-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
67 lines (58 loc) · 2.09 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
import { useFonts } from 'expo-font';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import * as SplashScreen from 'expo-splash-screen';
import { View } from 'react-native';
import Navigation from './App.navigation';
import { AppNextNativeProvider } from './App.theme';
import AppContext from '@components/context';
export default function App() {
// global variables
const checkJWT = useRef<any>();
const instanceInit = useRef(true);
const [isLoading, _setIsLoading] = useState<boolean>(true);
const [isLoadingLocal, _setIsLoadingLocal] = useState<boolean>(true);
const [fontsLoaded] = useFonts({
'Thin': require('./assets/fonts/Pretendard-Thin.otf'),
'ExtraLight': require('./assets/fonts/Pretendard-ExtraLight.otf'),
'Light': require('./assets/fonts/Pretendard-Light.otf'),
'Regular': require('./assets/fonts/Pretendard-Regular.otf'),
'Medium': require('./assets/fonts/Pretendard-Medium.otf'),
'SemiBold': require('./assets/fonts/Pretendard-SemiBold.otf'),
'Bold': require('./assets/fonts/Pretendard-Bold.otf'),
'ExtraBold': require('./assets/fonts/Pretendard-ExtraBold.otf'),
'Black': require('./assets/fonts/Pretendard-Black.otf')
});
useEffect(() => {
async function prepare() {
await SplashScreen.preventAutoHideAsync();
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded]);
if(!fontsLoaded) {
return null;
}
return (
<AppNextNativeProvider>
<AppContext.Provider value={{
checkJWT,
loading: { isLoading: isLoading, setIsLoading: _setIsLoading },
loadingLocal: { isLoading: isLoadingLocal, setIsLoading: _setIsLoadingLocal },
instanceInit
}}>
{
fontsLoaded ?
<View onLayout={onLayoutRootView} style={{ flex: 1 }}>
{/* <FetchLoading visible={isLoading}/> */}
<Navigation></Navigation>
</View>
: null
}
</AppContext.Provider>
</AppNextNativeProvider>
);
}