-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
64 lines (56 loc) · 1.49 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
import { StyleSheet, View } from "react-native";
import * as Updates from "expo-updates";
import { SafeAreaProvider } from "react-native-safe-area-context";
import * as SplashScreen from "expo-splash-screen";
import archivoBlack from "@Assets/fonts/Archivo-Black.ttf";
import archivoNarrow from "@Assets/fonts/Archivo-Narrow.ttf";
import { useFonts } from "expo-font";
import { useCallback, useEffect } from "react";
import AppNavigationContainer from "@Navigators/index";
import SnackbarProvider from "@Context/SnackbarContext";
export default (): JSX.Element => {
const [loaded] = useFonts({
"Archivo-Black": archivoBlack,
"Archivo-Narrow": archivoNarrow,
});
const checkUpdate = async (): Promise<void> => {
try {
const { isAvailable } = await Updates.checkForUpdateAsync();
if (isAvailable) {
await Updates.fetchUpdateAsync();
await Updates.reloadAsync();
}
} catch (error) {
//
}
};
const onLayoutRootView = useCallback(async () => {
if (loaded) {
await SplashScreen.hideAsync();
}
}, [loaded]);
useEffect(() => {
const prepare = async (): Promise<void> => {
await SplashScreen.preventAutoHideAsync();
};
prepare();
checkUpdate();
}, []);
if (!loaded) {
return null;
}
return (
<SafeAreaProvider>
<SnackbarProvider>
<View style={styles.container} onLayout={onLayoutRootView}>
<AppNavigationContainer />
</View>
</SnackbarProvider>
</SafeAreaProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
});