From 551938c6690e7bde10d87fcb854ed7a6f5986fb1 Mon Sep 17 00:00:00 2001 From: Nate Armstrong Date: Tue, 17 Oct 2017 13:57:22 -0600 Subject: [PATCH] Support layout changes * Updates keyboard space when device rotates * Updates keyboard space when props.topSpacing changes --- KeyboardSpacer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/KeyboardSpacer.js b/KeyboardSpacer.js index 14560d8..1740aa2 100644 --- a/KeyboardSpacer.js +++ b/KeyboardSpacer.js @@ -59,7 +59,7 @@ export default class KeyboardSpacer extends Component { } componentDidMount() { - const updateListener = Platform.OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow'; + const updateListener = Platform.OS === 'android' ? 'keyboardDidShow' : 'keyboardWillChangeFrame'; const resetListener = Platform.OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide'; this._listeners = [ Keyboard.addListener(updateListener, this.updateKeyboardSpace), @@ -91,7 +91,7 @@ export default class KeyboardSpacer extends Component { // when external physical keyboard is connected // event.endCoordinates.height still equals virtual keyboard height // however only the keyboard toolbar is showing if there should be one - const keyboardSpace = (screenHeight - event.endCoordinates.screenY) + this.props.topSpacing; + const keyboardSpace = (screenHeight - event.endCoordinates.screenY); this.setState({ keyboardSpace, isKeyboardOpened: true @@ -116,7 +116,8 @@ export default class KeyboardSpacer extends Component { } render() { + const height = this.state.keyboardSpace + this.props.topSpacing return ( - ); + ); } }