|
3 | 3 | View, |
4 | 4 | Text, |
5 | 5 | Image, |
| 6 | + Keyboard, |
6 | 7 | SectionList, |
7 | 8 | ActivityIndicator, |
8 | 9 | LayoutAnimation, |
|
37 | 38 | currentSwipeIndex: 0, |
38 | 39 | searchedEmployees: [], |
39 | 40 | screenState: 'normal', |
| 41 | + isKeyboardShowing: false, |
40 | 42 | } |
41 | 43 | } |
42 | 44 |
|
43 | | - // _animateOnMount = () => { |
44 | | - // LayoutAnimation.configureNext({ |
45 | | - // duration: 700, |
46 | | - // create: { |
47 | | - // type: LayoutAnimation.Types.linear, |
48 | | - // property: LayoutAnimation.Properties.opacity, |
49 | | - // }, |
50 | | - // update: { |
51 | | - // type: LayoutAnimation.Types.spring, |
52 | | - // springDamping: 0.75, |
53 | | - // }, |
54 | | - // }); |
55 | | - // } |
56 | | - |
57 | 45 | componentDidMount() { |
58 | 46 | // this._animateOnMount(); |
59 | 47 | LayoutAnimation.configureNext(LayoutAnimation.Presets.spring); |
|
67 | 55 | this.props.fetchEmployeesAndDepartments() |
68 | 56 | } |
69 | 57 | } |
| 58 | + this.screenHeight = getHeight() |
| 59 | + this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow); |
| 60 | + this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide); |
| 61 | + } |
| 62 | + |
| 63 | + _keyboardDidShow = () => { |
| 64 | + // this.setState({isKeyboardShowing: true}); |
| 65 | + } |
| 66 | + |
| 67 | + _keyboardDidHide = () => { |
| 68 | + this.setState({isKeyboardShowing: false}); |
70 | 69 | } |
71 | 70 |
|
72 | 71 | _onSearchBarTextChange = (text) => { |
|
75 | 74 | } |
76 | 75 |
|
77 | 76 | _onSearchBarFocus = () => { |
78 | | - this.setState({ isSearching: true }); |
| 77 | + this.setState({isKeyboardShowing: true}); |
| 78 | + this.timeout = setTimeout(() => { |
| 79 | + this.setState({ isSearching: true }); |
| 80 | + }, 300); |
79 | 81 | } |
80 | 82 |
|
81 | 83 | _onReturnAction = () => { |
|
84 | 86 | } |
85 | 87 |
|
86 | 88 | _onSearchCancel = () => { |
87 | | - this.setState({ searchedEmployees: [] }); |
88 | | - this.setState({ isSearching: false }); |
| 89 | + this.timeout = setTimeout(() => { |
| 90 | + this.setState({ searchedEmployees: [] }); |
| 91 | + this.setState({ isSearching: false }); |
| 92 | + }, 300); |
89 | 93 | } |
90 | 94 |
|
91 | 95 | _onCellSelection = (data) => { |
|
178 | 182 |
|
179 | 183 | _renderSearchView = () => { |
180 | 184 | return ( |
181 | | - <View style={style.searchViewContainer}> |
| 185 | + <View style={[style.searchViewContainer, {height: this.state.isKeyboardShowing ? this.screenHeight - 280 : this.screenHeight - 115}]}> |
182 | 186 | <SearchContactView |
183 | 187 | data={this.state.searchedEmployees} |
184 | 188 | onPress={this._onCellSelection} |
185 | 189 | /> |
186 | | - <KeyboardSpacer/> |
187 | 190 | </View> |
188 | 191 | ) |
189 | 192 | } |
|
0 commit comments