-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.txt
211 lines (171 loc) · 6.27 KB
/
test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
items={[
{ label: 'Image 1', value: 'image_1' },
{ label: 'Image 2', value: 'image_2' },
{ label: 'Image 3', value: 'image_3' },
{ label: 'Image 4', value: 'image_4' },
{ label: 'Image 5', value: 'image_5' },
{ label: 'Image 6', value: 'image_6' },
{ label: 'Image 7', value: 'image_7' },
{ label: 'Image 8', value: 'image_8' },
{ label: 'Image 9', value: 'image_9' },
{ label: 'Image 10', value: 'image_10' },
{ label: 'Image 11', value: 'image_11' },
{ label: 'Image 12', value: 'image_12' },
{ label: 'Image 13', value: 'image_13' },
{ label: 'Image 14', value: 'image_14' },
{ label: 'Image 15', value: 'image_15' },
{ label: 'Image 16', value: 'image_16' },
{ label: 'Image 17', value: 'image_17' },
{ label: 'Image 18', value: 'image_18' },
{ label: 'Image 19', value: 'image_19' },
{ label: 'Image 20', value: 'image_20' },
{ label: 'Image 21', value: 'image_21' },
{ label: 'Image 22', value: 'image_22' },
{ label: 'Image 23', value: 'image_23' },
{ label: 'Image 24', value: 'image_24' },
{ label: 'Image 25', value: 'image_25' },
]}
AAA262 (green) AFA760
898B8C (blue) 8F9887
bottomTabStyle: {
backgroundColor: '#2f345d',
borderTopLeftRadius: RFValue(40),
borderTopRightRadius: RFValue(40),
overflow: 'hidden',
position: 'absolute',
marginTop:20,
borderWidth:2,
borderColor:"biege"
},
<Bottom.Screen name={'Home'} component={Home} />
<Bottom.Screen name={'Something'} component={Something} />
defaultValue={this.state.previewImage}
containerStyle={{
height: 40,
width: 120,
borderRadius: RFValue(20),
marginBottom: RFValue(20),
marginHorizontal: RFValue(10),
}}
onChangeItem={(item) =>
this.setState({
previewImage: item.value,
})
}
onOpen={() => {
this.setState({ dropdownHeight: 170, width: 120 });
}}
onClose={() => {
this.setState({ dropdownHeight: 40 });
}}
arrowStyle={
this.state.light_theme
? styles.dropdownLabelLight
: styles.dropdownLabel
}
import React, { Component } from "react";
import { StyleSheet, View, Button } from "react-native";
import * as Google from "expo-google-app-auth";
import firebase from "firebase";
export default class LoginScreen extends Component {
isUserEqual = (googleUser, firebaseUser) => {
if (firebaseUser) {
var providerData = firebaseUser.providerData;
for (var i = 0; i < providerData.length; i++) {
if (
providerData[i].providerId ===
firebase.auth.GoogleAuthProvider.PROVIDER_ID &&
providerData[i].uid === googleUser.getBasicProfile().getId()
) {
// We don't need to reauth the Firebase connection.
return true;
}
}
}
return false;
};
onSignIn = googleUser => {
// We need to register an Observer on Firebase Auth to make sure auth is initialized.
var unsubscribe = firebase.auth().onAuthStateChanged(firebaseUser => {
unsubscribe();
// Check if we are already signed-in Firebase with the correct user.
if (!this.isUserEqual(googleUser, firebaseUser)) {
// Build Firebase credential with the Google ID token.
var credential = firebase.auth.GoogleAuthProvider.credential(
googleUser.idToken,
googleUser.accessToken
);
// Sign in with credential from the Google user.
firebase
.auth()
.signInWithCredential(credential)
.then(function(result) {
if (result.additionalUserInfo.isNewUser) {
firebase
.database()
.ref("/users/" + result.user.uid)
.set({
gmail: result.user.email,
profile_picture: result.additionalUserInfo.profile.picture,
locale: result.additionalUserInfo.profile.locale,
first_name: result.additionalUserInfo.profile.given_name,
last_name: result.additionalUserInfo.profile.family_name,
current_theme: "dark"
})
.then(function(snapshot) {});
}
})
.catch(error => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
} else {
console.log("User already signed-in Firebase.");
}
});
};
signInWithGoogleAsync = async () => {
try {
const result = await Google.logInAsync({
behaviour: "web",
androidClientId:
"",
iosClientId:
"",
scopes: ["profile", "email"]
});
if (result.type === "success") {
this.onSignIn(result);
return result.accessToken;
} else {
return { cancelled: true };
}
} catch (e) {
console.log(e.message);
return { error: true };
}
};
render() {
return (
<View style={styles.container}>
<Button
title="Sign in with Google"
onPress={() => this.signInWithGoogleAsync()}
></Button>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
});