-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ios.js
59 lines (48 loc) · 1.32 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
import React, { Component, PropTypes } from 'react';
import {
View,
StyleSheet,
AppRegistry,
NavigationExperimental,
} from 'react-native';
import ApplicationNavigator from './src/ApplicationNavigator';
const {
StateUtils: NavigationStateUtils,
} = NavigationExperimental;
class CardStackPanResponderExample extends Component {
constructor(props, context) {
super(props, context);
this.state = {
navigationState: {
index: 0,
key: 'root',
children: [{key: 'Home'}],
},
};
this._onNavigationChange = this._onNavigationChange.bind(this);
}
render() {
return (
<ApplicationNavigator
navigationState={this.state.navigationState}
onNavigate={this._onNavigationChange}
/>
);
}
_onNavigationChange(type, key = 'Home'): void {
let {navigationState} = this.state;
switch (type) {
case 'push':
const route = {key};
navigationState = NavigationStateUtils.push(navigationState, route);
break;
case 'pop':
navigationState = NavigationStateUtils.pop(navigationState);
break;
}
if (this.state.navigationState !== navigationState) {
this.setState({navigationState});
}
}
}
AppRegistry.registerComponent('CardStackPanResponderExample', () => CardStackPanResponderExample);