-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
73 lines (61 loc) · 1.88 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
/**
* Welcome to the main entry point of the app. In this file, we'll
* be kicking off our app.
*
* Most of this file is boilerplate and you shouldn't need to modify
* it very often. But take some time to look through and understand
* what is going on here.
*
* The app navigation resides in ./app/navigators, so head over there
* if you're interested in adding screens and navigators.
*/
import React from 'react';
import {useColorScheme} from 'react-native';
import {
SafeAreaProvider,
initialWindowMetrics,
} from 'react-native-safe-area-context';
import {Colors} from 'react-native-ui-lib';
import {useInitialRootStore} from './models';
import {AppNavigator, useNavigationPersistence} from './navigators';
import * as storage from './utils/storage';
Colors.loadSchemes({
light: {
screenBG: 'transparent',
textColor: Colors.grey10,
},
dark: {
screenBG: Colors.grey10,
textColor: Colors.white,
},
});
Colors.loadDesignTokens({primaryColor: '#e6b11b'});
export const NAVIGATION_PERSISTENCE_KEY = 'NAVIGATION_STATE';
/**
* This is the root component of our app.
*/
function App() {
const {
initialNavigationState,
onNavigationStateChange,
isRestored: isNavigationStateRestored,
} = useNavigationPersistence(storage, NAVIGATION_PERSISTENCE_KEY);
const theme = useColorScheme();
const {rehydrated} = useInitialRootStore();
// Before we show the app, we have to wait for our state to be ready.
if (!rehydrated || !isNavigationStateRestored) {
return null;
}
// set the color theme for the app
Colors.setScheme(theme === 'dark' ? 'dark' : 'light');
// otherwise, we're ready to render the app
return (
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<AppNavigator
initialState={initialNavigationState}
onStateChange={onNavigationStateChange}
/>
</SafeAreaProvider>
);
}
export default App;