-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
122 lines (99 loc) · 3.66 KB
/
App.tsx
File metadata and controls
122 lines (99 loc) · 3.66 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { StatusBar } from 'expo-status-bar';
import { Button, StyleSheet, Text, View } from 'react-native';
import Welcome from './screens/Welcome';
import { useFonts } from 'expo-font';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
// import Entypo from '@expo/vector-icons/Entypo';
import React, { useCallback, useEffect, useState } from 'react';
import RootStack from './navigators/RootStack';
// export default function App() {
// const [appIsReady, setAppIsReady] = useState(false);
// useEffect(() => {
// async function prepare() {
// try {
// // Keep the splash screen visible while we fetch resources
// await SplashScreen.preventAutoHideAsync();
// // Pre-load fonts, make any API calls you need to do here
// await Font.loadAsync({
// 'Lato-Bold': require("./assets/fonts/Lato-Bold.ttf"),
// 'Lato-Regular': require("./assets/fonts/Lato-Regular.ttf")
// });
// // Artificially delay for two seconds to simulate a slow loading
// // experience. Please remove this if you copy and paste the code!
// // await new Promise(resolve => setTimeout(resolve, 2000));
// } catch (e) {
// console.warn(e);
// } finally {
// setAppIsReady(true);
// }
// }
// prepare();
// }, []);
// const onLayoutRootView = useCallback(async () => {
// if (appIsReady) {
// console.log(232)
// // This tells the splash screen to hide immediately! If we call this after
// // `setAppIsReady`, then we may see a blank screen while the app is
// // loading its initial state and rendering its first pixels. So instead,
// // we hide the splash screen once we know the root view has already
// // performed layout.
// await SplashScreen.hideAsync();
// }
// }, [appIsReady]);
// if (!appIsReady) {
// return null;
// }
// return (
// <View onLayout={onLayoutRootView}>
// <Text>SplashScreen Demo! 👋</Text>
// {/* <Entypo name="rocket" size={30} /> */}
// <Welcome />
// </View>
// );
// }
// Keep the splash screen visible while we fetch resources
// SplashScreen.preventAutoHideAsync();
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
useEffect(() => {
async function prepare() {
try {
// Pre-load fonts, make any API calls you need to do here
await Font.loadAsync({
'Lato-Bold': require("./assets/fonts/Lato-Bold.ttf"),
'Lato-Regular': require("./assets/fonts/Lato-Regular.ttf")
});
// Artificially delay for two seconds to simulate a slow loading
// experience. Please remove this if you copy and paste the code!
await new Promise(resolve => setTimeout(resolve, 2000));
} catch (e) {
console.warn(e);
} finally {
// Tell the application to render
setAppIsReady(true);
}
}
prepare();
}, []);
console.log(appIsReady)
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
// This tells the splash screen to hide immediately! If we call this after
// `setAppIsReady`, then we may see a blank screen while the app is
// loading its initial state and rendering its first pixels. So instead,
// we hide the splash screen once we know the root view has already
// performed layout.
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return <Text>Loading</Text>;
}
return (
// <View onLayout={onLayoutRootView}>
// <Welcome />
<RootStack />
);
}