-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
127 lines (117 loc) · 3.54 KB
/
index.android.js
File metadata and controls
127 lines (117 loc) · 3.54 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Navigator,
AsyncStorage,
ActivityIndicator
} from 'react-native';
import CredentialsScreen from './app/components/SignUp/signUpCredentials';
import LogInScreen from './app/components/LogIn/index';
import InfoScreen from './app/components/SignUp/info';
import ClassSelectScreen from './app/components/SignUp/classSelect';
import ProjectSelectScreen from './app/components/SignUp/project';
import Root from './app/components/Dashboard/root';
import Summary from './app/components/Dashboard/summary';
import Details from './app/components/Details/details';
import ManualTracking from './app/components/Tracking/manual';
import Settings from './app/components/Dashboard/settings';
import storage from './app/components/api/storage';
import style from './app/styles/styles'
export default class SLTracker extends Component {
constructor(props) {
super(props);
this.state = {loading: true, initialRoute: 'LogIn'}
}
componentWillMount = async () => {
try {
const value = await storage.getAuthKey();
console.log(value);
if (value !== null){
this.setState({initialRoute: 'Dashboard'});
}
this.setState({loading: false});
} catch (error) {
// Error retrieving data
this.setState({loading: false});
this.setState({initialRoute: ''});
console.log(error);
}
}
// Renders a particular scene depending on the route title
renderScene(route, navigator) {
if(route.title == 'SelectClass') {
return <ClassSelectScreen navigator={navigator} {...route.extras}/>
}
if(route.title == 'SelectProject') {
return <ProjectSelectScreen navigator={navigator} {...route.extras} />
}
if(route.title == 'Dashboard') {
return <Root navigator={navigator} {...route.extras}/>
}
if(route.title == 'Summary') {
return <Summary navigator={navigator} {...route.extras}/>
}
if(route.title == 'Details') {
return <Details navigator={navigator} {...route.extras}/>
}
if(route.title == 'ManualTracking') {
return <ManualTracking navigator={navigator} {...route.extras}/>
}
if(route.title == 'LogIn') {
return <LogInScreen navigator={navigator} {...route.extras}/>
}
if(route.title == 'InfoScreen') {
return <InfoScreen navigator={navigator} {...route.extras}/>
}
if(route.title == 'SignUpCredentials') {
return <CredentialsScreen navigator={navigator} />
}
if(route.title == 'Settings') {
return <Settings navigator={navigator} {...route.extras}/>
}
}
render() {
// Change the 'initialRoute' to see your screen
// Add a case for your screen in the 'renderScene' function
if(this.state.loading) {
return(
<View style={[style.container, style.alignCenter]}>
<ActivityIndicator animating={true} />
</View>
)
}
return (
<Navigator
initialRoute={{ title: this.state.initialRoute}}
renderScene={this.renderScene}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('SLTracker', () => SLTracker);