-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
55 lines (45 loc) · 1.08 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
import React, { Component } from 'react';
import {
StyleSheet,
Text,
AsyncStorage
} from 'react-native';
import DataCollection from './views/DataCollection'
import Dashboard from './views/Dashboard'
import Loading from './views/Loading'
class App extends Component {
constructor (props) {
super(props)
this.state = {
page: null
}
this.findLoadedUser()
}
async findLoadedUser () {
try {
const loadedUser = await AsyncStorage.getItem('loadedUser')
if (loadedUser == 'true') {
this.setState({page: 'Dashboard'})
} else {
this.setState({page: 'DataCollection'})
}
} catch (error) {
this.setState({page: 'DataCollection'})
}
}
changePage (page) {
this.setState({page: page})
}
render () {
if (this.state.page === 'DataCollection') {
return (<DataCollection changePage={(e) => this.changePage(e)}/>)
} else if (this.state.page === 'Dashboard') {
return (<Dashboard/>)
} else {
return (<Loading/>)
}
}
};
const styles = StyleSheet.create({
});
export default App;