1- import React , { DeviceEventEmitter } from 'react-native'
1+ import { DeviceEventEmitter } from 'react-native'
22import TimerMixin from 'react-timer-mixin'
33
4+ const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49
5+
46const KeyboardAwareMixin = {
5- propTypes : {
6- viewIsInsideTabBar : React . PropTypes . bool ,
7- } ,
87 mixins : [ TimerMixin ] ,
98
9+ setViewIsInsideTabBar : function ( viewIsInsideTabBar ) {
10+ this . viewIsInsideTabBar = viewIsInsideTabBar
11+ this . setState ( { keyboardSpace : _KAM_DEFAULT_TAB_BAR_HEIGHT } )
12+ } ,
13+
1014 getInitialState : function ( props ) {
15+ this . viewIsInsideTabBar = false
1116 return {
1217 keyboardSpace : 0 ,
1318 }
1419 } ,
1520
1621 // Keyboard actions
17- // TODO: automatically handle TabBar height instead of using props
1822 updateKeyboardSpace : function ( frames ) {
19- const keyboardSpace = ( this . props . viewIsInsideTabBar ) ? frames . endCoordinates . height - 49 : frames . endCoordinates . height
23+ const keyboardSpace = ( this . props . viewIsInsideTabBar ) ? frames . endCoordinates . height - _KAM_DEFAULT_TAB_BAR_HEIGHT : frames . endCoordinates . height
2024 this . setState ( {
2125 keyboardSpace : keyboardSpace ,
2226 } )
@@ -43,7 +47,7 @@ const KeyboardAwareMixin = {
4347 /**
4448 * @param extraHeight: takes an extra height in consideration.
4549 */
46- scrollToFocusedInput : function ( event , reactNode , extraHeight = 49 ) {
50+ scrollToFocusedInput : function ( event , reactNode , extraHeight = _KAM_DEFAULT_TAB_BAR_HEIGHT ) {
4751 const scrollView = this . refs . keyboardView . getScrollResponder ( )
4852 this . setTimeout ( ( ) => {
4953 scrollView . scrollResponderScrollNativeHandleToKeyboard (
0 commit comments