-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.android.js
108 lines (100 loc) · 2.78 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var Catalog = require('./android/app/components/Catalog');
var Details = require('./android/app/components/Details');
var Reader = require('./android/app/components/Reader');
var MyBooks = require('./android/app/components/MyBooks');
var Login = require('./android/app/components/Login');
var StatusBarAndroid = require('react-native-android-statusbar');
var {
AppRegistry,
BackAndroid,
Navigator,
StyleSheet,
ToolbarAndroid,
View,
} = React;
var _navigator;
StatusBarAndroid.setHexColor('#B71C1C');
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 === 'catalog') {
return (
<Catalog navigator={navigationOperations} />
);
} else if (route.name === 'mybooks') {
return (
<MyBooks navigator={navigationOperations} />
);
} else if (route.name === 'login') {
return (
<Login navigator={navigationOperations} />
);
} else if (route.name === 'details') {
return (
<View style={{flex: 1}}>
<ToolbarAndroid
actions={[]}
navIcon={require('image!android_back_white')}
onIconClicked={navigationOperations.pop}
style={styles.toolbar}
titleColor="white"
title={route.book.title} />
<Details
style={{flex: 1}}
navigator={navigationOperations}
book={route.book} />
</View>
);
} else if (route.name === 'reader') {
return (
<View style={{flex: 1}}>
<ToolbarAndroid
actions={[]}
navIcon={require('image!android_back_white')}
onIconClicked={navigationOperations.pop}
style={styles.toolbar}
titleColor="white"
title={route.book.title} />
<Reader
style={{flex: 1}}
navigator={navigationOperations}
book={route.book} />
</View>
);
}
};
var ReactNativeCouchbaseLiteExample = 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: {
flex: 1,
backgroundColor: 'white',
},
toolbar: {
backgroundColor: '#a9a9a9',
height: 56,
},
});
AppRegistry.registerComponent('ReactNativeCouchbaseLiteExample', () => ReactNativeCouchbaseLiteExample);