-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
74 lines (68 loc) · 1.88 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
74
import React, { Component } from 'react';
import { AppLoading, Asset, SplashScreen } from 'expo';
import { StyleSheet, Text, View, Image } from 'react-native';
import { fontAssets, imageAssets } from './helpers';
import { Provider } from 'react-redux';
import { ReduxRouter } from './src/routes/Navigator';
import store, { ReduxNavigator } from './src/store';
import { Colors } from './src/common';
import { GalleryScreen } from './src/screens';
export default class App extends Component {
state = {
isSplashReady: false,
isAppReady: false
};
_loadSplashResourcesAsync = async () => {
const gif = require('./assets/splash.png');
return Asset.fromModule(gif).downloadAsync();
};
_cacheResourcesAsync = async () => {
SplashScreen.hide();
const result = await Promise.all([fontAssets, imageAssets]);
this.setState({ isAppReady: true });
};
render() {
if (!this.state.isSplashReady) {
return (
<AppLoading
startAsync={this._loadSplashResourcesAsync}
onFinish={() => this.setState({ isSplashReady: true })}
onError={console.warn}
autoHideSplash={false}
/>
);
}
if (!this.state.isAppReady) {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: Colors.hotspotColor
}}
>
<Image
source={require('./assets/splash.png')}
onLoad={this._cacheResourcesAsync}
/>
</View>
);
}
return (
<Provider store={store}>
<View style={{ flex: 1 }}>
<ReduxRouter navigator={ReduxNavigator} />
</View>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
});