From fcb689fdd18a6dd225e746bf238a6665efcc7037 Mon Sep 17 00:00:00 2001 From: ayushjainrksh Date: Thu, 18 Jun 2020 22:48:37 +0530 Subject: [PATCH 1/2] Update the KeyboardAvoidingView component * Update the title and prop description from docs. * Remove asterisks from the comments. * Add snackplayer example with example annotation. * Add inherit annotation for inherited component. --- .../Keyboard/KeyboardAvoidingView.js | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 07513e253b7041..43f848c8ae1910 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -30,24 +30,25 @@ type Props = $ReadOnly<{| ...ViewProps, /** - * Specify how to react to the presence of the keyboard. + Specify how to react to the presence of the keyboard. + + > Android and iOS both interact with this prop differently. On both iOS and Android, setting `behavior` is recommended. */ behavior?: ?('height' | 'position' | 'padding'), /** - * Style of the content container when `behavior` is 'position'. + The style of the content container(View) when behavior is 'position'. */ contentContainerStyle?: ?ViewStyleProp, /** - * Controls whether this `KeyboardAvoidingView` instance should take effect. - * This is useful when more than one is on the screen. Defaults to true. + Enabled or disabled KeyboardAvoidingView. The default is `true`. */ enabled: ?boolean, /** - * Distance between the top of the user screen and the React Native view. This - * may be non-zero in some cases. Defaults to 0. + This is the distance between the top of the user screen and the react native view, + may be non-zero in some use cases. Defaults to 0. */ keyboardVerticalOffset: number, |}>; @@ -57,8 +58,61 @@ type State = {| |}; /** - * View that moves out of the way when the keyboard appears by automatically - * adjusting its height, position, or bottom padding. + It is a component to solve the common problem of views that need to move out of the way of the virtual keyboard. + It can automatically adjust either its height, position, or bottom padding based on the keyboard height. + + @example ```SnackPlayer name=KeyboardAvoidingView&supportedPlatforms=android,ios + import React from 'react'; + import { View, KeyboardAvoidingView, TextInput, StyleSheet, Text, Platform, TouchableWithoutFeedback, Button, Keyboard } from 'react-native'; + + const KeyboardAvoidingComponent = () => { + return ( + + + + Header + + +