forked from Darren80/fog-o-war
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
124 lines (115 loc) · 3.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
import "react-native-gesture-handler";
import React, { useState } from "react";
import { StyleSheet, Text, View, LogBox } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { Provider as PaperProvider, MD3LightTheme } from "react-native-paper";
import { getHome } from "./APIs";
export const UserContext = React.createContext();
export const LoggedInContext = React.createContext(false);
const Stack = createStackNavigator();
import signIn from "./signIn.js";
import home from "./home.js";
import profile from "./profile.js";
import scoreboard from "./scoreboard";
import userRegistration from "./userRegistration.js";
const theme = {
...MD3LightTheme, // or MD3DarkTheme
roundness: 2,
colors: {
...MD3LightTheme.colors,
primary: "#3498db",
secondary: "#f1c40f",
tertiary: "#a1b2c3",
},
};
const App = () => {
const [user, setUser] = React.useState({ user_id: 0 });
const [loggedIn, setLoggedIn] = React.useState();
LogBox.ignoreAllLogs();
React.useEffect(() => {
console.log("checking log in");
getHome().then((response) => {
if (response.loggedIn === true) {
console.log("app logged in");
setUser(response);
setLoggedIn(true);
} else if (response.loggedIn === false) {
setLoggedIn(false);
}
});
}, [loggedIn]);
return (
<UserContext.Provider value={{ user, setUser }}>
<LoggedInContext.Provider value={{ loggedIn, setLoggedIn }}>
<PaperProvider theme={theme}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={home}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Sign In"
component={signIn}
options={{
headerLeft: null,
headerShown: false,
}}
/>
<Stack.Screen
name="userRegistration"
component={userRegistration}
/>
<Stack.Screen name="Profile" component={profile} />
<Stack.Screen name="Scoreboard" component={scoreboard} />
</Stack.Navigator>
</NavigationContainer>
</PaperProvider>
</LoggedInContext.Provider>
</UserContext.Provider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
map: {
width: "90%",
height: "90%",
},
button: {
alignItems: "center",
justifyContent: "center",
paddingVertical: 12,
paddingHorizontal: 32,
borderRadius: 4,
elevation: 3,
backgroundColor: "black",
},
navButton: {
position: "absolute",
alignItems: "center",
justifyContent: "center",
top: "20%",
left: "75%",
alignSelf: "flex-end",
paddingHorizontal: 0,
},
text: {
fontSize: 16,
lineHeight: 21,
fontWeight: "bold",
letterSpacing: 0.25,
color: "white",
width: "88%",
height: "88%",
},
});
export default App;