-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
71 lines (60 loc) · 1.94 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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { AppLoading } from 'expo';
import { Asset } from 'expo-asset';
import Navigation from './navigation';
import { Block } from './components';
console.disableYellowBox = true;
// import all used images
const images = [
require('./assets/icons/back.png'),
require('./assets/icons/plants.png'),
require('./assets/icons/seeds.png'),
require('./assets/icons/flowers.png'),
require('./assets/icons/sprayers.png'),
require('./assets/icons/pots.png'),
require('./assets/icons/fertilizers.png'),
require('./assets/images/plants_1.png'),
require('./assets/images/plants_2.png'),
require('./assets/images/plants_3.png'),
require('./assets/images/explore_1.png'),
require('./assets/images/explore_2.png'),
require('./assets/images/explore_3.png'),
require('./assets/images/explore_4.png'),
require('./assets/images/explore_5.png'),
require('./assets/images/explore_6.png'),
require('./assets/images/illustration_1.png'),
require('./assets/images/illustration_2.png'),
require('./assets/images/illustration_3.png'),
require('./assets/images/avatar.png')
];
export default class App extends React.Component {
state = {
isLoadingComplete: false
};
handleResourcesAsync = async () => {
// we're caching all the images
// for better performance on the app
const cacheImages = images.map(image => {
return Asset.fromModule(image).downloadAsync();
});
return Promise.all(cacheImages);
};
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this.handleResourcesAsync}
onError={error => console.warn(error)}
onFinish={() => this.setState({ isLoadingComplete: true })}
/>
);
}
return (
<Block white>
<Navigation />
</Block>
);
}
}
const styles = StyleSheet.create({});