forked from UnivTexasArlington-Library/library_mobile_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
213 lines (204 loc) · 7.19 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import {
createDrawerNavigator,
DrawerToggleButton,
} from "@react-navigation/drawer";
import {NavigationContainer} from "@react-navigation/native";
import {createNativeStackNavigator} from "@react-navigation/native-stack";
import {decode, encode} from "base-64";
import {useFonts} from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import {StatusBar} from "expo-status-bar";
import {useCallback, useEffect} from "react";
import {SafeAreaView, StyleSheet} from "react-native";
import "react-native-gesture-handler";
import * as Sentry from "sentry-expo";
import BackButton from "./src/components/BackButton";
import {GlobalStyles} from "./src/constants/styles";
import ArticleScreen from "./src/screens/ArticleScreen";
import BlogAndLatestEvents from "./src/screens/BlogAndLatestEvents";
import BookingScreen from "./src/screens/BookingScreen";
import Home from "./src/screens/HomeScreen";
import HoursScreen from "./src/screens/HoursScreen";
import MapScreen from "./src/screens/MapScreen";
import ReserveScreen from "./src/screens/ReserveScreen";
import BlogContextProvider from "./src/store/context/blog-context";
import InstagramContextProvider from "./src/store/context/instagram-context";
import LatestEventsContextProvider from "./src/store/context/latestEvents-context";
import LibCalContextProvider from "./src/store/context/libCal-context";
import ReserveHoursContextProvider from "./src/store/context/reserveHours-context";
import {configureFcmNotifications} from "./src/util/fcmTasks";
//The two following if statements removes the errors
//Can't find variable: btoa && Can't find variable: atob
//Sets the btoa variable to base64 format
if (!global.btoa) {
global.btoa = encode;
}
//Sets the atob variable to base64 format
if (!global.atob) {
global.atob = decode;
}
// Keep the splash screen visible while we fetch resources, This prevents SplashScreen from auto hiding while the fonts are loaded.
SplashScreen.preventAutoHideAsync().catch((err) => console.log(err));
//Initializes Sentry: Application Performance Monitoring and Error Tracking
Sentry.init({
dsn: "https://318ff9e98066266d1a30afbffb05b767@o4505909001191424.ingest.sentry.io/4505909010038784",
enableInExpoDevelopment: true,
debug: true, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
});
const Stack = createNativeStackNavigator();
const Drawer = createDrawerNavigator();
function DrawerNavigation({navigation}) {
// Pre-load fonts at runtime
const [fontsLoaded] = useFonts({
"open-sans": require("./assets/fonts/OpenSans-Regular.ttf"),
"open-sans-bold": require("./assets/fonts/OpenSans-Bold.ttf"),
});
//After the custom fonts have loaded, we can hide the splash screen and display the app screen.
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded]);
if (!fontsLoaded) {
return null;
}
return (
<SafeAreaView style={styles.rootScreen} onLayout={onLayoutRootView}>
<Drawer.Navigator
screenOptions={{
headerLeft: () => <BackButton navigation={navigation} />,
drawerPosition: "right",
headerRight: () => <DrawerToggleButton tintColor="white" />,
headerTitleAlign: "center",
drawerActiveTintColor: "white",
drawerInactiveTintColor: "black",
drawerActiveBackgroundColor: GlobalStyles.colors.primary800,
}}
>
<Drawer.Screen
name="Home"
component={Home}
options={{
headerShown: false,
}}
/>
<Drawer.Screen
name="BlogAndLatestEvents"
component={BlogAndLatestEvents}
options={{
title: "News and Events",
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
}}
/>
<Drawer.Screen
name="Hours"
component={HoursScreen}
options={{
title: "Library Hours",
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
}}
/>
<Drawer.Screen
name="Locations"
component={MapScreen}
options={{
title: "Department Locations",
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
}}
/>
<Drawer.Screen
name="Reserve"
component={ReserveScreen}
options={{
title: "Reserve Room",
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
}}
/>
<Drawer.Screen
name="Booking"
component={BookingScreen}
options={{
title: "Booking Details",
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
drawerItemStyle: {
display: "none",
},
}}
/>
</Drawer.Navigator>
</SafeAreaView>
);
}
export default function App() {
//Initialize push notifications sent through the Firebase Cloud Messaging Platform
useEffect(() => {
configureFcmNotifications();
}, []);
return (
<>
<StatusBar style="light" />
<ReserveHoursContextProvider>
<InstagramContextProvider>
<LibCalContextProvider>
<LatestEventsContextProvider>
<BlogContextProvider>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
headerTintColor: "white",
tabBarStyle: {
backgroundColor: GlobalStyles.colors.primary800,
},
tabBarActiveTintColor: GlobalStyles.colors.primary800,
}}
>
<Stack.Screen
name="Drawer"
component={DrawerNavigation}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Article"
component={ArticleScreen}
options={({navigation}) => ({
headerLeft: () => (
<BackButton navigation={navigation} />
),
headerTitleAlign: "center",
})}
/>
</Stack.Navigator>
</NavigationContainer>
</BlogContextProvider>
</LatestEventsContextProvider>
</LibCalContextProvider>
</InstagramContextProvider>
</ReserveHoursContextProvider>
</>
);
}
const styles = StyleSheet.create({
rootScreen: {
flex: 1,
},
});