-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathApp.js
85 lines (74 loc) · 1.84 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
75
76
77
78
79
80
81
82
83
84
85
// Differentiate between setup and layout components
import React from 'react';
import { Text, View, StatusBar } from 'react-native';
import Layout from './layouts/layout';
import Setup from './layouts/setup';
import * as Font from 'expo-font';
import API from './api';
export default class App extends React.Component {
constructor(props){
super(props);
this.state = {
setup: false,
font: false
}
}
componentWillMount(){
API.getData("setup").then(setupStatus => {
console.log(setupStatus);
if(setupStatus == "start"){
this.setState({setup: "start"});
}else{
this.setState({setup: "done"});
}
});
}
componentDidMount(){
Font.loadAsync({
'rubik': require('./fonts/Rubik-Regular.ttf'),
'rubik-bold': require('./fonts/Rubik-Bold.ttf')
}).then(() => {
this.setState({font: true});
});
this.checkTimeout();
}
checkTimeout(){
setTimeout(() => {
if(!this.state.setup){
API.getData("setup").then(setupStatus => {
if(setupStatus == "start"){
this.setState({setup: "start"});
}else{
this.setState({setup: "done"});
}
});
this.checkTimeout();
}
}, 300);
}
setupFinished(){
this.setState({setup: "done"});
API.setData("setup", "done");
}
renderMainComponent(){
if(this.state.setup == "start"){
return(<Setup finished={this.setupFinished.bind(this)}/>);
}else if(this.state.setup == "done"){
return(<Layout language={this.state.currentLang}/>);
}else{
return null;
}
}
render() {
if(this.state.font){
return (
<View style={{flex: 1, position: "relative"}}>
<StatusBar hidden={true}/>
{this.renderMainComponent()}
</View>
);
}else{
return null;
}
}
}