@@ -12,13 +12,14 @@ import Swiper from 'react-native-swiper';
1212import Search from 'react-native-search-box' ;
1313import ParallaxScrollView from 'react-native-parallax-scroll-view' ;
1414
15- import * as util from 'App/utils/dataNormalization' ;
1615import colors from 'App/config/colors' ;
1716import ContactCell from './contactCell' ;
1817import screens from 'App/constants/screens' ;
18+ import * as util from 'App/utils/dataNormalization' ;
19+ import SearchContactView from 'App/screens/searchContact' ;
1920import { getWidth , getHeight } from 'App/utils/dimension' ;
21+ import { searchEmployeesOfName } from 'App/utils/dataNormalization' ;
2022import style , { AVATAR_SIZE , STICKY_HEADER_HEIGHT , DOT_MARGIN , PARALLAX_HEADER_HEIGHT } from './styles' ;
21- import { setInterval } from 'core-js/library/web/timers' ;
2223
2324const DEPARTMENT_LIST = [ {
2425 name : 'iOS' ,
@@ -63,7 +64,9 @@ const DEPARTMENT_LIST = [{
6364 super ( props ) ;
6465
6566 this . state = {
67+ isSearching : false ,
6668 currentSwipeIndex : 0 ,
69+ searchedEmployees : [ ] ,
6770 }
6871 }
6972
@@ -84,50 +87,53 @@ const DEPARTMENT_LIST = [{
8487 componentDidMount ( ) {
8588 // this._animateOnMount();
8689 LayoutAnimation . configureNext ( LayoutAnimation . Presets . spring ) ;
87-
88- this . props . employees ? null : this . props . fetchEmployees ( )
90+ if ( ! this . props . employees ) { this . props . fetchEmployees ( ) }
8991 }
9092
91- _onSearchBarTextChange = ( ) => {
92- console . log ( 'bigno' ) ;
93+ _onSearchBarTextChange = ( text ) => {
94+ var employees = searchEmployeesOfName ( this . props . employees , text ) ;
95+ this . setState ( { searchedEmployees : employees } ) ;
9396 }
9497
9598 _onSearchBarFocus = ( ) => {
96- console . log ( 'focus' ) ;
99+ this . setState ( { isSearching : true } ) ;
97100 }
98101
99- _onSearch = ( ) => {
100- console . log ( 'search' ) ;
102+ _onReturnAction = ( ) => {
103+ // also cancels on done button action
104+ this . _onSearchCancel ( ) ;
101105 }
102106
103107 _onSearchCancel = ( ) => {
104- console . log ( 'cancel' ) ;
108+ this . setState ( { searchedEmployees : [ ] } ) ;
109+ this . setState ( { isSearching : false } ) ;
105110 }
106111
107- _onCellSelection = ( ) => {
108- // this.props.navigator.push({
109- // screen: screens.PROFILE_SCREEN.id,
110- // animated: true,
111- // overrideBackPress: true,
112- // navigatorStyle: {
113- // drawUnderNavBar: true,
114- // navBarTranslucent: true,
115- // navBarTransparent: true,
116- // navBarTextColor: 'white',
117- // navBarTransparency: 1,
118- // navBarButtonColor: 'white',
119- // navBarLeftButtonColor: 'white',
120- // navBarRightButtonColor: 'white',
121- // },
122- // title: '',
123- // passProps: {
124- // data: {
125- // department: DEPARTMENT_LIST[this.state.currentSwipeIndex]
126- // }
127- // }
128- // });
112+ _onCellSelection = ( data ) => {
113+ this . props . navigator . push ( {
114+ screen : screens . PROFILE_SCREEN . id ,
115+ animated : true ,
116+ overrideBackPress : true ,
117+ navigatorStyle : {
118+ drawUnderNavBar : true ,
119+ navBarTranslucent : true ,
120+ navBarTransparent : true ,
121+ navBarTextColor : 'white' ,
122+ navBarTransparency : 1 ,
123+ navBarButtonColor : 'white' ,
124+ navBarLeftButtonColor : 'white' ,
125+ navBarRightButtonColor : 'white' ,
126+ } ,
127+ title : '' ,
128+ passProps : {
129+ data : {
130+ profile : data
131+ }
132+ }
133+ } ) ;
129134 }
130135
136+ /*
131137 _renderParallaxTableHeaderView = (data, index) => {
132138 // return (<View style={{width: 200, height: 200}}>asd</View>)
133139 return (
@@ -167,6 +173,7 @@ const DEPARTMENT_LIST = [{
167173 />
168174 );
169175 }
176+ */
170177
171178 _renderTableView = ( employees , index ) => {
172179 const { onScroll = ( ) => { } } = this . props ;
@@ -209,11 +216,12 @@ const DEPARTMENT_LIST = [{
209216 ref = { component => this . searchBar = component }
210217 backgroundColor = { colors . LF_DARK_GRREEN }
211218 titleCancelColor = 'white'
212- onChangeText = { this . _onSearchBarTextChange }
213- onFocus = { this . _onSearchBarFocus }
214- afterSearch = { this . onSearch }
215- afterCancel = { this . onCancel }
219+ onChangeText = { ( text ) => this . _onSearchBarTextChange ( text ) }
220+ onFocus = { ( ) => this . _onSearchBarFocus ( ) }
221+ afterSearch = { ( ) => this . _onReturnAction ( ) }
222+ afterCancel = { ( ) => this . _onSearchCancel ( ) }
216223 keyboardDismissOnSubmit = { true }
224+ returnKeyType = { 'done' }
217225 blurOnSubmit = { true }
218226 />
219227 )
@@ -243,6 +251,18 @@ const DEPARTMENT_LIST = [{
243251 )
244252 }
245253
254+ _renderSearchView = ( ) => {
255+ console . log ( '_renderSearchView' )
256+ return (
257+ < View style = { style . searchViewContainer } >
258+ < SearchContactView
259+ data = { this . state . searchedEmployees }
260+ onPress = { this . _onCellSelection }
261+ />
262+ </ View >
263+ )
264+ }
265+
246266 render ( ) {
247267 // setInterval(() => {
248268 // console.log('----_CONTACT', this.props.groupedEmp);
@@ -255,7 +275,9 @@ const DEPARTMENT_LIST = [{
255275 { this . _renderSearchBar ( ) }
256276 </ View >
257277 < View style = { style . tableContainer } >
258- { this . props . employees ? this . _renderSwiper ( ) : this . _renderActivityIndicator ( ) }
278+ { ( ! this . props . employees ) && this . _renderActivityIndicator ( ) }
279+ { ( this . props . employees ) && this . _renderSwiper ( ) }
280+ { ( this . state . isSearching ) && this . _renderSearchView ( ) }
259281 </ View >
260282 </ View >
261283 ) ;
0 commit comments