-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.android.js
executable file
·71 lines (65 loc) · 1.82 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
/**
* IOS 入口文件
*/
'use strict';
var React = require('react-native');
var { AppRegistry, Navigator, StyleSheet, View, ToolbarAndroid,
BackAndroid,
} = React;
var StoryList = require('./views/StoryList.react');
var StoryDetail = require('./views/StoryDetail.react');
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;
switch(route.name){
case 'storyList':
return (
<StoryList navigator={navigationOperations} />
);
case 'storyDetail':
return (
<View style={{flex:1}}>
<ToolbarAndroid
actions={[]}
navIcon={require('./images/icon-back.imageset/icon-back.png')}
onIconClicked={navigationOperations.pop}
style={styles.toolbar}
titleColor="#fff"
title={route.title} />
<StoryDetail
navigator={navigationOperations}
detailId={route.detailId} />
</View>
);
}
};
var ReactNativeWeb = React.createClass({
render: function(){
var initialRoute = {name: 'storyList'};
return (
<Navigator
style={styles.container}
initialRoute={initialRoute}
renderScene={RouteMapper}
/>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
toolbar: {
backgroundColor: '#333',
height: 56,
},
});
AppRegistry.registerComponent('ReactNativeWeb', () => ReactNativeWeb);