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
103import { Caveat_700Bold } from '@expo-google-fonts/caveat'
import { InterTight_700Bold } from '@expo-google-fonts/inter-tight'
import { Lexend_400Regular, Lexend_500Medium } from '@expo-google-fonts/lexend'
import { safeBottomSheetViewScreenOptions } from '@lib/components/generic/SafeBottomSheetView'
import BackgroundLocationServiceController from '@lib/services/BackgroundLocationServiceController'
import TracingCrawlerServiceProvider from '@lib/services/tracing-crawler/TracingCrawlerServiceProvider'
import WebWorkerThreadProvider from '@lib/services/web-worker/WebWorkerThreadProvider'
import DatabaseProvider, {
initializeDatabase,
} from '@lib/utils/DatabaseProvider'
import SettingsProvider from '@lib/utils/SettingsProvider'
import * as Font from 'expo-font'
import { SplashScreen, Stack } from 'expo-router'
import { StatusBar } from 'expo-status-bar'
import { useEffect, useState } from 'react'
SplashScreen.preventAutoHideAsync()
export default function RootLayout() {
const [appIsReady, setAppIsReady] = useState(false)
useEffect(() => {
async function prepareApp() {
console.info('Preparing app...')
console.info('Initializing database...')
await initializeDatabase()
console.info('Database initialized')
console.info('Loading fonts...')
try {
await Font.loadAsync({
'Proto Mono':
require('@assets/fonts/ProtoMono-Regular.ttf') as number,
Caveat: Caveat_700Bold,
Lexend: Lexend_400Regular,
'Lexend-Medium': Lexend_500Medium,
'Inter-Tight-Bold': InterTight_700Bold,
})
} catch (e) {
console.warn('error loading fonts', e)
}
console.info('Fonts loaded')
setAppIsReady(true)
}
void prepareApp()
}, [])
useEffect(() => {
if (appIsReady) {
console.info("App is ready, let's go!")
SplashScreen.hideAsync()
}
}, [appIsReady])
if (!appIsReady) {
return null
}
return (
<DatabaseProvider>
<SettingsProvider>
<WebWorkerThreadProvider>
<TracingCrawlerServiceProvider>
<StatusBar style="dark" />
<BackgroundLocationServiceController />
<Stack
screenOptions={{
headerShown: false,
orientation: 'portrait',
}}
>
<Stack.Screen
name="onboarding"
options={{
animation: 'fade',
}}
/>
<Stack.Screen
name="home"
options={{
animation: 'fade',
}}
/>
<Stack.Screen
name="settings"
options={safeBottomSheetViewScreenOptions}
/>
</Stack>
</TracingCrawlerServiceProvider>
</WebWorkerThreadProvider>
</SettingsProvider>
</DatabaseProvider>
)
}