-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
91 lines (79 loc) · 2.83 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
import './polyfill'
import './setupColorScheme'
import './setupTheme'
import { FontAwesome } from '@expo/vector-icons'
import { effect, useSignalEffect } from '@preact/signals-react'
import {
currentlyLoadedResources,
FONT_RESOURCE,
I18N_RESOURCE,
loadedAllResources,
NOTIFICATION_RESOURCE,
} from '@utils/AppResources'
import { scheduleReminderNotification } from '@utils/NotificationUtils'
import * as Font from 'expo-font'
import { StatusBar } from 'expo-status-bar'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import useColorScheme from './hooks/useColorScheme'
import Navigation from './navigation'
import i18n from './modules/i18n'
import * as Notifications from 'expo-notifications'
import * as SplashScreen from 'expo-splash-screen'
import { LogBox } from 'react-native'
LogBox.ignoreLogs(['Non-serializable values were found in the navigation state'])
// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync()
effect(() => {})
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: true,
}),
})
scheduleReminderNotification()
.then(() => {
currentlyLoadedResources.value |= NOTIFICATION_RESOURCE
})
.catch((error) => console.error('[NOTIFICATION]', error))
i18n
.init()
.then(() => (currentlyLoadedResources.value |= I18N_RESOURCE))
.catch((error) => console.error('[I18N]', error))
Font.loadAsync({
...FontAwesome.font,
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
'mona-black': require('./assets/fonts/Mona-Sans-Black.ttf'),
'mona-bold': require('./assets/fonts/Mona-Sans-Bold.ttf'),
'mona-extraBold': require('./assets/fonts/Mona-Sans-ExtraBold.ttf'),
'mona-light': require('./assets/fonts/Mona-Sans-Light.ttf'),
'mona-medium': require('./assets/fonts/Mona-Sans-Medium.ttf'),
'mona-regular': require('./assets/fonts/Mona-Sans-Regular.ttf'),
'mona-semiBold': require('./assets/fonts/Mona-Sans-SemiBold.ttf'),
'mona-ultraLight': require('./assets/fonts/Mona-Sans-UltraLight.ttf'),
})
.then(() => (currentlyLoadedResources.value |= FONT_RESOURCE))
.catch((error) => console.error('[FONT]', error))
export default function App() {
useSignalEffect(() => {
if (!loadedAllResources.value) {
return
}
console.log('Loaded all resources')
SplashScreen.hideAsync()
})
const colorScheme = useColorScheme()
if (!loadedAllResources.value) {
console.log("Skip rendering app, it's not ready yet", loadedAllResources.value)
return null
}
return (
<SafeAreaProvider>
<GestureHandlerRootView style={{ flex: 1 }}>
<Navigation colorScheme={colorScheme} />
</GestureHandlerRootView>
<StatusBar />
</SafeAreaProvider>
)
}