Skip to content

Commit c0ebc22

Browse files
committed
LFG-187: fixes
1 parent 6d7a683 commit c0ebc22

File tree

10 files changed

+67
-78
lines changed

10 files changed

+67
-78
lines changed
1.65 KB
Loading
11.2 KB
Loading

app/actions/fetchActions.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@ export const validateEmail = (token) => (dispatch) => {
2525
)
2626
}
2727

28-
// export const fetchEmployeeFromAPI = (apiKey) => {
29-
// return (dispatch) => {
30-
// dispatch(networkFetching(true))
31-
// fetch(uri.EMPLOYEES_LIST, Resource.employeesList(apiKey))
32-
// .then(data => data.json())
33-
// .then(jsonResponse => {
34-
// // console.log('json:', jsonResponse);
35-
// var state = store.getState();
36-
// var myProfile = util.getMyInformation(jsonResponse, state.rootReducer.auth.user.email)[0];
37-
// dispatch(employeeAction.myProfileInfo(myProfile));
38-
// dispatch(employeeList(jsonResponse));
39-
// dispatch(employeeAction.groupEmployeesOnDepartmentBasis(util.groupByDepartment(jsonResponse), state.rootReducer.department.departments))
40-
// dispatch(networkFetching(false));
41-
// })
42-
// .catch(err => {
43-
// // console.log('error-------');
44-
// dispatch(networkFetching(false));
45-
// dispatch(networkFetchError(err))
46-
// })
47-
// }
48-
// }
49-
5028
export const fetchEmployeesAndDepartmentsFromAPI = (apiKey) => {
5129
return (dispatch) => {
5230
dispatch(networkFetching(true))
@@ -88,27 +66,6 @@ networkFetchError = () => {
8866
}
8967
}
9068

91-
// validateLFEmail = (validationResponse) => {
92-
// return {
93-
// type: ActionType.VALIDATE_EMAIL,
94-
// validationResponse
95-
// }
96-
// }
97-
98-
// employeeList = (employees) => {
99-
// return {
100-
// type: ActionType.EMPLOYEES_LIST,
101-
// employees
102-
// }
103-
// }
104-
105-
// departmentList = (departments) => {
106-
// return {
107-
// type: ActionType.DEPARTMENT_LIST,
108-
// departments
109-
// }
110-
// }
111-
11269
// For local guest
11370
export const setGuestEmployeeAndDepartmentLocal = (employees, departments) => {
11471
return (dispatch) => {

app/screens/contact/contact.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
View,
44
Text,
55
Image,
6+
Keyboard,
67
SectionList,
78
ActivityIndicator,
89
LayoutAnimation,
@@ -37,23 +38,10 @@ const GUEST_EMAIL = '[email protected]'
3738
currentSwipeIndex: 0,
3839
searchedEmployees: [],
3940
screenState: 'normal',
41+
isKeyboardShowing: false,
4042
}
4143
}
4244

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-
5745
componentDidMount() {
5846
// this._animateOnMount();
5947
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
@@ -67,6 +55,17 @@ const GUEST_EMAIL = '[email protected]'
6755
this.props.fetchEmployeesAndDepartments()
6856
}
6957
}
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});
7069
}
7170

7271
_onSearchBarTextChange = (text) => {
@@ -75,7 +74,10 @@ const GUEST_EMAIL = '[email protected]'
7574
}
7675

7776
_onSearchBarFocus = () => {
78-
this.setState({ isSearching: true });
77+
this.setState({isKeyboardShowing: true});
78+
this.timeout = setTimeout(() => {
79+
this.setState({ isSearching: true });
80+
}, 300);
7981
}
8082

8183
_onReturnAction = () => {
@@ -84,8 +86,10 @@ const GUEST_EMAIL = '[email protected]'
8486
}
8587

8688
_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);
8993
}
9094

9195
_onCellSelection = (data) => {
@@ -178,12 +182,11 @@ const GUEST_EMAIL = '[email protected]'
178182

179183
_renderSearchView = () => {
180184
return (
181-
<View style={style.searchViewContainer}>
185+
<View style={[style.searchViewContainer, {height: this.state.isKeyboardShowing ? this.screenHeight - 280 : this.screenHeight - 115}]}>
182186
<SearchContactView
183187
data={this.state.searchedEmployees}
184188
onPress={this._onCellSelection}
185189
/>
186-
<KeyboardSpacer/>
187190
</View>
188191
)
189192
}

app/screens/contact/contactCell/styles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ const style = StyleSheet.create({
6161
},
6262
moreImage: {
6363
width: 18,
64-
marginHorizontal: 8,
64+
paddingHorizontal: 8,
6565
resizeMode: 'contain',
6666
shadowRadius: 4,
6767
shadowOpacity: 0.8,
6868
shadowColor: 'black',
6969
shadowOffset: { width: 0, height: 0 },
7070
},
7171
moreButton: {
72+
width: 25,
7273
alignSelf: 'center',
74+
alignItems: 'flex-end',
7375
justifyContent: 'center',
7476
// backgroundColor: 'purple',
7577
},

app/screens/login/login.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const GuestUser = {
4141
password: '',
4242
errorMessage: '',
4343
revokingAccess: false,
44+
disableBtn: false,
45+
isValidating: false,
4446
}
4547
}
4648

@@ -74,8 +76,7 @@ const GuestUser = {
7476
_revokeGoogleSigninAccess = () => {
7577
this.setState({revokingAccess: true})
7678
GoogleSignin.revokeAccess()
77-
.then(() => this.setState({revokingAccess: false}))
78-
.catch(err => this.setState({revokingAccess: false}))
79+
.done(() => { this.setState({revokingAccess: false}) })
7980
}
8081

8182
_showAlertWithMessage = (msg) => {
@@ -123,23 +124,24 @@ const GuestUser = {
123124
}
124125

125126
_googleSignIn = () => {
127+
this.setState({ disableBtn: true });
126128
GoogleSignin.signIn()
127129
.then((user) => {
128-
// console.log('xxxxx', user.email)
130+
this.setState({ isValidating: true })
129131
this.props.validateEmail(user.accessToken)
130132
.then(() => {
131133
this._afterValidation(user);
132134
})
133135
.catch((err) => {
134-
// console.log('errrrrr', err);
135136
this._showAlertWithMessage('Error Occured')
136137
})
138+
.done(() => this.setState({ isValidating: false }))
137139
})
138140
.catch((err) => {
139141
this._revokeGoogleSigninAccess()
140142
// console.log(WRONG_SIGNIN.message, err);
141143
})
142-
.done();
144+
.done(() => this.setState({ disableBtn: false }))
143145
}
144146

145147
_validateEmail = (email) => {
@@ -215,7 +217,7 @@ const GuestUser = {
215217
</View>
216218
<View style={style.buttonContainer}>
217219
{
218-
this.props.isValidating &&
220+
this.state.isValidating &&
219221
<ActivityIndicator size="large" color={colors.LF_DARK_GRREEN} style={[style.activityIndicator]} />
220222
}
221223
<Button
@@ -224,7 +226,7 @@ const GuestUser = {
224226
title={'Sign in with Google'}
225227
titleStyle={style.googleTitle}
226228
source={googleLogo}
227-
disabled={this.state.revokingAccess || this.props.isValidating}
229+
disabled={this.state.revokingAccess || this.state.disableBtn || this.state.isValidating}
228230
imageStyle={style.googleImage}
229231
onPress={() => this._googleSignIn()}
230232
/>

app/screens/login/loginContainer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as fetchActions from 'App/actions/fetchActions';
66

77
const mapStateToProps = (state) => ({
88
isLoggedIn: state.rootReducer.auth.loggedIn,
9-
isValidating: state.rootReducer.user.isFetching,
109
validationResponse: state.rootReducer.user.validationResponse,
1110
});
1211

app/screens/searchContact/searchContact.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,31 @@ import ContactCell from './../contact/contactCell';
3333

3434
_renderTableView = () => {
3535
return (
36-
<FlatList
37-
ref="ListView"
38-
data={this.props.data}
39-
keyExtractor={this._keyExtractor}
40-
renderItem={({item, section, index}) => this._renderCell(item) }
41-
/>
36+
<View style={style.listContainer}>
37+
<FlatList
38+
ref="ListView"
39+
data={this.props.data}
40+
keyExtractor={this._keyExtractor}
41+
renderItem={({item, section, index}) => this._renderCell(item) }
42+
/>
43+
</View>
4244
);
4345
}
46+
47+
_renderSearchResult = () => {
48+
return (
49+
<View style={style.searchResult}>
50+
<Text>{this.props.data.length} results found</Text>
51+
</View>
52+
)
53+
}
4454

4555
render() {
4656
return (
4757
<View style={ style.mainContainer }>
58+
{
59+
this._renderSearchResult()
60+
}
4861
{
4962
this._renderTableView()
5063
}

app/screens/searchContact/styles.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ const style = StyleSheet.create({
8080
color: 'white',
8181
paddingVertical: 5
8282
},
83-
83+
searchResult: {
84+
width: getWidth(),
85+
height: 35,
86+
alignItems: 'center',
87+
justifyContent: 'center',
88+
backgroundColor: colors.SYSTEM_LIGHT_GRAY,
89+
},
90+
searchResultText: {
91+
color: colors.MID_GRAY,
92+
},
93+
listContainer: {
94+
flex: 1,
95+
}
8496
});
8597

8698
export default style;

app/utils/dataNormalization.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const getMyInformation = (employeesList, email) => {
9898
//-------------------search----------
9999

100100
export const searchEmployeesOfName = (employeesList, characters) => {
101+
if (!characters) return []
101102
var chars = characters.toLowerCase()
102103
return employeesList.filter((employee) => {
103104
var name = (employee.firstName + " " + employee.lastName).toLowerCase();

0 commit comments

Comments
 (0)