1
- import React , { DeviceEventEmitter } from 'react-native'
1
+ import { DeviceEventEmitter } from 'react-native'
2
2
import TimerMixin from 'react-timer-mixin'
3
3
4
+ const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49
5
+
4
6
const KeyboardAwareMixin = {
5
- propTypes : {
6
- viewIsInsideTabBar : React . PropTypes . bool ,
7
- } ,
8
7
mixins : [ TimerMixin ] ,
9
8
9
+ setViewIsInsideTabBar : function ( viewIsInsideTabBar ) {
10
+ this . viewIsInsideTabBar = viewIsInsideTabBar
11
+ this . setState ( { keyboardSpace : _KAM_DEFAULT_TAB_BAR_HEIGHT } )
12
+ } ,
13
+
10
14
getInitialState : function ( props ) {
15
+ this . viewIsInsideTabBar = false
11
16
return {
12
17
keyboardSpace : 0 ,
13
18
}
14
19
} ,
15
20
16
21
// Keyboard actions
17
- // TODO: automatically handle TabBar height instead of using props
18
22
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
20
24
this . setState ( {
21
25
keyboardSpace : keyboardSpace ,
22
26
} )
@@ -43,7 +47,7 @@ const KeyboardAwareMixin = {
43
47
/**
44
48
* @param extraHeight: takes an extra height in consideration.
45
49
*/
46
- scrollToFocusedInput : function ( event , reactNode , extraHeight = 49 ) {
50
+ scrollToFocusedInput : function ( event , reactNode , extraHeight = _KAM_DEFAULT_TAB_BAR_HEIGHT ) {
47
51
const scrollView = this . refs . keyboardView . getScrollResponder ( )
48
52
this . setTimeout ( ( ) => {
49
53
scrollView . scrollResponderScrollNativeHandleToKeyboard (
0 commit comments