@@ -5,6 +5,7 @@ import { NavigationExperimental, View } from 'react-native';
5
5
import { warnOutOfSync } from './warningUtil' ;
6
6
import transitionRegistry from './transitionRegistry' ;
7
7
import { globalStyles as styles } from './styles' ;
8
+ import withRouter from './withRouter' ;
8
9
9
10
import type {
10
11
EnhancedNavigationRoute ,
@@ -25,6 +26,7 @@ type Props = {
25
26
navigationSubtree : ?Array < PseudoElement > ,
26
27
navigationState : EnhancedNavigationRoute ,
27
28
createElement : Function ,
29
+ router : Object ,
28
30
} ;
29
31
30
32
class TabsRouteView extends Component < any , Props , any > {
@@ -37,6 +39,7 @@ class TabsRouteView extends Component<any, Props, any> {
37
39
navigationSubtree : PropTypes . arrayOf ( PropTypes . object ) ,
38
40
navigationState : PropTypes . object ,
39
41
createElement : PropTypes . func . isRequired ,
42
+ router : PropTypes . object . isRequired ,
40
43
} ;
41
44
42
45
componentWillMount ( ) : void {
@@ -46,8 +49,7 @@ class TabsRouteView extends Component<any, Props, any> {
46
49
( this : any ) . renderCardScene = this . renderCardScene . bind ( this ) ;
47
50
}
48
51
49
- // $FlowFixMe NavigationSceneRendererProps
50
- renderOverlay ( props ) : ?ReactElement {
52
+ renderOverlay ( props : Object ) : ?ReactElement < any > {
51
53
const { scene } = props ;
52
54
53
55
const { navigationSubtree , createElement } = this . props ;
@@ -80,16 +82,19 @@ class TabsRouteView extends Component<any, Props, any> {
80
82
return null ;
81
83
}
82
84
83
- // $FlowFixMe NavigationSceneRendererProps
84
- renderScene ( props ) : ?ReactElement {
85
+ renderScene ( props : Object ) : ?ReactElement < any > {
85
86
const { scene } = props ;
86
87
87
88
if ( ! scene . route ) {
88
89
return null ;
89
90
}
90
91
91
92
const { transition : parentTransition } = props . navigationState ;
92
- const { transition : sceneTransition } = scene . route ;
93
+ const {
94
+ transition : sceneTransition ,
95
+ onSwipeBack,
96
+ onSwipeForward,
97
+ } = scene . route ;
93
98
94
99
const transition = sceneTransition || parentTransition ;
95
100
@@ -98,8 +103,16 @@ class TabsRouteView extends Component<any, Props, any> {
98
103
panResponder,
99
104
} = transitionRegistry [ transition ] ;
100
105
106
+ const {
107
+ router,
108
+ } = this . props ;
109
+
101
110
const viewStyle = styleInterpolator ( props ) ;
102
- const panHandlers = panResponder ( props ) ;
111
+ const panHandlers = panResponder ( {
112
+ ...props ,
113
+ onNavigateBack : ( ) => onSwipeBack && onSwipeBack ( router ) ,
114
+ onNavigateForward : ( ) => onSwipeForward && onSwipeForward ( router ) ,
115
+ } ) ;
103
116
104
117
const navigationCardProps = {
105
118
key : scene . route . key ,
@@ -112,8 +125,7 @@ class TabsRouteView extends Component<any, Props, any> {
112
125
return React . createElement ( NavigationCard , navigationCardProps ) ;
113
126
}
114
127
115
- // $FlowFixMe NavigationSceneRendererProps
116
- renderCardScene ( props ) : ?ReactElement {
128
+ renderCardScene ( props : Object ) : ?ReactElement < any > {
117
129
const { scene } = props ;
118
130
119
131
const { navigationSubtree } = this . props ;
@@ -213,4 +225,4 @@ class TabsRouteView extends Component<any, Props, any> {
213
225
}
214
226
}
215
227
216
- export default TabsRouteView ;
228
+ export default withRouter ( TabsRouteView ) ;
0 commit comments