-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
82 lines (70 loc) · 1.91 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
import 'intl';
import 'intl/locale-data/jsonp/en';
import React, { useState, useEffect, useCallback } from 'react';
import { StatusBar, View } from 'react-native';
import * as SplashScreen from 'expo-splash-screen';
import { useAuthentication } from '@modules/authentication/hooks/authentication';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { ScreenProvider } from 'responsive-native';
import { loadAsync } from 'expo-font';
import {
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_700Bold,
} from '@expo-google-fonts/poppins';
import AppProvider from '@shared/hooks';
import Routes from '@shared/routes';
const App = (): JSX.Element => {
const [appIsReady, setAppIsReady] = useState(false);
const { persistedLoading } = useAuthentication();
useEffect(() => {
async function prepare() {
try {
await SplashScreen.preventAutoHideAsync();
loadAsync({
Poppins_300Light,
Poppins_400Regular,
Poppins_500Medium,
Poppins_700Bold,
});
await new Promise(resolve => setTimeout(resolve, 2000));
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady && !persistedLoading) {
return (
<View
style={{
flex: 1,
backgroundColor: '#5636D3',
}}
/>
);
}
return (
<SafeAreaProvider onLayout={onLayoutRootView}>
<ScreenProvider baseFontSize={16}>
<StatusBar
translucent
backgroundColor="transparent"
barStyle="dark-content"
/>
<AppProvider>
<Routes />
</AppProvider>
</ScreenProvider>
</SafeAreaProvider>
);
};
export default App;