-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
35 lines (30 loc) · 1.03 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
import { StatusBar } from "expo-status-bar";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import GameEngine from "./src/components/GameEngine";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { useFonts } from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { useCallback } from "react";
// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();
export default function App() {
const [fontsLoaded, fontError] = useFonts({
Pixeled: require("./assets/fonts/Pixeled.ttf"),
});
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded || fontError) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded, fontError]);
if (!fontsLoaded && !fontError) {
return null;
}
return (
<SafeAreaProvider>
<GestureHandlerRootView style={{ flex: 1 }} onLayout={onLayoutRootView}>
<GameEngine />
<StatusBar style="auto" />
</GestureHandlerRootView>
</SafeAreaProvider>
);
}