-
Notifications
You must be signed in to change notification settings - Fork 5
/
App.tsx
132 lines (122 loc) · 3.51 KB
/
App.tsx
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
import {
AzeretMono_100Thin,
AzeretMono_200ExtraLight,
AzeretMono_300Light,
AzeretMono_400Regular,
AzeretMono_500Medium,
AzeretMono_600SemiBold,
AzeretMono_700Bold,
AzeretMono_800ExtraBold,
AzeretMono_900Black,
} from "@expo-google-fonts/azeret-mono";
import { Inter_100Thin, Inter_200ExtraLight, Inter_300Light, Inter_400Regular, Inter_500Medium, Inter_600SemiBold, Inter_700Bold, Inter_800ExtraBold, Inter_900Black } from "@expo-google-fonts/inter";
import {
Outfit_100Thin,
Outfit_200ExtraLight,
Outfit_300Light,
Outfit_400Regular,
Outfit_500Medium,
Outfit_600SemiBold,
Outfit_700Bold,
Outfit_800ExtraBold,
Outfit_900Black,
useFonts,
} from "@expo-google-fonts/outfit";
import {
Poppins_100Thin,
Poppins_200ExtraLight,
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_600SemiBold,
Poppins_700Bold,
Poppins_800ExtraBold,
Poppins_900Black,
} from "@expo-google-fonts/poppins";
import * as SplashScreen from "expo-splash-screen";
import { NativeBaseProvider } from "native-base";
import React, { useEffect, useState } from "react";
import { Appearance, View } from "react-native";
import { extendedTheme } from "./src/config/theme";
import { AppContextProvider } from "./src/context/app/AppContext";
import { SettingsContextProvider } from "./src/context/settings/SettingsContext";
import { colorModeManager } from "./src/lib/color";
import { runMigration } from "./src/lib/database/core";
import { migrateLegacyDB, syncLocalData } from "./src/services/local/startup";
import MainStack from "./src/stacks/MainStack";
(async () => await SplashScreen.preventAutoHideAsync())();
export default function App() {
const [navReady, setNavReady] = useState(false);
const [appReady, setAppReady] = useState(false);
const [migrationComplete, setMigrationComplete] = useState(false);
let [fontsLoaded] = useFonts({
Outfit_100Thin,
Outfit_200ExtraLight,
Outfit_300Light,
Outfit_400Regular,
Outfit_500Medium,
Outfit_600SemiBold,
Outfit_700Bold,
Outfit_800ExtraBold,
Outfit_900Black,
Poppins_100Thin,
Poppins_200ExtraLight,
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_600SemiBold,
Poppins_700Bold,
Poppins_800ExtraBold,
Poppins_900Black,
Inter_100Thin,
Inter_200ExtraLight,
Inter_300Light,
Inter_400Regular,
Inter_500Medium,
Inter_600SemiBold,
Inter_700Bold,
Inter_800ExtraBold,
Inter_900Black,
AzeretMono_100Thin,
AzeretMono_200ExtraLight,
AzeretMono_300Light,
AzeretMono_400Regular,
AzeretMono_500Medium,
AzeretMono_600SemiBold,
AzeretMono_700Bold,
AzeretMono_800ExtraBold,
AzeretMono_900Black,
});
// Hide splash screen when fonts and pages are ready
useEffect(() => {
(async () => {
if (fontsLoaded && navReady && appReady) {
await SplashScreen.hideAsync();
}
})();
}, [fontsLoaded, navReady, appReady]);
if (typeof window !== undefined) {
Appearance.addChangeListener(({ colorScheme }) => { colorModeManager.set(colorScheme); });
(async () => {
await runMigration(migrateLegacyDB);
await syncLocalData();
if (!migrationComplete) {
setMigrationComplete(true);
}
})();
}
if (!fontsLoaded) {
return null;
}
return (
<View style={{ flex: 1 }} onLayout={() => setAppReady(true)}>
<AppContextProvider>
<SettingsContextProvider>
<NativeBaseProvider theme={extendedTheme} colorModeManager={colorModeManager} >
<MainStack migrationComplete={migrationComplete} onNavReady={() => setNavReady(true)} />
</NativeBaseProvider>
</SettingsContextProvider>
</AppContextProvider>
</View>
);
}