[ReactNative] Navigator de-contextualize popToRoute
This commit is contained in:
parent
62c556c785
commit
5bad316678
|
@ -340,14 +340,13 @@ var Navigator = React.createClass({
|
|||
getCurrentRoutes: this.getCurrentRoutes,
|
||||
// `route` is injected by NavigatorStaticContextContainer
|
||||
|
||||
// Contextual nav actions
|
||||
// Contextual nav action
|
||||
pop: this.requestPop,
|
||||
popToRoute: this.requestPopTo,
|
||||
|
||||
// Legacy, imperitive nav actions. Will transition these to contextual actions
|
||||
jumpBack: this.jumpBack,
|
||||
jumpForward: this.jumpForward,
|
||||
jumpTo: this.jumpTo,
|
||||
popToRoute: this.popToRoute,
|
||||
push: this.push,
|
||||
replace: this.replace,
|
||||
replaceAtIndex: this.replaceAtIndex,
|
||||
|
@ -410,8 +409,6 @@ var Navigator = React.createClass({
|
|||
switch (action) {
|
||||
case 'pop':
|
||||
return this._handlePop(arg1);
|
||||
case 'popTo':
|
||||
return this._handlePopTo(arg1);
|
||||
case 'push':
|
||||
return this._handlePush(arg1);
|
||||
default:
|
||||
|
@ -440,23 +437,6 @@ var Navigator = React.createClass({
|
|||
return true;
|
||||
},
|
||||
|
||||
_handlePopTo: function(destRoute) {
|
||||
if (destRoute) {
|
||||
var hasRoute = this.state.routeStack.indexOf(destRoute) !== -1;
|
||||
if (hasRoute) {
|
||||
this.popToRoute(destRoute);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.state.presentedIndex === 0) {
|
||||
return false;
|
||||
}
|
||||
this.pop();
|
||||
return true;
|
||||
},
|
||||
|
||||
_handlePush: function(route) {
|
||||
this.push(route);
|
||||
return true;
|
||||
|
@ -1155,17 +1135,13 @@ var Navigator = React.createClass({
|
|||
this.popToRoute(this.state.routeStack[0]);
|
||||
},
|
||||
|
||||
_getNumToPopForRoute: function(route) {
|
||||
popToRoute: function(route) {
|
||||
var indexOfRoute = this.state.routeStack.indexOf(route);
|
||||
invariant(
|
||||
indexOfRoute !== -1,
|
||||
'Calling pop to route for a route that doesn\'t exist!'
|
||||
'Calling popToRoute for a route that doesn\'t exist!'
|
||||
);
|
||||
return this.state.presentedIndex - indexOfRoute;
|
||||
},
|
||||
|
||||
popToRoute: function(route) {
|
||||
var numToPop = this._getNumToPopForRoute(route);
|
||||
var numToPop = this.state.presentedIndex - indexOfRoute;
|
||||
this._popN(numToPop);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue