-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
69 lines (60 loc) · 1.84 KB
/
App.js
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
if (__DEV__) {
import('./ReactotronConfig').then(() => console.log('Reactotron Configured'));
}
import './global';
import 'react-native-gesture-handler';
import { StatusBar } from 'expo-status-bar';
import { Provider as PaperProvider } from 'react-native-paper';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';
import { NavigationContainer } from '@react-navigation/native';
import { useCallback, useEffect, useState } from 'react';
import { LogBox } from 'react-native';
import { useAuth, usePreferences } from './src/hooks';
import { fonts } from './src/core';
import { AuthProvider, GlobalProvider, PreferencesProvider } from './src/contexts';
import { RootNavigator } from './src/navigation';
LogBox.ignoreLogs([
'Require cycles are allowed, but can result in uninitialized values.',
'Require cycle: node_modules/victory',
]);
SplashScreen.preventAutoHideAsync();
function Main() {
const [appIsReady, setAppIsReady] = useState(false);
const { isThemeDark, theme } = usePreferences();
const { isValidating } = useAuth();
useEffect(() => {
async function prepare() {
await Font.loadAsync(fonts);
setAppIsReady(true);
}
prepare();
}, []);
const onReady = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady || isValidating) {
return null;
}
return (
<PaperProvider theme={theme}>
<GlobalProvider>
<NavigationContainer theme={theme} onReady={onReady}>
<RootNavigator />
</NavigationContainer>
<StatusBar style={isThemeDark ? 'light' : 'dark'} />
</GlobalProvider>
</PaperProvider>
);
}
export default function App() {
return (
<AuthProvider>
<PreferencesProvider>
<Main />
</PreferencesProvider>
</AuthProvider>
);
}