-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.js
executable file
·49 lines (42 loc) · 1.13 KB
/
App.js
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
import React, {Component} from 'react';
import {StyleSheet, SafeAreaView, ScrollView, RefreshControl, Modal, Button} from 'react-native';
import Main from './app/views/Main';
import Login from './app/views/Login';
import firebase from 'react-native-firebase';
export default class App extends Component {
state = {
isLogged: false,
user: null
}
onUpdateUser = async () => {
const auth = firebase.auth();
await auth.currentUser.reload();
this.setState({user: auth.currentUser});
}
onLogin = async (user) => {
this.setState({user, isLogged: true});
}
onLogout = async () => {
this.setState({user: null, isLogged: false});
}
render() {
const {state} = this;
return (
<SafeAreaView style={styles.container}>
{
state.isLogged ?
<Main user={state.user} onLogout={this.onLogout} onUpdateUser={this.onUpdateUser} />:
<Login onLogin={this.onLogin} />
}
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});