-
Notifications
You must be signed in to change notification settings - Fork 54
/
App.tsx
74 lines (63 loc) · 2.17 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
import 'expo-dev-client';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {LogBox} from 'react-native';
import * as Linking from 'expo-linking';
import {StatusBar} from 'expo-status-bar';
import * as SplashScreen from 'expo-splash-screen';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {NavioApp} from '@app/navio';
import {
configureDesignSystem,
getNavigationTheme,
getStatusBarBGColor,
getStatusBarStyle,
} from '@app/utils/designSystem';
import {hydrateStores} from '@app/stores';
import {initServices} from '@app/services';
import {AppProvider} from '@app/utils/providers';
import {useAppearance} from '@app/utils/hooks';
LogBox.ignoreLogs([
'Require',
'Found screens with the same name nested inside one another.', // for navio in some cases
]);
export default (): JSX.Element => {
useAppearance();
const [ready, setReady] = useState(false);
// `onLaunch` performs actions that have to be done on app launch before displaying app UI.
// If you need to make some api requests, load remote config, or some other "heavy" actions, you can use `@app/services/onLaunch.tsx`.
const onLaunch = useCallback(async () => {
await SplashScreen.preventAutoHideAsync();
await hydrateStores();
configureDesignSystem();
await initServices();
setReady(true);
await SplashScreen.hideAsync();
}, []);
useEffect(() => {
onLaunch();
}, [onLaunch]);
const NotReady = useMemo(() => {
// [Tip]
// You can show loading state here.
return <></>;
}, [ready]);
if (!ready) return NotReady;
return (
<GestureHandlerRootView style={{flex: 1}}>
<AppProvider>
<StatusBar style={getStatusBarStyle()} backgroundColor={getStatusBarBGColor()} />
<NavioApp
navigationContainerProps={{
theme: getNavigationTheme(),
linking: {
prefixes: [Linking.createURL('/')],
},
}}
// [Tip]
// You can use `root` to change the root of the app depending on global state changes.
// root={isLoggedIn ? 'AuthStack' : 'AppTabs'}
/>
</AppProvider>
</GestureHandlerRootView>
);
};