forked from cyqresig/ReactNativeComponentDemos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
114 lines (99 loc) · 2.64 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
109
110
111
112
113
114
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Navigator,
Text,
TouchableOpacity,
} from 'react-native';
import ReactNativeComponentList from './examples/android/react-native-component-list'
import SplashScreen from 'react-native-smart-splash-screen'
class ReactNativeComponentDemos extends Component {
constructor (props, context) {
super(props);
}
componentDidMount () {
SplashScreen.close({
animationType: SplashScreen.animationType.scale,
duration: 1000,
delay: 500,
})
}
render () {
return (
<Navigator style={styles.container}
initialRoute={{
component: ReactNativeComponentList,
title: 'React Native Component Demos'
}}
sceneStyle={styles.navigatorBg}
renderScene={(route, navigator) => {
let Component = route.component;
return (
<Component
navigator={navigator}
{...route.passProps}
/>
)}}
navigationBar={
<Navigator.NavigationBar
ref={(navigationBar) => {
this.navigationBar = navigationBar
}}
routeMapper={NavigationBarRouteMapper}
style={styles.navBar} /> }
/>
)
}
}
let NavigationBarRouteMapper = {
LeftButton: function (route, navigator, index, navState) {
if (index === 0) {
return null;
}
var previousRoute = navState.routeStack[ index - 1 ];
return (
<TouchableOpacity
onPress={() => navigator.pop()}
style={styles.navBarLeftButton}>
<Text style={[styles.navBarText, styles.navBarButtonText]}>
back
</Text>
</TouchableOpacity>
);
},
RightButton: function (route, navigator, index, navState) {
return null
},
Title: function (route, navigator, index, navState) {
return (
<Text style={[styles.navBarText, styles.navBarTitleText]}>
{route.title}
</Text>
)
},
};
const styles = StyleSheet.create({
navigatorBg: {
backgroundColor: '#F4F4F4',
},
navBar: {
backgroundColor: 'black',
},
navBarText: {
fontSize: 16,
margin: 10,
color: 'white',
},
navBarTitleText: {
color: 'white',
fontWeight: '500',
marginVertical: 9,
},
})
AppRegistry.registerComponent('ReactNativeComponentDemos', () => ReactNativeComponentDemos);