configureScene: add routeStack in second argument

Summary:
Giving routeStack in second parameter of configureScene allows to do more advanced scene configuration.
I have use-case where I can only determine the scene config from the navigation context (not only from the route object but also from where it's located).
Closes https://github.com/facebook/react-native/pull/5254

Reviewed By: svcscm

Differential Revision: D2828415

Pulled By: androidtrunkagent

fb-gh-sync-id: 27b6c79b24cbc194e080541e9202ca84c55a0bc4
This commit is contained in:
Gaëtan Renaudeau 2016-01-13 13:26:59 -08:00 committed by facebook-github-bot-3
parent 00659864bc
commit 1abd12b68b
1 changed files with 7 additions and 7 deletions

View File

@ -189,11 +189,11 @@ var Navigator = React.createClass({
propTypes: { propTypes: {
/** /**
* Optional function that allows configuration about scene animations and * Optional function that allows configuration about scene animations and
* gestures. Will be invoked with the route and should return a scene * gestures. Will be invoked with the route and the routeStack and should
* configuration object * return a scene configuration object
* *
* ``` * ```
* (route) => Navigator.SceneConfigs.FloatFromRight * (route, routeStack) => Navigator.SceneConfigs.FloatFromRight
* ``` * ```
*/ */
configureScene: PropTypes.func, configureScene: PropTypes.func,
@ -293,7 +293,7 @@ var Navigator = React.createClass({
} }
return { return {
sceneConfigStack: routeStack.map( sceneConfigStack: routeStack.map(
(route) => this.props.configureScene(route) (route) => this.props.configureScene(route, routeStack)
), ),
routeStack, routeStack,
presentedIndex: initialRouteIndex, presentedIndex: initialRouteIndex,
@ -368,7 +368,7 @@ var Navigator = React.createClass({
this.setState({ this.setState({
routeStack: nextRouteStack, routeStack: nextRouteStack,
sceneConfigStack: nextRouteStack.map( sceneConfigStack: nextRouteStack.map(
this.props.configureScene route => this.props.configureScene(route, nextRouteStack)
), ),
presentedIndex: destIndex, presentedIndex: destIndex,
activeGesture: null, activeGesture: null,
@ -913,7 +913,7 @@ var Navigator = React.createClass({
var nextStack = activeStack.concat([route]); var nextStack = activeStack.concat([route]);
var destIndex = nextStack.length - 1; var destIndex = nextStack.length - 1;
var nextAnimationConfigStack = activeAnimationConfigStack.concat([ var nextAnimationConfigStack = activeAnimationConfigStack.concat([
this.props.configureScene(route), this.props.configureScene(route, nextStack),
]); ]);
this._emitWillFocus(nextStack[destIndex]); this._emitWillFocus(nextStack[destIndex]);
this.setState({ this.setState({
@ -981,7 +981,7 @@ var Navigator = React.createClass({
var nextRouteStack = this.state.routeStack.slice(); var nextRouteStack = this.state.routeStack.slice();
var nextAnimationModeStack = this.state.sceneConfigStack.slice(); var nextAnimationModeStack = this.state.sceneConfigStack.slice();
nextRouteStack[index] = route; nextRouteStack[index] = route;
nextAnimationModeStack[index] = this.props.configureScene(route); nextAnimationModeStack[index] = this.props.configureScene(route, nextRouteStack);
if (index === this.state.presentedIndex) { if (index === this.state.presentedIndex) {
this._emitWillFocus(route); this._emitWillFocus(route);