From 8e514040801c73c6e057ef0353c6b0e2c967ff2b Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Sat, 4 Jun 2016 12:16:59 -0300 Subject: [PATCH 1/5] Make it handle android keyboard events --- lib/KeyboardAwareMixin.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/KeyboardAwareMixin.js b/lib/KeyboardAwareMixin.js index 8d740c9..459230d 100644 --- a/lib/KeyboardAwareMixin.js +++ b/lib/KeyboardAwareMixin.js @@ -8,6 +8,8 @@ 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: { @@ -73,8 +75,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 () { From e229205711b8ff697c9895b75ebd05c637c78e47 Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Sat, 4 Jun 2016 12:50:55 -0300 Subject: [PATCH 2/5] No need to do scrollToFocusedInput on Android --- lib/KeyboardAwareMixin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/KeyboardAwareMixin.js b/lib/KeyboardAwareMixin.js index 459230d..57ca386 100644 --- a/lib/KeyboardAwareMixin.js +++ b/lib/KeyboardAwareMixin.js @@ -97,6 +97,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( From 7ac221786b3663254d3054f1ad94b3444b476d68 Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Sat, 4 Jun 2016 12:51:17 -0300 Subject: [PATCH 3/5] Fix keyboard flickering on input change on Android --- lib/KeyboardAwareScrollView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/KeyboardAwareScrollView.js b/lib/KeyboardAwareScrollView.js index 41e6ed7..dbea3ce 100644 --- a/lib/KeyboardAwareScrollView.js +++ b/lib/KeyboardAwareScrollView.js @@ -25,6 +25,7 @@ const KeyboardAwareScrollView = React.createClass({ From bd5a58ef8579865f99972742dbeef1b93708de57 Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Mon, 27 Jun 2016 10:08:38 -0300 Subject: [PATCH 4/5] Remove option form default as request --- lib/KeyboardAwareScrollView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/KeyboardAwareScrollView.js b/lib/KeyboardAwareScrollView.js index dbea3ce..41e6ed7 100644 --- a/lib/KeyboardAwareScrollView.js +++ b/lib/KeyboardAwareScrollView.js @@ -25,7 +25,6 @@ const KeyboardAwareScrollView = React.createClass({ From efd7676b09ced2ef50af55615211a21692d90671 Mon Sep 17 00:00:00 2001 From: Gabriel Rubens Date: Mon, 27 Jun 2016 10:10:36 -0300 Subject: [PATCH 5/5] Import Platform --- lib/KeyboardAwareMixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/KeyboardAwareMixin.js b/lib/KeyboardAwareMixin.js index 57ca386..1c022ba 100644 --- a/lib/KeyboardAwareMixin.js +++ b/lib/KeyboardAwareMixin.js @@ -1,7 +1,7 @@ /* @flow */ import { PropTypes } from 'react' -import ReactNative, { TextInput, Keyboard } from 'react-native' +import ReactNative, { TextInput, Keyboard, Platform } from 'react-native' import TimerMixin from 'react-timer-mixin' const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49