-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
82 lines (76 loc) · 2.52 KB
/
App.js
File metadata and controls
82 lines (76 loc) · 2.52 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
import React, {useState} from 'react'
import {Provider} from 'react-redux'
import store from './client/store'
import {Platform, View, Text, StyleSheet, Image} from 'react-native'
import * as Font from 'expo-font'
import Routes from './client/routes'
import {fonts} from './assets'
import {AppLoading, SplashScreen} from 'expo'
import {Asset} from 'expo-asset'
import {Ionicons} from '@expo/vector-icons'
import useLinking from './client/routes/useLinking'
console.disableYellowBox = true
const styles = StyleSheet.create({
boldText: {
fontSize: 30,
color: 'red'
},
nav: {
flexDirection: 'row',
justifyContent: 'space-around'
}
})
function cacheImages(images) {
return images.map(image => {
if (typeof image === 'string') {
return Image.prefetch(image)
} else {
return Asset.fromModule(image).downloadAsync()
}
})
}
export default function App(props) {
const [isLoadingComplete, setLoadingComplete] = React.useState(false)
const [initialNavigationState, setInitialNavigationState] = React.useState()
const containerRef = React.useRef()
const {getInitialState} = useLinking(containerRef)
// Load any resources or data that we need prior to rendering the app
React.useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
SplashScreen.preventAutoHide()
// Load our initial navigation state
setInitialNavigationState(await getInitialState())
//load images
await cacheImages([require('./assets/background.png')])
// Load fonts
await Font.loadAsync({
...Ionicons.font,
FuturaBold: require('./assets/fonts/FuturaBold.ttf'),
FuturaBoldE: require('./assets/fonts/FuturaExtra.ttf'),
FuturaBoldI: require('./assets/fonts/FuturaBoldItalic.ttf'),
KenyanCoffee: require('./assets/fonts/kenyancoffeerg.ttf'),
FuturistFixedwidthBold: require('./assets/fonts/FuturistFixedwidthBold.ttf'),
APompadour: require('./assets/fonts/APompadour.ttf'),
APompadourBold: require('./assets/fonts/APompadourBold.ttf')
})
} catch (e) {
// We might want to provide this error information to an error reporting service
console.warn(e)
} finally {
setLoadingComplete(true)
SplashScreen.hide()
}
}
loadResourcesAndDataAsync()
}, [])
if (!isLoadingComplete && !props.skipLoadingScreen) {
return <AppLoading />
} else {
return (
<Provider store={store}>
<Routes />
</Provider>
)
}
}