-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
83 lines (77 loc) · 1.83 KB
/
Copy pathApp.js
File metadata and controls
83 lines (77 loc) · 1.83 KB
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
import React, {useState} from 'react';
import {
StyleSheet,
View,
Text,
TextInput,
TouchableOpacity,
} from 'react-native';
import firebase from 'react-native-firebase';
const App = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [isAuthenticated, setIsAuthenticated] = useState(false);
const login = async () => {
try {
const user = await firebase
.auth()
.signInWithEmailAndPassword(email, password);
setIsAuthenticated({isAuthenticated: true});
console.log(user);
} catch (e) {
console.log(e);
}
};
return (
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Digite seu e-mail"
value={email}
onChangeText={email => setEmail(email)}
/>
<TextInput
style={styles.input}
placeholder="Digite sua senha"
value={password}
onChangeText={password => setPassword(password)}
/>
<TouchableOpacity style={styles.button} onPress={login}>
<Text style={styles.buttonText}>Logar</Text>
</TouchableOpacity>
<Text> {`Status do Login: ${isAuthenticated}`}</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#333',
padding: 20,
},
input: {
height: 45,
backgroundColor: '#FFF',
alignSelf: 'stretch',
borderColor: '#DDD',
borderWidth: 1,
paddingHorizontal: 20,
marginBottom: 10,
},
button: {
height: 45,
backgroundColor: '#069',
alignSelf: 'stretch',
borderColor: '#EEE',
paddingHorizontal: 20,
justifyContent: 'center',
alignItems: 'center',
},
buttonText: {
color: '#FFF',
fontWeight: 'bold',
},
});
export default App;