generated from GabrielGuedess/Expo-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
69 lines (55 loc) · 1.64 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
import { useEffect, useState, useCallback } from 'react';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import Toast from 'react-native-toast-message';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';
import {
Poppins_300Light as Poppins300Light,
Poppins_500Medium as Poppins500Medium,
Poppins_600SemiBold as Poppins600SemiBold,
} from '@expo-google-fonts/poppins';
import { ThemeProvider } from 'styled-components/native';
import { rgba } from 'polished';
import { Routes } from 'routes';
import { AuthContextProvider } from 'contexts/AuthContext';
import { theme } from 'styles/theme';
const App = () => {
const [appIsReady, setAppIsReady] = useState(false);
useEffect(() => {
async function prepare() {
try {
await Font.loadAsync({
Poppins300Light,
Poppins500Medium,
Poppins600SemiBold,
});
} catch (error) {
console.warn(error);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<ThemeProvider theme={theme}>
<AuthContextProvider>
<GestureHandlerRootView onLayout={onLayoutRootView} style={{ flex: 1 }}>
<StatusBar style="light" backgroundColor={rgba('#000', 0.3)} />
<Routes />
<Toast />
</GestureHandlerRootView>
</AuthContextProvider>
</ThemeProvider>
);
};
export default App;