-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
62 lines (50 loc) · 1.58 KB
/
App.js
File metadata and controls
62 lines (50 loc) · 1.58 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
import React, {useState, useEffect} from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { firebase } from './config';
import Login from './src/telas/Login';
import Cadastro from './src/telas/Cadastro';
import Apresentacao from './src/telas/Apresentacao';
import { AppRoutes } from './src/rotas/app.routes';
const Stack = createNativeStackNavigator();
function App (){
const [initializing, setInitializing] = useState(true);
const [user, setUser] = useState();
function onAuthStateChanged(user){
setUser(user);
if(initializing) setInitializing(false);
}
useEffect(() => {
const subscriber = firebase.auth().onAuthStateChanged(onAuthStateChanged);
return subscriber;
}, []);
if (initializing) return null;
if(!user){
return(
<Stack.Navigator>
<Stack.Screen options={{headerTransparent: true,
headerTitle: '',
headerLeft: null,
headerShown: false,}} name='Apresentacao' component={Apresentacao} />
<Stack.Screen options={{headerTransparent: true,
headerTitle: '',
headerLeft: null,
headerShown: false,}} name='Login' component={Login} />
<Stack.Screen options={{headerTransparent: true,
headerTitle: '',
headerLeft: null,
headerShown: false,}} name='Cadastro' component={Cadastro} />
</Stack.Navigator>
);
}
return(
<AppRoutes />
);
}
export default () => {
return(
<NavigationContainer>
<App/>
</NavigationContainer>
)
}