-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
55 lines (42 loc) · 1.24 KB
/
App.js
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
import { useCallback, useEffect, useState } from 'react';
//Font loading
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
//Screen component
import Pomodoro from "./Navigation/PomodoroNavigation"
//Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();
//Custom Font Imports
function fetchFonts() {
return Font.loadAsync({
"open-sans-light": require("./assets/Fonts/OpenSansCondensed-Light.ttf"),
"open-sans-bold": require("./assets/Fonts/OpenSansCondensed-Bold.ttf"),
"open-sans-light-italic": require("./assets/Fonts/OpenSansCondensed-LightItalic.ttf"),
});
}
export default function App() {
const [fontLoaded, setFontLoaded] = useState(false);
useEffect(() => {
async function prepare() {
try {
await fetchFonts();
await new Promise(resolve => setTimeout(resolve, 2000));
} catch (e) {
console.warn(e);
} finally {
setFontLoaded(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (fontLoaded) {
await SplashScreen.hideAsync();
}
}, [fontLoaded]);
if (!fontLoaded) {
return null;
}
onLayoutRootView()
return <Pomodoro />;
}