From 6065eeac7a1b1906f34be992e64b9d42cb64ecbc Mon Sep 17 00:00:00 2001 From: Garrett McCullough Date: Fri, 20 Oct 2017 15:23:00 -0700 Subject: [PATCH 1/2] improve docs for KeyboardAvoidingView --- Libraries/Components/Keyboard/KeyboardAvoidingView.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 5b90702fefd363..13d3862bf30a8c 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -43,8 +43,8 @@ type KeyboardChangeEvent = { const viewRef = 'VIEW'; /** - * 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 position or bottom padding based on the position of the keyboard. + * This 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 position of the keyboard. */ const KeyboardAvoidingView = createReactClass({ displayName: 'KeyboardAvoidingView', @@ -52,6 +52,10 @@ const KeyboardAvoidingView = createReactClass({ propTypes: { ...ViewPropTypes, + /** + * Specify how the `KeyboardAvoidingView` will react to the presence of + * the keyboard. Will it adjust its height, position or bottom padding? + */ behavior: PropTypes.oneOf(['height', 'position', 'padding']), /** @@ -61,7 +65,7 @@ const KeyboardAvoidingView = createReactClass({ /** * This is the distance between the top of the user screen and the react native view, - * may be non-zero in some use cases. + * may be non-zero in some use cases. The default value is 0. */ keyboardVerticalOffset: PropTypes.number.isRequired, }, From 09874b5dafe99d8668fc97713e2ada6fca473570 Mon Sep 17 00:00:00 2001 From: Garrett McCullough Date: Mon, 23 Oct 2017 12:06:16 -0700 Subject: [PATCH 2/2] update verbiage on docs and rename internal component functions to hide them from appearing on docs --- .../Keyboard/KeyboardAvoidingView.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 13d3862bf30a8c..1f6c4848496d5d 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -54,7 +54,7 @@ const KeyboardAvoidingView = createReactClass({ ...ViewPropTypes, /** * Specify how the `KeyboardAvoidingView` will react to the presence of - * the keyboard. Will it adjust its height, position or bottom padding? + * the keyboard. It can adjust the height, position or bottom padding of the view */ behavior: PropTypes.oneOf(['height', 'position', 'padding']), @@ -85,7 +85,7 @@ const KeyboardAvoidingView = createReactClass({ subscriptions: ([]: Array), frame: (null: ?ViewLayout), - relativeKeyboardHeight(keyboardFrame: ScreenRect): number { + _relativeKeyboardHeight(keyboardFrame: ScreenRect): number { const frame = this.frame; if (!frame || !keyboardFrame) { return 0; @@ -98,14 +98,14 @@ const KeyboardAvoidingView = createReactClass({ return Math.max(frame.y + frame.height - keyboardY, 0); }, - onKeyboardChange(event: ?KeyboardChangeEvent) { + _onKeyboardChange(event: ?KeyboardChangeEvent) { if (!event) { this.setState({bottom: 0}); return; } const {duration, easing, endCoordinates} = event; - const height = this.relativeKeyboardHeight(endCoordinates); + const height = this._relativeKeyboardHeight(endCoordinates); if (duration && easing) { LayoutAnimation.configureNext({ @@ -119,7 +119,7 @@ const KeyboardAvoidingView = createReactClass({ this.setState({bottom: height}); }, - onLayout(event: ViewLayoutEvent) { + _onLayout(event: ViewLayoutEvent) { this.frame = event.nativeEvent.layout; }, @@ -136,12 +136,12 @@ const KeyboardAvoidingView = createReactClass({ componentWillMount() { if (Platform.OS === 'ios') { this.subscriptions = [ - Keyboard.addListener('keyboardWillChangeFrame', this.onKeyboardChange), + Keyboard.addListener('keyboardWillChangeFrame', this._onKeyboardChange), ]; } else { this.subscriptions = [ - Keyboard.addListener('keyboardDidHide', this.onKeyboardChange), - Keyboard.addListener('keyboardDidShow', this.onKeyboardChange), + Keyboard.addListener('keyboardDidHide', this._onKeyboardChange), + Keyboard.addListener('keyboardDidShow', this._onKeyboardChange), ]; } }, @@ -165,7 +165,7 @@ const KeyboardAvoidingView = createReactClass({ heightStyle = {height: this.frame.height - this.state.bottom, flex: 0}; } return ( - + {children} ); @@ -175,7 +175,7 @@ const KeyboardAvoidingView = createReactClass({ const { contentContainerStyle } = this.props; return ( - + {children} @@ -185,14 +185,14 @@ const KeyboardAvoidingView = createReactClass({ case 'padding': const paddingStyle = {paddingBottom: this.state.bottom}; return ( - + {children} ); default: return ( - + {children} );