7
7
StyleSheet ,
8
8
View ,
9
9
Platform ,
10
+ Keyboard ,
10
11
} from 'react-native' ;
11
12
import TabBarIcon from './TabBarIcon' ;
12
13
import SafeAreaView from '../SafeAreaView' ;
@@ -46,11 +47,15 @@ type Props = {
46
47
isLandscape : boolean ,
47
48
} ;
48
49
50
+ type State = {
51
+ isVisible : boolean ,
52
+ } ;
53
+
49
54
const majorVersion = parseInt ( Platform . Version , 10 ) ;
50
55
const isIos = Platform . OS === 'ios' ;
51
56
const useHorizontalTabs = majorVersion >= 11 && isIos ;
52
57
53
- class TabBarBottom extends React . PureComponent < Props > {
58
+ class TabBarBottom extends React . PureComponent < Props , State > {
54
59
// See https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/UIKitUICatalog/UITabBar.html
55
60
static defaultProps = {
56
61
activeTintColor : '#3478f6' , // Default active tint color in iOS 10
@@ -64,6 +69,41 @@ class TabBarBottom extends React.PureComponent<Props> {
64
69
65
70
props : Props ;
66
71
72
+ state : State = {
73
+ isVisible : true ,
74
+ } ;
75
+
76
+ _keyboardDidShowSub = undefined ;
77
+ _keyboardDidHideSub = undefined ;
78
+
79
+ componentWillMount ( ) {
80
+ this . _keyboardDidShowSub = Keyboard . addListener (
81
+ 'keyboardDidShow' ,
82
+ this . _keyboardDidShow
83
+ ) ;
84
+ this . _keyboardDidHideSub = Keyboard . addListener (
85
+ 'keyboardDidHide' ,
86
+ this . _keyboardDidHide
87
+ ) ;
88
+ }
89
+
90
+ componentWillUnmount ( ) {
91
+ this . _keyboardDidShowSub ! == undefined && this . _keyboardDidShowSub . remove ( ) ;
92
+ this . _keyboardDidHideSub ! == undefined && this . _keyboardDidHideSub . remove ( ) ;
93
+ }
94
+
95
+ _keyboardDidShow = ( ) => {
96
+ this . setState ( {
97
+ isVisible : false ,
98
+ } ) ;
99
+ } ;
100
+
101
+ _keyboardDidHide = ( ) => {
102
+ this . setState ( {
103
+ isVisible : true ,
104
+ } ) ;
105
+ } ;
106
+
67
107
_renderLabel = ( scene : TabScene ) => {
68
108
const {
69
109
position,
@@ -178,7 +218,7 @@ class TabBarBottom extends React.PureComponent<Props> {
178
218
style ,
179
219
] ;
180
220
181
- return (
221
+ return this . state . isVisible ? (
182
222
< Animated . View >
183
223
< SafeAreaView
184
224
style = { tabBarStyle }
@@ -228,7 +268,7 @@ class TabBarBottom extends React.PureComponent<Props> {
228
268
} ) }
229
269
</ SafeAreaView >
230
270
</ Animated . View >
231
- ) ;
271
+ ) : null ;
232
272
}
233
273
}
234
274
0 commit comments