-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
143 lines (125 loc) · 4.11 KB
/
index.ios.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Navigator,
LinkingIOS,
TouchableOpacity
} = React;
var EventsList = require("./src/components/EventsList")
var EventDetail = require("./src/components/EventDetail")
var MapsList = require("./src/components/MapsList")
require("./src/reactions/Reactions")
var ResultsIndex = require("./src/components/ResultsIndex")
var ResultsByCategory = require("./src/components/ResultsByCategory")
var ResultsByRunner = require("./src/components/ResultsByRunner")
var ResultsByLeg = require("./src/components/ResultsByLeg")
var AboutPage = require("./src/components/About")
var style = require("./src/styles/IosIndexStyle")
var app = require("./src/App")
var _navigator = null;
app.on("openUrl").subscribe(function(url) {
LinkingIOS.openURL(url);
});
var NavigationBarRouteMapper = {
RightButton: function(route, navigator, index, navState) {
if(route.name == "index") {
return <TouchableOpacity onPress={() => app.emit("openAboutPage")}>
<Text style={style.titleBarButton}>
Über MyOApp
</Text>
</TouchableOpacity>
}
return null;
},
LeftButton: function(route, navigator, index, navState) {
if (index === 0) {
return null;
}
var previousRoute = navState.routeStack[index - 1];
return (
<TouchableOpacity
onPress={() => navigator.pop()}>
<Text style={style.titleBarButton}>
Zurück
</Text>
</TouchableOpacity>
);
},
Title: function(route, navigator, index, navState) {
return (
<Text style={style.titleBarTitle}>
{route.title}
</Text>
);
},
};
var MyOAppReact = React.createClass({
navigator: null,
navigationBar: null,
renderScene: function(route, navigationOperations, onComponentRef) {
_navigator = navigationOperations;
app.setNavigator(_navigator);
switch(route.name) {
case "index":
if(this.navigationBar) {
this.navigationBar.setState({title: "MyOApp", showBack: false})
}
return <EventsList />
case "eventDetail":
//this.navigationBar.setState({title: route.event.name, showBack: true})
return <EventDetail event={route.event} />
case "mapsList":
//this.navigationBar.setState({title: "Karten: " + route.event.map, showBack: true})
return <MapsList event={route.event} />
case "resultsIndex":
return <ResultsIndex event={route.event} />
case "resultsByCategory":
return <ResultsByCategory category={route.category} results={route.results} />
case "resultsByRunner":
return <ResultsByRunner results={route.results} runner={route.runner} category={route.category} />
case "resultsByLeg":
return <ResultsByLeg results={route.results} leg={route.leg} category={route.category} />
case "about":
return <AboutPage />
}
},
getInitialState: function() {
return {title: 'MyOApp'}
},
componentDidMount: function() {
},
onBack: function() {
this.navigator.pop();
},
render: function() {
var firstRoute = {
name: 'index',
title: "MyOApp"
};
return (<View style={{flex: 1}}>
<Navigator
initialRoute={firstRoute}
configureScene={() => Navigator.SceneConfigs.FloatFromBottom}
renderScene={this.renderScene}
ref={n => this.navigator = n}
sceneStyle={style.scene}
navigationBar={
<Navigator.NavigationBar
routeMapper={NavigationBarRouteMapper}
style={style.titleBar}
/>
}
/>
</View>
);
}
});
AppRegistry.registerComponent('MyOAppReact', () => MyOAppReact);