99import React , { Component , Animated , PropTypes , StyleSheet , View , NavigationExperimental } from "react-native" ;
1010const {
1111 AnimatedView : NavigationAnimatedView ,
12- Card : NavigationCard
13- } = NavigationExperimental ;
14-
15- const {
16- CardStackPanResponder : NavigationCardStackPanResponder ,
17- CardStackStyleInterpolator : NavigationCardStackStyleInterpolator
18- } = NavigationCard ;
19-
12+ Card : NavigationCard ,
13+ RootContainer : NavigationRootContainer ,
14+ Header : NavigationHeader ,
15+ } = NavigationExperimental ;
2016import TabBar from "./TabBar" ;
2117import NavBar from "./NavBar" ;
2218import Actions from './Actions' ;
@@ -63,13 +59,13 @@ export default class DefaultRenderer extends Component {
6359 return null ;
6460 }
6561 let Component = navigationState . component ;
66- if ( navigationState . tabs && ! Component ) {
62+ if ( navigationState . tabs && ! Component ) {
6763 Component = TabBar ;
6864 }
6965 if ( Component ) {
7066 return (
7167 < View style = { [ { flex : 1 } , navigationState . sceneStyle ] } >
72- < Component { ...navigationState } navigationState = { navigationState } />
68+ < Component { ...navigationState } navigationState = { navigationState } />
7369 </ View >
7470 )
7571 }
@@ -79,6 +75,7 @@ export default class DefaultRenderer extends Component {
7975
8076 let applyAnimation = selected . applyAnimation || navigationState . applyAnimation ;
8177 let style = selected . style || navigationState . style ;
78+ let direction = selected . direction || navigationState . direction || "horizontal" ;
8279
8380 let optionals = { } ;
8481 if ( applyAnimation ) {
@@ -88,11 +85,7 @@ export default class DefaultRenderer extends Component {
8885 if ( duration === null || duration === undefined ) duration = navigationState . duration ;
8986 if ( duration !== null && duration !== undefined ) {
9087 optionals . applyAnimation = function ( pos , navState ) {
91- if ( duration === 0 ) {
92- pos . setValue ( navState . index ) ;
93- } else {
94- Animated . timing ( pos , { toValue : navState . index , duration} ) . start ( ) ;
95- }
88+ Animated . timing ( pos , { toValue : navState . index , duration} ) . start ( ) ;
9689 } ;
9790 }
9891 }
@@ -102,6 +95,7 @@ export default class DefaultRenderer extends Component {
10295 navigationState = { navigationState }
10396 style = { [ styles . animatedView , style ] }
10497 renderOverlay = { this . _renderHeader }
98+ direction = { direction }
10599 renderScene = { this . _renderCard }
106100 { ...optionals }
107101 />
@@ -110,40 +104,25 @@ export default class DefaultRenderer extends Component {
110104
111105 _renderHeader ( /*NavigationSceneRendererProps*/ props ) {
112106 return < NavBar
113- { ...props }
114- getTitle = { state => state . title }
115- /> ;
107+ { ...props }
108+ getTitle = { state => state . title }
109+ /> ;
116110 }
117111
118112 _renderCard ( /*NavigationSceneRendererProps*/ props ) {
119- const { key, direction, getSceneStyle} = props . scene . navigationState ;
120- let { panHandlers, animationStyle} = props . scene . navigationState ;
121-
122- // Since we always need to pass a style for the direction, we can avoid #526
123- let style = { } ;
124- if ( getSceneStyle ) style = getSceneStyle ( props ) ;
113+ const { key, direction, panHandlers, getSceneStyle } = props . scene . navigationState ;
125114
126- const isVertical = direction === "vertical" ;
127-
128- if ( typeof ( animationStyle ) === 'undefined' ) {
129- animationStyle = ( isVertical ?
130- NavigationCardStackStyleInterpolator . forVertical ( props ) :
131- NavigationCardStackStyleInterpolator . forHorizontal ( props ) ) ;
132- }
133-
134- if ( typeof ( panHandlers ) === 'undefined' ) {
135- panHandlers = panHandlers || ( isVertical ?
136- NavigationCardStackPanResponder . forVertical ( props ) :
137- NavigationCardStackPanResponder . forHorizontal ( props ) ) ;
138- }
115+ const optionals = { } ;
116+ if ( getSceneStyle ) optionals . style = getSceneStyle ( props ) ;
139117
140118 return (
141119 < NavigationCard
142120 { ...props }
143121 key = { 'card_' + key }
144- style = { [ animationStyle , style ] }
122+ direction = { direction || 'horizontal' }
145123 panHandlers = { panHandlers }
146124 renderScene = { this . _renderScene }
125+ { ...optionals }
147126 />
148127 ) ;
149128 }
@@ -157,6 +136,6 @@ export default class DefaultRenderer extends Component {
157136const styles = StyleSheet . create ( {
158137 animatedView : {
159138 flex : 1 ,
160- backgroundColor : "transparent"
139+ backgroundColor :"transparent"
161140 } ,
162141} ) ;
0 commit comments