-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
110 lines (107 loc) · 3.23 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
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
import React, { useEffect, useState } from 'react';
import Title from './src/UI/Title';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './src/Pages/Home';
import AccountAccess from './src/Pages/AccountAccess';
import EmailVerification from './src/Pages/EmailVerification';
import AuthedHome from './src/Pages/AuthedHome';
import SignupSuccess from './src/Pages/SignupSuccess';
import AsyncStorageLib from '@react-native-async-storage/async-storage';
import { View, ActivityIndicator } from 'react-native';
import { AuthProvider } from './src/context/AuthProvider';
import { StyleSheet } from 'react-native';
import ForgotPasswordPage from './src/Pages/ForgotPasswordPage';
import Profile from './src/Pages/Profile';
import { StatusBar } from 'expo-status-bar';
import Slides from './src/Pages/Slides';
const App = () => {
const [token, setToken] = useState();
const [loading, setLoading] = useState(true);
useEffect(async () => {
setToken(await AsyncStorageLib.getItem('user'));
setTimeout(() => {
setLoading(false);
}, 1000);
}, []);
const Stack = createNativeStackNavigator();
let toRender;
if (loading)
toRender = (
<View style={styles.center}>
<ActivityIndicator color='#4DAAAA' size='large' />
</View>
);
else
toRender = (
<NavigationContainer>
<Stack.Navigator
initialRouteName='Slides'
screenOptions={{
headerTransparent: true,
animation: 'fade_from_bottom',
}}
>
<Stack.Screen
name='Slides'
component={Slides}
options={{ headerShown: false }}
/>
<Stack.Screen
name='Home'
component={Home}
options={{
headerTitle: props => <Title {...props} />,
headerLeft: null,
}}
/>
<Stack.Screen
name='Login1'
component={AccountAccess}
options={{
headerTitle: props => <Title {...props} />,
}}
/>
<Stack.Screen
name='EmailVerification'
component={EmailVerification}
options={{ headerTitle: props => <Title {...props} /> }}
/>
<Stack.Screen
name='ForgotPassword'
component={ForgotPasswordPage}
options={{ headerTitle: props => <Title {...props} /> }}
/>
<Stack.Screen
name='Success'
component={SignupSuccess}
options={{ headerTitle: props => <Title {...props} /> }}
/>
<Stack.Screen
name='LoggedHome'
component={AuthedHome}
options={{ headerShown: false }}
/>
<Stack.Screen
name='Profile'
component={Profile}
options={{ headerShown: false }}
/>
</Stack.Navigator>
</NavigationContainer>
);
return (
<AuthProvider>
{toRender}
<StatusBar />
</AuthProvider>
);
};
const styles = StyleSheet.create({
center: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default App;