-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.android.js
75 lines (66 loc) · 1.89 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
View,
Navigator,
BackAndroid,
} from 'react-native';
var TopicView = require('./App/View/Topic/TopicView');
var MainScreen = require('./App/View/Main/MainScreen');
var TopicList = require('./App/View/Topic/TopicList');
var _navigator;
BackAndroid.addEventListener('hardwareBackPress', function () {
if (_navigator && _navigator.getCurrentRoutes().length > 1) {
_navigator.pop();
return true;
}
return false;
});
class V2exRN extends Component {
static routeMapper(route, navigator) {
_navigator = navigator;
var result;
switch (route.name) {
case 'main':
result = (<MainScreen navigator={navigator}/>);
break;
case 'node':
result = (<TopicList navigator={navigator} nodeId={route.nodeId} title={route.title}/>);
break;
case 'topic':
result = (
<View style={styles.container}>
<TopicView navigator={navigator} topic={route.topic} title={route.title}/>
</View>
);
break;
default:
break;
}
return result;
}
render() {
return (
<Navigator
style={styles.container}
initialRoute={{name: 'main'}}
configureScene={() => Navigator.SceneConfigs.FadeAndroid}
renderScene={(route, navigator) => V2exRN.routeMapper(route, navigator)}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
backgroundColor: '#F7F7F7',
}
});
AppRegistry.registerComponent('V2exRN', () => V2exRN);