-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
158 lines (151 loc) · 5.52 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
import * as React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createDrawerNavigator } from "@react-navigation/drawer";
import { Image, StyleSheet, Text, View, TouchableOpacity } from "react-native";
import SignIn from "./components/SignIn";
import SignUp from "./components/SignUp";
import Home from "./components/Home";
import Profile from "./components/Profile";
import Leaderboard from "./components/Leaderboard";
import Settings from "./components/Settings";
import CustomDrawer from "./components/CustomDrawer";
import { LessonThenQuiz } from "./components/Lesson-then-quiz";
import {FinishedLesson} from "./components/Finished-lesson";
import { Answer } from "./components/Answer-options";
import { UserContext, LoadingContext } from "./utils/userContext";
import { allAvatars } from "./assets/avatars/avatars-export";
const Stack = createNativeStackNavigator();
const Drawer = createDrawerNavigator();
function DrawerNavigator({ navigation: { navigate } }) {
const [avatarIndex, setAvatarIndex] = React.useState(null);
React.useEffect(() => {}, [avatarIndex]);
const profileImgLink = (
<TouchableOpacity onPress={() => navigate("Profile")}>
<Image
source={{
uri: avatarIndex
? `${allAvatars[avatarIndex]}`
: "https://api.multiavatar.com/helloworld.png",
}}
style={styles.image}
/>
</TouchableOpacity>
);
return (
<Drawer.Navigator
initialRouteName="Home"
drawerContent={(props) => (
<CustomDrawer {...props} avatarIndex={avatarIndex} />
)}
screenOptions={{
drawerActiveBackgroundColor: "#004346",
drawerActiveTintColor: "white",
drawerLabelStyle: {
// fontFamily: "Roboto-Medium",
fontSize: 20,
},
}}
>
<Drawer.Screen
name="Home"
options={{
headerRight: () => profileImgLink,
}}
>
{(props) => <Home {...props} setAvatarIndex={setAvatarIndex} />}
</Drawer.Screen>
<Drawer.Screen
name="Profile"
options={{
headerRight: () => profileImgLink,
}}
>
{(props) => <Profile {...props} setAvatarIndex={setAvatarIndex} />}
</Drawer.Screen>
<Drawer.Screen
name="Leaderboard"
component={Leaderboard}
options={{
headerRight: () => profileImgLink,
}}
/>
<Drawer.Screen
name="Settings"
component={Settings}
options={{
headerRight: () => profileImgLink,
}}
/>
<Drawer.Screen
name="FinishedLesson"
component={FinishedLesson}
options={{
headerRight: () => profileImgLink,
drawerLabel: () => null,
title: null,
drawerIcon: () => null,
}}
/>
</Drawer.Navigator>
);
}
export default function App() {
const [username, setUsername] = React.useState("John Smith");
const [isLoading, setIsLoading] = React.useState(false);
return (
<UserContext.Provider value={{ username, setUsername }}>
<LoadingContext.Provider value={{ isLoading, setIsLoading }}>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
cardStyle: { backgroundColor: "#78ba97" },
}}
>
<Stack.Screen
name="SignIn"
component={SignIn}
options={{
title: "Sign In ",
headerStyle: { backgroundColor: "#3d9891" },
headerTitleStyle: {
color: "#fff",
},
}}
/>
<Stack.Screen
name="SignUp"
component={SignUp}
options={{
title: "Sign Up",
headerStyle: { backgroundColor: "#3d9891" },
headerTitleStyle: {
color: "#fff",
},
}}
/>
<Stack.Screen
name="HomePage"
component={DrawerNavigator}
options={{
headerShown: false,
backgroundColor: "#78ba97",
}}
/>
<Stack.Screen
name="Lesson"
component={LessonThenQuiz}
options={{
headerShown: false,
backgroundColor: "#78ba97",
}}
/>
</Stack.Navigator>
</NavigationContainer>
</LoadingContext.Provider>
</UserContext.Provider>
);
}
const styles = StyleSheet.create({
image: { width: 50, height: 50, marginRight: 10 },
});