-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
61 lines (52 loc) · 1.58 KB
/
App.tsx
File metadata and controls
61 lines (52 loc) · 1.58 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
import React, { useState, useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import * as SplashScreenExpo from 'expo-splash-screen';
import { ThemeProvider, useTheme } from './src/context/ThemeContext';
import { useSettingsStore } from './src/store/SettingsStore';
import { Navigation } from './src/navigation/Navigation';
import { SplashScreen } from './src/components/SplashScreen';
import { UpdateChecker } from './src/components/UpdateChecker';
SplashScreenExpo.preventAutoHideAsync();
function AppContent() {
const [isReady, setIsReady] = useState(false);
const [showSplash, setShowSplash] = useState(true);
const [updateCheckComplete, setUpdateCheckComplete] = useState(false);
const { isDark } = useTheme();
const loadSettings = useSettingsStore((state) => state.loadSettings);
useEffect(() => {
async function prepare() {
try {
await loadSettings();
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (e) {
console.warn(e);
} finally {
setIsReady(true);
await SplashScreenExpo.hideAsync();
}
}
prepare();
}, []);
if (!isReady) {
return null;
}
if (!updateCheckComplete) {
return <UpdateChecker onCheckComplete={() => setUpdateCheckComplete(true)} />;
}
if (showSplash) {
return <SplashScreen onFinish={() => setShowSplash(false)} />;
}
return (
<>
<StatusBar style={isDark ? 'light' : 'dark'} />
<Navigation />
</>
);
}
export default function App() {
return (
<ThemeProvider>
<AppContent />
</ThemeProvider>
);
}