forked from chillibeaver/CatchUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
102 lines (94 loc) · 2.82 KB
/
App.js
File metadata and controls
102 lines (94 loc) · 2.82 KB
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
import "react-native-gesture-handler";
// import LocationPermissionManager from "./Components/LocationPermissionManager";
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { View, ActivityIndicator } from "react-native";
import LoginScreen from "./Screens/LoginScreen";
import ProfileSetup from "./Screens/ProfileSetup";
import { UserProvider, useUser } from "./Context/UserContext";
import BottomTabNavigator from "./Navigation/BottomTabNavigator";
import { StatusBar } from "expo-status-bar";
import NotificationScheduler from "./Screens/NotificationScheduler";
import * as Notifications from "expo-notifications";
import * as Device from "expo-device";
const Stack = createStackNavigator();
// Configure notification handler
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
// Navigation content based on user authentication state
const NavigationContent = () => {
const { user, loading } = useUser();
if (loading) {
return (
<View className="flex-1 justify-center items-center bg-black">
<ActivityIndicator size="large" color="#fff" />
</View>
);
}
// Initial route based on user authentication state
const initialRoute = user
? user.username
? "Tabs"
: "ProfileSetup"
: "LoginScreen";
return (
<Stack.Navigator initialRouteName={initialRoute}>
{!user ? (
// unauthenticated route
<Stack.Screen
name="LoginScreen"
component={LoginScreen}
options={{ headerShown: false }}
/>
) : !user.username ? (
// incomplete user information route
<Stack.Screen
name="ProfileSetup"
component={ProfileSetup}
options={{
headerShown: false,
}}
/>
) : (
// logged in route
<>
<Stack.Screen
name="Tabs"
component={BottomTabNavigator}
options={{ headerShown: false }}
/>
<Stack.Screen
name="NotificationScheduler"
component={NotificationScheduler}
options={{
headerTitle: "Set Reminder",
headerStyle: {
backgroundColor: "black",
},
headerTintColor: "white",
}}
/>
</>
)}
</Stack.Navigator>
);
};
const App = () => {
return (
<UserProvider>
{/* this is not avalible yet need some debugging */}
{/* <LocationPermissionManager /> */}
<NavigationContainer>
<StatusBar style="light" />
<NavigationContent />
</NavigationContainer>
</UserProvider>
);
};
export default App;