-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.android.js
76 lines (70 loc) · 1.77 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
'use strict';
var React = require('react-native');
var {
AppRegistry,
BackAndroid,
Navigator,
StyleSheet,
View,
} = React;
var LoginScreen = require('./LoginScreen');
var ContactsScreen = require('./ContactsScreen');
var ChatScreen = require('./ChatScreen');
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;
if (route.name === 'login') {
return (
<LoginScreen
navigator = {navigationOperations}>
</LoginScreen>
);
} else if (route.name === 'contacts') {
return (
<ContactsScreen
navigator = {navigationOperations}
id = {route.id}
password = {route.password}
username = {route.username}>
</ContactsScreen>
);
} else if (route.name === 'chat') {
return (
<ChatScreen
navigator = {navigationOperations}
id = {route.id}
password = {route.password}
username = {route.username}
contactId = {route.contactId}
contactUsername = {route.contactUsername}>
</ChatScreen>
);
}
};
var Messenger = React.createClass({
render: function() {
var initialRoute = {name: 'login'};
return (
<Navigator
style = {styles.container}
initialRoute = {initialRoute}
configureScene = {() => Navigator.SceneConfigs.FadeAndroid}
renderScene = {RouteMapper} />
);
}
});
var styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
},
});
AppRegistry.registerComponent('Messenger', () => Messenger);
module.exports = Messenger;