-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppNavigator.js
92 lines (83 loc) · 2.16 KB
/
AppNavigator.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
'use strict';
var React = require('react-native');
var {
StyleSheet,
Navigator,
View,
BackAndroid,
} = React;
var NavBar = require('./js/view/NavBar')
var LandingPage = require('./js/view/LandingPage')
var LoginPage = require('./js/view/LoginPage')
var MyHomePage = require('./js/view/MyHomePage')
var MyNotifications = require('./js/view/MyNotifications')
var MySettings = require('./js/view/MySettings')
var _navigator;
BackAndroid.addEventListener('hardwareBackPress', () => {
if (_navigator && _navigator.getCurrentRoutes().length > 1) {
_navigator.pop();
return true;
}
return false;
});
var RouteMapper = function(route, navigationOperations, onComponentRef) {
_navigator = navigationOperations;
var showBackButton = true;
if (route.hideBackButton) {
showBackButton = false;
}
if (route.name === 'landing') {
return (
<LandingPage navigator={navigationOperations} />
);
} else if (route.name === 'login') {
return (
<View style={{flex: 1}}>
<NavBar title="邮件登陆"/>
<LoginPage navigator={navigationOperations} />
</View>
);
} else if (route.name === 'myhome') {
return (
<View style={{flex: 1}}>
<NavBar title="我的" />
<MyHomePage navigator={navigationOperations} />
</View>
);
} else if (route.name === 'myNotifications') {
return (
<View style={{flex: 1}}>
<NavBar title="通知" showBackButton='true' navigator={navigationOperations}/>
<MyNotifications navigator={navigationOperations} />
</View>
);
} else if (route.name === 'mySettings') {
return (
<View style={{flex: 1}}>
<NavBar title="设置" showBackButton='true' navigator={navigationOperations}/>
<MySettings navigator={navigationOperations} />
</View>
);
}
};
var AppNavigator = React.createClass({
propTypes: {
initialViewRoute: React.PropTypes.string,
},
render: function() {
return (
<Navigator
style={styles.container}
initialRoute={{name: this.props.initialViewRoute}}
configureScene={() => Navigator.SceneConfigs.PushFromRight}
renderScene={RouteMapper} />
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#eaeaea',
},
});
module.exports = AppNavigator;