@@ -5,17 +5,18 @@ import {
5
5
View ,
6
6
TextInput ,
7
7
TouchableOpacity ,
8
+ Image ,
8
9
} from 'react-native' ;
9
10
import { Formik } from 'formik' ;
10
11
import SafeAreaView from 'react-native-safe-area-view' ;
11
- // import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
12
+ import FontAwesome5 from 'react-native-vector-icons/FontAwesome5' ;
12
13
import firebase from 'firebase' ;
13
14
import { useNavigation } from '@react-navigation/native' ;
14
15
15
16
import RegisterSchema from '../validation/Register' ;
16
17
import { primaryColor } from '../theme' ;
17
18
18
- export default function RegisterScreen ( props ) {
19
+ export default function RegisterScreen ( ) {
19
20
const navigation = useNavigation ( ) ;
20
21
const { navigate} = navigation ;
21
22
@@ -28,9 +29,16 @@ export default function RegisterScreen(props) {
28
29
. auth ( )
29
30
. createUserWithEmailAndPassword ( email , password )
30
31
. then ( userCredentials => {
31
- return userCredentials . user . updateProfile ( {
32
- displayName : fullName ,
33
- } ) ;
32
+ const uid = userCredentials . user . uid ;
33
+ firebase
34
+ . firestore ( )
35
+ . collection ( 'users' )
36
+ . doc ( uid )
37
+ . set ( { fullName, phone, email} )
38
+ . then ( res => {
39
+ setErrorMessage ( '' ) ;
40
+ } )
41
+ . catch ( error => setErrorMessage ( error . message ) ) ;
34
42
} )
35
43
. catch ( error => setErrorMessage ( error . message ) ) ;
36
44
@@ -48,20 +56,33 @@ export default function RegisterScreen(props) {
48
56
return (
49
57
< SafeAreaView style = { styles . container } >
50
58
< Text style = { styles . greeting } > Sign up to get started</ Text >
51
- < View style = { styles . errorMessage } >
52
- < Text style = { styles . error } > { errorMessage } </ Text >
53
- </ View >
59
+
60
+ { /* <TouchableOpacity
61
+ style={styles.back}
62
+ onPress={() => navigation.goBack()}>
63
+ <FontAwesome5
64
+ name="chevron-left"
65
+ size={32}
66
+ color="#000000"></FontAwesome5>
67
+ </TouchableOpacity> */ }
68
+
54
69
{ /* <View
55
70
style={{
56
71
// position: 'absolute',
57
72
// top: 64,
58
73
alignItems: 'center',
59
74
width: '100%',
60
75
}}>
61
- <TouchableOpacity style={styles.avatar}>
62
- <FontAwesome5 name={'heart'} size={24} />
76
+ <TouchableOpacity style={styles.avatarPlaceholder}>
77
+ <Image source={null} style={styles.avatar} />
78
+ <FontAwesome5 name={'plus'} size={24} color="#FFF" />
63
79
</TouchableOpacity>
64
80
</View> */ }
81
+
82
+ < View style = { styles . errorMessage } >
83
+ < Text style = { styles . error } > { errorMessage } </ Text >
84
+ </ View >
85
+
65
86
< Formik
66
87
initialValues = { {
67
88
fullName : 'Trinh Chin Chin' ,
@@ -171,6 +192,12 @@ const styles = StyleSheet.create({
171
192
justifyContent : 'center' ,
172
193
marginHorizontal : 30 ,
173
194
} ,
195
+ error : {
196
+ color : primaryColor ,
197
+ fontSize : 13 ,
198
+ fontWeight : '600' ,
199
+ textAlign : 'center' ,
200
+ } ,
174
201
form : {
175
202
marginBottom : 48 ,
176
203
marginHorizontal : 30 ,
@@ -187,12 +214,6 @@ const styles = StyleSheet.create({
187
214
fontSize : 15 ,
188
215
color : '#161F3D' ,
189
216
} ,
190
- error : {
191
- color : primaryColor ,
192
- fontSize : 13 ,
193
- fontWeight : '600' ,
194
- textAlign : 'center' ,
195
- } ,
196
217
button : {
197
218
marginHorizontal : 30 ,
198
219
backgroundColor : primaryColor ,
@@ -210,4 +231,19 @@ const styles = StyleSheet.create({
210
231
fontSize : 13 ,
211
232
fontWeight : '500' ,
212
233
} ,
234
+ avatarPlaceholder : {
235
+ width : 100 ,
236
+ height : 100 ,
237
+ backgroundColor : '#E1E2E6' ,
238
+ borderRadius : 50 ,
239
+ marginTop : 48 ,
240
+ justifyContent : 'center' ,
241
+ alignItems : 'center' ,
242
+ } ,
243
+ avatar : {
244
+ position : 'absolute' ,
245
+ width : 100 ,
246
+ height : 100 ,
247
+ borderRadius : 50 ,
248
+ } ,
213
249
} ) ;
0 commit comments