-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.tsx
More file actions
106 lines (95 loc) · 3.15 KB
/
Copy pathApp.tsx
File metadata and controls
106 lines (95 loc) · 3.15 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
103
104
105
106
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import type { Theme as NavTheme } from "@react-navigation/native";
import { PaperProvider, MD3Theme } from "react-native-paper";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import * as Notifications from "expo-notifications";
import "@utils/webAlertPolyfill";
import { SettingsProvider, useSettings } from "@store/settings";
import navigationRef from "@navigation/navigationRef";
import { AppTabs } from "@navigation/AppTabs";
import { builtStacks } from "@navigation/stacks";
import { ConferenceDataProvider } from "@store/conferenceData";
import { FavoritesProvider } from "@store/favorites";
import { useScheduleNotifications } from "@hooks/useScheduleNotifications";
import { useNotificationDeepLink } from "@hooks/useNotificationDeepLink";
import { useUrlDeepLink } from "@hooks/useUrlDeepLink";
import { useAppNavTheme } from "@hooks/useAppNavTheme";
import { usePwaInstallPrompt } from "@hooks/usePwaInstallPrompt";
import InstallPrompt from "@components/status/InstallPrompt";
function ScheduleNotificationManager() {
useScheduleNotifications();
return null;
}
function UrlDeepLinkManager() {
useUrlDeepLink();
return null;
}
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowBanner: true,
shouldShowList: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
function AppContent() {
const { conferenceYear, themeMode, onboardingSeen, hydrated } = useSettings();
const { paperTheme: activePaperTheme, navTheme } = useAppNavTheme(themeMode);
const { onNavReady } = useNotificationDeepLink();
const pwaInstallPrompt = usePwaInstallPrompt();
if (!hydrated) {
return null;
}
const OnboardingStackNavigator = builtStacks.onboarding;
if (!onboardingSeen) {
return (
<AppScaffold theme={activePaperTheme} navTheme={navTheme} onNavReady={onNavReady}>
<OnboardingStackNavigator />
</AppScaffold>
);
}
return (
<AppScaffold theme={activePaperTheme} navTheme={navTheme} onNavReady={onNavReady}>
<ConferenceDataProvider year={conferenceYear}>
<FavoritesProvider year={conferenceYear}>
<ScheduleNotificationManager />
<UrlDeepLinkManager />
<InstallPrompt {...pwaInstallPrompt} />
<AppTabs theme={activePaperTheme} />
</FavoritesProvider>
</ConferenceDataProvider>
</AppScaffold>
);
}
export default function App() {
return (
<SettingsProvider>
<AppContent />
</SettingsProvider>
);
}
function AppScaffold({
children,
theme,
navTheme,
onNavReady,
}: {
children: React.ReactNode;
theme: MD3Theme;
navTheme: NavTheme;
onNavReady: () => void;
}) {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<PaperProvider theme={theme}>
<SafeAreaProvider>
<NavigationContainer theme={navTheme} ref={navigationRef} onReady={onNavReady}>
{children}
</NavigationContainer>
</SafeAreaProvider>
</PaperProvider>
</GestureHandlerRootView>
);
}