-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
109 lines (92 loc) · 2.36 KB
/
index.android.js
File metadata and controls
109 lines (92 loc) · 2.36 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
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Navigator,
AsyncStorage,
Alert,
View
} from 'react-native';
import Button from 'react-native-button'
import TimerMixin from 'react-timer-mixin';
import Profile from './app/components/Profile';
import FBLogin from './app/components/Launch';
import Main from './app/components/Home';
// const Main = require('HomePage')
import Spinner from 'react-native-loading-spinner-overlay';
class HumorUs extends Component {
mixins: [TimerMixin]
constructor(props) {
super(props)
this.state = {
num: 0,
persists: false
}
}
componentWillMount() {
// AsyncStorage.getItem("user").then((value) => {
// this.setState({ num: '0', persists: true });
AsyncStorage.getItem("loggedin").then((value) => {
console.log("value", value)
if (value === 'true') {
console.log("logged in")
this.setState({ num: '1', persists: true });
} else {
console.log("not logged in?")
this.setState({ num: '0', persists: true });
}
}).done()
}
renderScene(route, navigator) {
console.log("ROUTE?", route)
if(route.name == 'FBLogin') {
return <FBLogin navigator={navigator} />
}
if(route.name === 'Main') {
return <Main navigator={navigator} />
}
if(route.name == 'Profile') {
return <Profile navigator={navigator} />
}
}
render() {
if (!this.state.persists) {
return <View><Spinner visible={true}/></View>
// return <View><Text>Loading...</Text></View>;
}
const routes = [
{name: 'FBLogin', index: 0},
{name: 'Main', index: 1},
{name: 'Profile', index: 2},
];
return ( <Navigator
initialRoute={routes[this.state.num]}
// initialRouteStack={routes}
configureScene={() => {
return Navigator.SceneConfigs.FadeAndroid;
}}
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('HumorUs', () => HumorUs);