-
Notifications
You must be signed in to change notification settings - Fork 14
/
App.js
73 lines (64 loc) · 2.51 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React, { useState, useEffect } from "react";
import 'react-native-gesture-handler';
import { AsyncStorage } from 'react-native'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { useFonts } from 'expo-font';
//State
import { GlobalProvider } from './context/GlobalState'
//Screens
import Login from './screens/Login';
import SignUp from './screens/SignUp';
import MainApp from './screens/MainApp';
import Splash from './screens/Splash';
import Guest from './screens/Guest';
import Onboarding from "./screens/Onboarding";
import ForgotPassword from "./screens/ForgotPassword";
import { StatusBar } from "expo-status-bar";
const Stack = createStackNavigator();
const App = () => {
const [isReady, setIsReady] = useState(false);
const [initialScreen, setInititalScreen] = useState("Onboarding");
const [loaded] = useFonts({
'ProductSans': require('./assets/fonts/Product_Sans_Regular.ttf'),
'ProductSansItalic': require('./assets/fonts/Product_Sans_Italic.ttf'),
'ProductSansBold': require('./assets/fonts/Product_Sans_Bold.ttf'),
'ProductSansBoldItalic': require('./assets/fonts/Product_Sans_Bold_Italic.ttf'),
'DMSansBold': require('./assets/fonts/DMSans-Bold.ttf'),
'DMSansRegular': require('./assets/fonts/DMSans-Regular.ttf'),
'PTSans': require('./assets/fonts/Product_Sans_Regular.ttf'),
'PTSansBold': require('./assets/fonts/Product_Sans_Bold.ttf')
});
console.disableYellowBox = true;
useEffect(() => {
const checkToken = async () => {
const user = await AsyncStorage.getItem('user');
console.log(user)
if (user) {
setInititalScreen("MainApp");
}
setIsReady(true);
}
checkToken()
}, []);
if (!isReady || !loaded) {
return null;
}
return (
<GlobalProvider>
<NavigationContainer>
<StatusBar backgroundColor="white" />
<Stack.Navigator headerMode="none" initialRouteName={initialScreen}>
<Stack.Screen name="SignUp" component={SignUp} />
<Stack.Screen name="Onboarding" component={Onboarding} />
<Stack.Screen name="Splash" component={Splash} />
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="MainApp" component={MainApp} />
<Stack.Screen name="Guest" component={Guest} />
<Stack.Screen name="ForgotPassword" component={ForgotPassword} />
</Stack.Navigator>
</NavigationContainer>
</GlobalProvider>
)
}
export default App;