@@ -3,12 +3,14 @@ import {
33 View ,
44 Text ,
55 Image ,
6- SectionList
6+ SectionList ,
7+ ActivityIndicator ,
78 } from 'react-native' ;
89import Swiper from 'react-native-swiper' ;
910import Search from 'react-native-search-box' ;
1011import ParallaxScrollView from 'react-native-parallax-scroll-view' ;
1112
13+ import * as util from 'App/utils/dataNormalization' ;
1214import colors from 'App/config/colors' ;
1315import ContactCell from './contactCell' ;
1416import screens from 'App/constants/screens' ;
@@ -62,6 +64,10 @@ const DEPARTMENT_LIST = [{
6264 }
6365 }
6466
67+ componentDidMount ( ) {
68+ this . props . employees ? null : this . props . fetchEmployees ( )
69+ }
70+
6571 _onSearchBarTextChange = ( ) => {
6672 console . log ( 'bigno' ) ;
6773 }
@@ -173,35 +179,61 @@ const DEPARTMENT_LIST = [{
173179 } )
174180 }
175181
182+ _renderStatusBar = ( ) => {
183+ return (
184+ < View style = { [ style . statusBar , { height : 20 } ] } />
185+ )
186+ }
187+
188+ _renderSearchBar = ( ) => {
189+ return (
190+ < Search
191+ ref = { component => this . searchBar = component }
192+ backgroundColor = { colors . LF_DARK_GRREEN }
193+ titleCancelColor = 'white'
194+ onChangeText = { this . _onSearchBarTextChange }
195+ onFocus = { this . _onSearchBarFocus }
196+ afterSearch = { this . onSearch }
197+ afterCancel = { this . onCancel }
198+ keyboardDismissOnSubmit = { true }
199+ blurOnSubmit = { true }
200+ />
201+ )
202+ }
203+
204+ _renderSwiper = ( ) => {
205+ return (
206+ < Swiper
207+ style = { style . wrapper }
208+ loop = { false }
209+ onIndexChanged = { this . _onMomentumScrollEnd }
210+ activeDotStyle = { { marginBottom : DOT_MARGIN } }
211+ activeDotColor = { colors . LF_DARK_GRREEN }
212+ dotStyle = { { marginBottom : DOT_MARGIN } } >
213+ {
214+ DEPARTMENT_LIST . map ( ( data , index ) => this . _renderTableView ( data , index ) )
215+ }
216+ </ Swiper >
217+ )
218+ }
219+
220+ _renderActivityIndicator = ( ) => {
221+ return (
222+ < View style = { [ style . container , style . horizontal ] } >
223+ < ActivityIndicator size = "large" color = { colors . GRAY } />
224+ </ View >
225+ )
226+ }
227+
176228 render ( ) {
177229 return (
178230 < View style = { style . mainContainer } >
179- < View style = { [ style . statusBar , { height : 20 } ] } />
231+ { this . _renderStatusBar ( ) }
180232 < View style = { style . searchContainer } >
181- < Search
182- ref = { component => this . searchBar = component }
183- backgroundColor = { colors . LF_DARK_GRREEN }
184- titleCancelColor = 'white'
185- onChangeText = { this . _onSearchBarTextChange }
186- onFocus = { this . _onSearchBarFocus }
187- afterSearch = { this . onSearch }
188- afterCancel = { this . onCancel }
189- keyboardDismissOnSubmit = { true }
190- blurOnSubmit = { true }
191- />
233+ { this . _renderSearchBar ( ) }
192234 </ View >
193235 < View style = { style . tableContainer } >
194- < Swiper
195- style = { style . wrapper }
196- loop = { false }
197- onIndexChanged = { this . _onMomentumScrollEnd }
198- activeDotStyle = { { marginBottom : DOT_MARGIN } }
199- activeDotColor = { colors . LF_DARK_GRREEN }
200- dotStyle = { { marginBottom : DOT_MARGIN } } >
201- {
202- DEPARTMENT_LIST . map ( ( data , index ) => this . _renderTableView ( data , index ) )
203- }
204- </ Swiper >
236+ { this . props . employees ? this . _renderSwiper ( ) : this . _renderActivityIndicator ( ) }
205237 </ View >
206238 </ View >
207239 ) ;
0 commit comments