diff --git a/lib/KeyboardAwareMixin.js b/lib/KeyboardAwareMixin.js index 9289a2e..14cfb22 100644 --- a/lib/KeyboardAwareMixin.js +++ b/lib/KeyboardAwareMixin.js @@ -1,13 +1,15 @@ /* @flow */ import { PropTypes } from 'react' -import ReactNative, { TextInput, Keyboard, UIManager } from 'react-native' +import ReactNative, { TextInput, Keyboard, Platform, UIManager } from 'react-native' import TimerMixin from 'react-timer-mixin' const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49 const _KAM_KEYBOARD_OPENING_TIME = 250 const _KAM_EXTRA_HEIGHT = 75 +const isAndroid = () => Platform.OS === 'android' + const KeyboardAwareMixin = { mixins: [TimerMixin], propTypes: { @@ -89,8 +91,12 @@ const KeyboardAwareMixin = { componentDidMount: function () { // Keyboard events - this.keyboardWillShowEvent = Keyboard.addListener('keyboardWillShow', this.updateKeyboardSpace) - this.keyboardWillHideEvent = Keyboard.addListener('keyboardWillHide', this.resetKeyboardSpace) + const events = { + show: isAndroid() ? 'keyboardDidShow' : 'keyboardWillShow', + hide: isAndroid() ? 'keyboardDidHide' : 'keyboardWillHide', + } + this.keyboardWillShowEvent = Keyboard.addListener(events.show, this.updateKeyboardSpace) + this.keyboardWillHideEvent = Keyboard.addListener(events.hide, this.resetKeyboardSpace) }, componentWillUnmount: function () { @@ -107,6 +113,9 @@ const KeyboardAwareMixin = { * @param extraHeight: takes an extra height in consideration. */ scrollToFocusedInput: function (reactNode: Object, extraHeight: number = this.props.extraHeight) { + // Android already does this + if(isAndroid()) return; + const scrollView = this.refs._rnkasv_keyboardView.getScrollResponder() this.setTimeout(() => { scrollView.scrollResponderScrollNativeHandleToKeyboard(