-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
60 lines (54 loc) · 1.36 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
import React from "react";
import { StatusBar } from "expo-status-bar";
import { StyleSheet, View, SafeAreaView, Platform } from "react-native";
import * as SplashScreen from "expo-splash-screen";
import { HomeScreen } from "./src/screens/";
import Load from "./src/Load";
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isAppReady: false,
data: [],
};
}
componentDidMount() {
this.loadResourcesAsync();
}
async loadResourcesAsync() {
await Load.start(this.setAppIsReady, this.setInitState);
}
setAppIsReady = async () => {
this.setState({ isAppReady: true });
await SplashScreen.hideAsync();
};
setInitState = async (data) => {
this.setState({
data: data,
});
};
render() {
if (!this.state.isAppReady) {
return null;
}
return (
<View style={styles.container}>
{Platform.OS === "ios" && <StatusBar barStyle="default" />}
{Platform.OS === "android" && (
<View style={{ height: 24, backgroundColor: "rgba(0,0,0,0.2)" }} />
)}
<SafeAreaView>
<HomeScreen data={this.state.data} />
</SafeAreaView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});