-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
116 lines (101 loc) · 2.68 KB
/
index.android.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
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
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
ScrollView,
Navigator,
TabBarIOS,
Text,
View
} from 'react-native';
import QuestionDetailScreen from './app/screens/QuestionDetailScreen'
import QuestionListScreen from './app/screens/QuestionListScreen'
import ProfileScreen from './app/screens/ProfileScreen'
import LoginScreen from './app/screens/LoginScreen'
import Main from './app/screens/Main'
import SignUpScreen from './app/screens/SignUpScreen'
var bridges_client = require('./app/bridges_client');
var settings = require('./settings');
export default class Employable extends Component {
constructor() {
super();
this.state = {
initialIdent: "Login",
loading: true
};
}
_renderScene(route, navigator) {
var globalNavigatorProps = { navigator }
switch(route.ident) {
case "QuestionList":
return (
<QuestionListScreen
{...globalNavigatorProps} />
)
case "QuestionDetail":
return (
<QuestionDetailScreen
{...globalNavigatorProps}
question = {route.question} />
)
case "Profile":
return (
<ProfileScreen
{...globalNavigatorProps} />
)
case "Login":
return (
<LoginScreen
{...globalNavigatorProps} />
)
case "Main":
return (
<Main
{...globalNavigatorProps} />
)
case "SignUp":
return (
<SignUpScreen
{...globalNavigatorProps}
pageLayout={settings.signUpLayout}
currentPage={route.currentPage}/>
)
default:
return (
<LoginScreen
{...globalNavigatorProps} />
)
}
}
componentWillMount() {
bridges_client.getUserInfo(function(response) {
if (response.email) {
this.setState({initialIdent: "Main"});
}
this.setState({loading: false});
}.bind(this));
}
render() {
// If we have the proper token saved, lets just login
if (!this.state.loading) {
return (
<Navigator
initialRoute={{ident: this.state.initialIdent}}
ref="appNavigator"
renderScene={this._renderScene} />
);
} else {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text> Connecting to server... </Text>
</View>
);
}
}
}
AppRegistry.registerComponent('Employable', () => Employable);