-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
73 lines (65 loc) · 2.23 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React, { useState, useEffect, useContext, useCallback } from 'react';
import { setNavigator } from './src/navigationRef';
import { Provider as ColorProvider } from './src/context/ColorContext';
import { Provider as TimeProvider } from './src/context/TimeContext';
import { Provider as SoundProvider } from './src/context/SoundContext';
import { Provider as ThemeProvider } from './src/context/ThemeContext';
import { Provider as AdsProvider } from './src/context/AdsContext';
import Navigation from './src/navigation';
// import { AppLoading } from 'expo';
import * as SplashScreen from 'expo-splash-screen';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import { View, StyleSheet } from 'react-native';
const images = [];
export default () => {
const [loading, setLoading] = useState(true);
useEffect(() => {
SplashScreen.preventAutoHideAsync()
.then((result) =>
console.log(`SplashScreen.preventAutoHideAsync() succeeded: ${result}`)
)
.catch(console.warn);
handleResourcesAsync();
}, []);
const handleResourcesAsync = async () => {
// we're caching all the images
// for better performance on the app
await Font.loadAsync({
monoton: require('./assets/fonts/Monoton-Regular.ttf'),
overlock: require('./assets/fonts/OverlockSC-Regular.ttf'),
poiret: require('./assets/fonts/PoiretOne-Regular.ttf'),
comforta: require('./assets/fonts/Comfortaa-VariableFont_wght.ttf'),
baloo: require('./assets/fonts/BalooThambi2-Regular.ttf'),
});
const cacheImages = images.map((image) => {
return Asset.fromModule(image).downloadAsync();
});
Promise.all(cacheImages)
.then(async () => {
setLoading(false);
await SplashScreen.hideAsync();
})
.catch(() => console.log(1));
};
if (loading) {
return null;
}
return (
<AdsProvider>
<ThemeProvider>
<SoundProvider>
<ColorProvider>
<TimeProvider>
<Navigation
ref={(navigator) => {
setNavigator(navigator);
}}
/>
</TimeProvider>
</ColorProvider>
</SoundProvider>
</ThemeProvider>
</AdsProvider>
);
};