-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
56 lines (44 loc) · 1.17 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
import React from 'react'
import { StatusBar, Image } from 'react-native'
import { Provider as PaperProvider } from 'react-native-paper'
import { Asset } from 'expo-asset'
import { AppLoading } from 'expo'
import Router from './src/screens/Routes'
import theme from './src/style/theme'
export default class App extends React.Component {
state = {
isReady: false,
}
render() {
if (!this.state.isReady) {
return (
<AppLoading
startAsync={this._cacheResourcesAsync}
onFinish={() => this.setState({ isReady: true })}
onError={console.warn}
/>
)
}
return (
<PaperProvider theme={theme}>
<StatusBar translucent='true' barStyle="light-content" />
<Router />
</PaperProvider>
)
}
async _cacheResourcesAsync() {
let images = [
require('./assets/animals-splash.png')
]
const imagesCached = cacheImages(images)
await Promise.all(imagesCached)
}
}
const cacheImages = (images) => {
return images.map(image => {
if (typeof image === 'string') {
return Image.prefetch(image)
}
return Asset.fromModule(image).downloadAsync()
})
}