-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
64 lines (57 loc) · 2.12 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
import React, { Component } from 'react';
import {AppRegistry, Navigator} from 'react-native';
import FavsIndex from "./components/favs/Index";
import NewFav from "./components/favs/New";
import TrainsIndex from "./components/trains/Index";
import About from "./components/About";
class App extends Component {
render(){
return (
<Navigator style={{ flex:1 }}
initialRoute={{ name: 'FAVS' }}
renderScene={ this.renderScene }
configureScene={ this.configureScene }
/>
);
}
// todo: iterate over a hash of nav routes and actions
renderScene(navRoute, navigator) {
switch (navRoute.name) {
case 'FAVS':
return <FavsIndex navigator={navigator} {...navRoute.params} />
break;
case 'NEW_FAV':
return <NewFav navigator={navigator} {...navRoute.params} />
break;
case 'TRAINS':
return <TrainsIndex navigator={navigator} {...navRoute.params} />
break;
case 'ABOUT':
return <About navigator={navigator} {...navRoute.params} />
break;
default:
console.error("UNRECOGNIZED ROUTE -- " + navRoute.name)
};
}
configureScene(navRoute, navRouteStack){
console.log('ROUTE:', navRoute.name)
if(navRouteStack){ console.log('ROUTE-STACK', `(${navRouteStack.length})`) } // navRouteStack.map(function(navRoute){ return navRoute.name})
switch (navRoute.transition) {
case 'Back':
return Navigator.SceneConfigs.FloatFromLeft;
break;
case 'Modal':
return Navigator.SceneConfigs.FloatFromBottomAndroid;
break;
default:
return Navigator.SceneConfigs.FadeAndroid;
};
}
componentWillMount(){ console.log("APP WILL MOUNT") }
componentDidMount(){ console.log("APP DID MOUNT") }
componentWillReceiveProps(nextProps){ console.log("APP WILL RECEIVE PROPS") }
componentWillUpdate(nextProps, nextState){ console.log("APP WILL UPDATE") }
componentDidUpdate(prevProps, prevState){ console.log("APP DID UPDATE") }
componentWillUnmount(){ console.log("APP WILL UNMOUNT") }
}
AppRegistry.registerComponent('NextTrainCT', () => App);