-
Notifications
You must be signed in to change notification settings - Fork 11
/
App.tsx
68 lines (60 loc) · 2.14 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
import "react-native-gesture-handler";
import React, { useCallback, useEffect, useState } from "react";
import { Provider } from "react-redux";
import { MenuProvider } from "react-native-popup-menu";
import * as SplashScreen from "expo-splash-screen";
import { LogBox } from "react-native";
import * as Font from "expo-font";
import { SafeAreaProvider } from "react-native-safe-area-context";
import AppNavigator from "./src/navigation";
import { store } from "./src/utils/store";
// Keep the splash screen visible while we fetch resources(fonts)
SplashScreen.preventAutoHideAsync();
// LogBox.ignoreLogs(["You are initializing Firebase Auth for React Native without providing AsyncStorage."]);
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
useEffect(() => {
async function prepare() {
try {
// Pre-load fonts
await Font.loadAsync({
black: require("./assets/fonts/Roboto-Black.ttf"),
blackItalic: require("./assets/fonts/Roboto-BlackItalic.ttf"),
bold: require("./assets/fonts/Roboto-Bold.ttf"),
boldItalic: require("./assets/fonts/Roboto-BoldItalic.ttf"),
italic: require("./assets/fonts/Roboto-Italic.ttf"),
light: require("./assets/fonts/Roboto-Light.ttf"),
lightItalic: require("./assets/fonts/Roboto-LightItalic.ttf"),
medium: require("./assets/fonts/Roboto-Medium.ttf"),
mediumItalic: require("./assets/fonts/Roboto-MediumItalic.ttf"),
regular: require("./assets/fonts/Roboto-Regular.ttf"),
thin: require("./assets/fonts/Roboto-Thin.ttf"),
thinItalic: require("./assets/fonts/Roboto-ThinItalic.ttf"),
});
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) {
return null;
}
return (
<Provider store={store}>
<SafeAreaProvider style={{ flex: 1 }} onLayout={onLayoutRootView}>
<MenuProvider>
<AppNavigator />
</MenuProvider>
</SafeAreaProvider>
</Provider>
);
}