-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
96 lines (85 loc) · 2.83 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
/*
* Guess Game
* Starter app show-casing react native app handling view routing, lists
* and external links
*/
import React, { Component } from 'react';
import { AppRegistry,
Text,
Navigator,
TouchableHighlight
} from 'react-native';
import HomeView from './app/components/HomeView';
import SettingsView from './app/components/SettingsView';
import styles from './app/styles/styles';
export default class GuessGame extends Component {
render() {
return (
<Navigator
initialRoute={{ title: 'Home', id: 'home' }}
renderScene={ this.navigatorRenderScene }
sceneStyle={{marginTop: Navigator.NavigationBar.Styles.General.NavBarHeight}}
navigationBar={
<Navigator.NavigationBar
routeMapper={{
LeftButton: (route, navigator, index, navState) => {
if (route.id === 'home') {
return null;
} else {
return (
<TouchableHighlight onPress={() => navigator.pop()}>
<Text style={styles.headerItem}>←</Text>
</TouchableHighlight>
);
}
},
Title: (route, navigator, index, navState) => {
return (
<Text style={styles.headerItem}>{route.title}</Text>
);
},
RightButton: (route, navigator, index, navState) => {
if (route.id === 'settings') {
return null;
} else {
return (
<TouchableHighlight onPress={() =>
navigator.push({title: 'App settings', id: 'settings'})}>
<Text style={styles.headerItem}>Next</Text>
</TouchableHighlight>
);
}
}
}}
style={{backgroundColor: 'darkcyan'}}
/>
}
/>
);
}
navigatorRenderScene(route, navigator) {
switch (route.id) {
case 'home':
return (<HomeView
title={route.title}
onForward={() => {
navigator.push({
title: 'List',
id: 'list',
});
}}
/>);
case 'settings':
return (<SettingsView
title={route.title}
onForward={() => {
navigator.push({
title: 'Home',
id: 'home',
});
}}
/>);
}
}
}
AppRegistry.registerComponent('GuessGame', () => GuessGame);