-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
164 lines (158 loc) · 5.43 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import 'react-native-gesture-handler';
import React from 'react';
import { StatusBar } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { GoogleSignin } from '@react-native-google-signin/google-signin';
import Spinner from 'react-native-loading-spinner-overlay';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { Context } from './src/utils/context';
import { DrawerContent } from './src/components/DrawerContent';
import RootStackScreen from './src/screens/RootStackScreen';
import ProfileScreen from './src/screens/ProfileScreen';
import StudyScheduleScreen from './src/screens/StudyScheduleScreen';
import TranscriptScreen from './src/screens/TranscriptScreen';
import ExamScheduleScreen from './src/screens/ExamScheduleScreen';
import ReLoginAlert from './src/components/ReLoginAlert';
import TuitionScreen from './src/screens/TuitionScreen';
import { USER_ROLE } from './src/common/constant';
import BottomTabNavigator from './src/components/BottomTab';
import { MenuProvider } from 'react-native-popup-menu';
import SettingScreen from './src/screens/SettingScreen';
const Drawer = createDrawerNavigator();
function App() {
const [context, setContext] = React.useState({
token: '',
role: '',
userId: '',
username: '',
email: '',
avatar: '',
isLoading: false,
expire: false,
timer: null,
});
const logout = async () => {
const currentUser = await GoogleSignin.getCurrentUser();
if (currentUser) {
await GoogleSignin.signOut();
}
};
React.useEffect(() => {
logout();
}, []);
return (
<Context.Provider value={[context, setContext]}>
<MenuProvider>
<StatusBar backgroundColor="#2596be" />
<Spinner visible={context.isLoading} />
{context.expire && <ReLoginAlert />}
<NavigationContainer>
{context.token ? (
<Drawer.Navigator
drawerContent={(props) => <DrawerContent {...props} />}
screenOptions={{ drawerStyle: { width: 312 } }}
>
<Drawer.Screen name="HomeBottomTab" component={BottomTabNavigator} options={{ headerShown: false }} />
<Drawer.Screen
name="StudySchedule"
component={StudyScheduleScreen}
options={{
title: 'Thời khóa biểu',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
<Drawer.Screen
name="Transcript"
component={TranscriptScreen}
options={{
title: 'Điểm',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
<Drawer.Screen
name="ExamSchedule"
component={ExamScheduleScreen}
options={{
title: 'Lịch thi',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
{context.role === USER_ROLE.student && (
<Drawer.Screen
name="Tuition"
component={TuitionScreen}
options={{
title: 'Học phí',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
)}
<Drawer.Screen
name="Profile"
component={ProfileScreen}
options={{
title: 'Hồ sơ',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
<Drawer.Screen
name="Setting"
component={SettingScreen}
options={{
title: 'Cài đặt',
headerStyle: {
backgroundColor: '#2596be',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerTitleAlign: 'center',
}}
/>
</Drawer.Navigator>
) : (
<RootStackScreen />
)}
</NavigationContainer>
</MenuProvider>
</Context.Provider>
);
}
export default App;