-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
365 lines (350 loc) · 15.6 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import { useEffect, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import AsyncStorage from '@react-native-async-storage/async-storage'; //global storage in react, data will stay even when the app is closed
import { Ionicons } from "@expo/vector-icons";
import 'react-native-reanimated';
import { CreateAccPage, LoginPage } from './src/account.js';
import { CoverPage } from './src/cover.js';
import { AddJournalEntryPage, JournalHomePage, ViewJournalEntry } from './src/journal.js';
import { HomePage } from './src/homepage.js';
import { ProgressTracker } from "./src/progress.js";
import { UserInfoProvider} from './src/userInfo.js';
import { AccountSettingsPage, SettingsPage, AccountChangePassword } from './src/settings.js';
import { StorePage} from './src/store.js';
import { MoobieProvider } from './src/moobie.js';
import { UserCurrencyProvider } from './src/currency.js';
import { ClosetPage } from './src/closet.js';
import { DailyLoginsProvider } from './src/progress_files/dailyLoginsContext.js';
import { ConsecutiveLoginsProvider } from './src/progress_files/consecutiveLoginsContext.js';
import { LongestStreakProvider } from './src/progress_files/longestStreakContext.js';
import { SundayLoginProvider, MondayLoginProvider, TuesdayLoginProvider,
WednesdayLoginProvider, ThursdayLoginProvider,
FridayLoginProvider, SaturdayLoginProvider } from './src/progress_files/weeklyLoginContext.js';
import { ChatPage } from './src/chat.js';
import { IconButton } from './src/homepage.js';
import { TaskContextProvider } from './src/task.js';
import { ShowDailyNotificationProvider } from './src/progress_files/showDailyNotificationContext.js';
import { ShowJournalNotificationProvider } from './src/progress_files/showJournalNotificationContext.js';
import { ShowWeeklyNotificationProvider } from './src/progress_files/showWeeklyNotificationContext.js';
const Stack = createNativeStackNavigator();
export default function App() {
//initial value is false
const [isLogged, setLogged] = useState(false);
const getUserStatus = async () =>{
try{
const status = await AsyncStorage.getItem("UserIsLoggedIn");
console.log("status " + status);
setLogged(status);
}catch(error){
console.log("error " + error);
}
}
//everytime the app opens and renders we check is the user is logged in
useEffect(()=>{
getUserStatus();
})
return (
<UserInfoProvider>
<TaskContextProvider>
<ShowDailyNotificationProvider>
<ShowJournalNotificationProvider>
<ShowWeeklyNotificationProvider>
<DailyLoginsProvider>
<ConsecutiveLoginsProvider>
<LongestStreakProvider>
<SundayLoginProvider>
<MondayLoginProvider>
<TuesdayLoginProvider>
<WednesdayLoginProvider>
<ThursdayLoginProvider>
<FridayLoginProvider>
<SaturdayLoginProvider>
<UserCurrencyProvider>
<MoobieProvider>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name = "Cover Page"
options = {{
headerShown: false,
animation: 'fade'
}}>
{/* don't need component since we are passing down a child prop instead */}
{props => <CoverPage {...props} isLogged={isLogged} />}
</Stack.Screen>
<Stack.Screen
name = "Login Page"
component = {LoginPage}
//animation removes the screen to slide from left to right
//gesture disables the user to allow from moving to the previous screen on swipe
options = {{
headerBackVisible: false,
animation: 'none',
gestureEnabled: false,
headerShown: false
}}>
</Stack.Screen>
<Stack.Screen
name = "Create Account Page"
component = {CreateAccPage}
options = {{
headerBackVisible: false,
animation: 'none',
gestureEnabled: false,
headerShown: false
}}>
</Stack.Screen>
<Stack.Screen
name = "Home Page"
component = {HomePage}
options = {{
headerBackVisible: false,
animation: 'none',
gestureEnabled: false,
headerShown: false
}}>
</Stack.Screen>
<Stack.Screen
name="Chat Page"
component={ChatPage}
options={({navigation}) => ({
animation: 'fade',
gestureEnabled: false,
headerTitle: "Chat with Moobie",
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerShadowVisible: false,
headerTintColor: "black",
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}
/>
<Stack.Screen name = "Settings Page"
component = {SettingsPage}
options={({navigation}) => ({
gestureEnabled: false,
headerTitle: " ",
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerShadowVisible: false,
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Account Settings Page"
component = {AccountSettingsPage}
options={({navigation}) => ({
gestureEnabled: false,
headerTitle: " ",
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerShadowVisible: false,
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Settings Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Change Password Page"
component = {AccountChangePassword}
options={({navigation}) => ({
gestureEnabled: false,
headerTitle: " ",
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerShadowVisible: false,
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Account Settings Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Journal Home Page"
component = {JournalHomePage}
options={({navigation}) =>({
animation: 'slide_from_bottom',
gestureEnabled: false,
headerTitle: "",
headerShadowVisible: false,
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Journal New Entry Page"
component = {AddJournalEntryPage}
options={({navigation}) =>({
gestureEnabled: false,
headerTitle: "",
headerShadowVisible: false,
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Journal Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Journal Entry Page"
component = {ViewJournalEntry}
options={({navigation}) =>({
animation: 'fade',
gestureEnabled: false,
headerTitle: "",
headerShadowVisible: false,
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Journal Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Progress Tracking"
component = {ProgressTracker}
options={({navigation}) =>({
animation: 'slide_from_bottom',
gestureEnabled: false,
headerTitle: "",
headerShadowVisible: false,
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Store Page"
component = {StorePage}
options={({navigation}) =>({
animation: 'slide_from_bottom',
gestureEnabled: false,
headerTitle: "Moobie's Shop",
headerShadowVisible: false,
headerTitleStyle:{
fontSize: 25,
},
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
<Stack.Screen
name = "Closet Page"
component = {ClosetPage}
options={({navigation}) =>({
animation: 'slide_from_bottom',
gestureEnabled: false,
headerTitle: " ",
headerShadowVisible: false,
headerTitleStyle:{
fontSize: 25,
},
headerStyle: {
backgroundColor: "#B6D3B3",
},
headerLeft: () => (
<IconButton
onPress={() => navigation.navigate("Home Page")}
iconName="arrow-back"
iconComponent={Ionicons}
size={30}
color="black"
/>
),
})}>
</Stack.Screen>
</Stack.Navigator>
</NavigationContainer>
</MoobieProvider>
</UserCurrencyProvider>
</SaturdayLoginProvider>
</FridayLoginProvider>
</ThursdayLoginProvider>
</WednesdayLoginProvider>
</TuesdayLoginProvider>
</MondayLoginProvider>
</SundayLoginProvider>
</LongestStreakProvider>
</ConsecutiveLoginsProvider>
</DailyLoginsProvider>
</ShowWeeklyNotificationProvider>
</ShowJournalNotificationProvider>
</ShowDailyNotificationProvider>
</TaskContextProvider>
</UserInfoProvider>
);
}