-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppNavigation.js
94 lines (84 loc) · 2.54 KB
/
AppNavigation.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
import React, { Component } from 'react';
import ExplorePage from './ExplorePage';
import ArrowPage from './ArrowPage';
import { createAppContainer, createMaterialTopTabNavigator, createStackNavigator } from 'react-navigation';
import SettingsPage from './SettingsPage';
import PlacePage from './PlacePage';
import SwipeNavigationPageModel from './SwipeNavigationPageModel';
import { inject, observer } from 'mobx-react';
import { reaction } from 'mobx';
const stackNavigator = createStackNavigator({
Swipe: { screen: ArrowPage },
Settings: { screen: SettingsPage, },
Place: { screen: PlacePage }
},
{
initialRouteKey: 'Swipe',
});
// inject stores: https://github.com/mobxjs/mobx-react/issues/510
/*
inject(stores => {
console.log('stores: ' + stores);
return {
screenProps: {
...stores,
},
}
})(stackNavigator);
*/
// inject('swipeNavigationPageModel')(stackNavigator);
/*
stackNavigator.navigationOptions = ({ navigation, screenProps }) => {
// console.log('screensProps: ' + JSON.stringify(screenProps));
console.log('tabNavigationOptions: ' + JSON.stringify(navigation.state));
let enabled = true;
if (navigation.state.index === 0) {
if (navigation.state.routes[0].params) {
console.log('sc: ' + navigation.state.routes[0].params.swipeEnabled);
enabled = navigation.state.routes[0].params.swipeEnabled;
}
} else {
enabled = false; // prevent swipback to lead to wrong tab
}
return {
swipeEnabled: enabled
};
};
*/
/*
const tabs = createMaterialTopTabNavigator({
Explore: { screen: ExplorePage },
Arrow: { screen: stackNavigator }
},
{
initialRouteName: 'Arrow',
defaultNavigationOptions: { tabBarVisible: false },
swipeEnabled: true
}
);
*/
/*
tabs.navigationOptions = ({ navigation }) => { // can not access tabs navigationOptions from here
console.log('tabs');
};
*/
const AppContainer = createAppContainer(stackNavigator);
export default class AppNavigation extends Component {
/*
componentDidMount() {
this.reactionOnSwipeoutSwipeEnabledChange = reaction(() => this.props.swipeNavigationPageModel.scrollEnabled, (scrollEnabled, reaction) => {
console.log('reacted');
const { setParams } = AppContainer.
setParams({ swipeEnabled: scrollEnabled });
}, {});
}
componentWillUnmount() {
this.reactionOnSwipeoutSwipeEnabledChange();
}
*/
render() {
return (
<AppContainer />
);
}
}