-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
75 lines (69 loc) · 2.27 KB
/
App.js
File metadata and controls
75 lines (69 loc) · 2.27 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
import React, { useEffect, useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { StripeProvider } from "@stripe/stripe-react-native";
import { BottomSheetProvider } from "./hooks/BottomSheetContext";
import { SettingsProvider, useSettings } from "./hooks/SettingsContext";
import { ThemesProvider } from "./hooks/ThemesContext";
import { STRIPE_PUBLISHABLE_KEY } from "@env";
import MainStack from "./components/MainStack";
import Splash from "./components/Splash";
import TodoBottomSheet from "./components/todaytmrw/TodoBottomSheet";
import { MenuProvider } from "react-native-popup-menu";
import Auth from "./screens/Auth";
import { createStackNavigator } from "@react-navigation/stack";
import { SafeAreaView } from "react-native";
const Stack = createStackNavigator();
export default function App() {
return (
<SettingsProvider>
<ThemesProvider>
<StripeProvider publishableKey={STRIPE_PUBLISHABLE_KEY}>
<MenuProvider>
<AppContent />
</MenuProvider>
</StripeProvider>
</ThemesProvider>
</SettingsProvider>
);
}
function AppContent() {
const { isAuthenticated, todayPageLoaded, finishSignup } = useSettings();
const [showSplash, setShowSplash] = useState(true);
useEffect(() => {
if (
isAuthenticated === false ||
(isAuthenticated === true && todayPageLoaded === true) ||
finishSignup
) {
setShowSplash(false);
}
}, [isAuthenticated, todayPageLoaded, finishSignup]);
if (showSplash) {
return <Splash />;
}
return (
<NavigationContainer theme={{ colors: {} }} style={{ flex: 1 }}>
<Stack.Navigator>
{isAuthenticated && (finishSignup || todayPageLoaded) ? (
<Stack.Screen
name="Home"
options={{ headerShown: false, animationEnabled: false }}
>
{() => (
<BottomSheetProvider>
<MainStack />
<TodoBottomSheet />
</BottomSheetProvider>
)}
</Stack.Screen>
) : (
<Stack.Screen
name="Auth"
component={Auth}
options={{ headerShown: false, animationEnabled: false }}
/>
)}
</Stack.Navigator>
</NavigationContainer>
);
}