NavigatorIOS - Remove NavigationContext
Reviewed By: fkgozali Differential Revision: D4774022 fbshipit-source-id: 0184bcbcf6a458eac6377cc6e1cffc0924f0d2d2
This commit is contained in:
parent
af34c3452f
commit
7aa2c9ab17
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
var EventEmitter = require('EventEmitter');
|
var EventEmitter = require('EventEmitter');
|
||||||
var Image = require('Image');
|
var Image = require('Image');
|
||||||
var NavigationContext = require('NavigationContext');
|
|
||||||
var RCTNavigatorManager = require('NativeModules').NavigatorManager;
|
var RCTNavigatorManager = require('NativeModules').NavigatorManager;
|
||||||
var React = require('React');
|
var React = require('React');
|
||||||
var ReactNative = require('ReactNative');
|
var ReactNative = require('ReactNative');
|
||||||
|
@ -499,7 +498,6 @@ var NavigatorIOS = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
navigator: (undefined: ?Object),
|
navigator: (undefined: ?Object),
|
||||||
navigationContext: new NavigationContext(),
|
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
// Precompute a pack of callbacks that's frequently generated and passed to
|
// Precompute a pack of callbacks that's frequently generated and passed to
|
||||||
|
@ -515,19 +513,14 @@ var NavigatorIOS = React.createClass({
|
||||||
resetTo: this.resetTo,
|
resetTo: this.resetTo,
|
||||||
popToRoute: this.popToRoute,
|
popToRoute: this.popToRoute,
|
||||||
popToTop: this.popToTop,
|
popToTop: this.popToTop,
|
||||||
navigationContext: this.navigationContext,
|
|
||||||
};
|
};
|
||||||
this._emitWillFocus(this.state.routeStack[this.state.observedTopOfStack]);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._emitDidFocus(this.state.routeStack[this.state.observedTopOfStack]);
|
|
||||||
this._enableTVEventHandler();
|
this._enableTVEventHandler();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
this.navigationContext.dispose();
|
|
||||||
this.navigationContext = new NavigationContext();
|
|
||||||
this._disableTVEventHandler();
|
this._disableTVEventHandler();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -608,7 +601,6 @@ var NavigatorIOS = React.createClass({
|
||||||
|
|
||||||
_handleNavigatorStackChanged: function(e: Event) {
|
_handleNavigatorStackChanged: function(e: Event) {
|
||||||
var newObservedTopOfStack = e.nativeEvent.stackLength - 1;
|
var newObservedTopOfStack = e.nativeEvent.stackLength - 1;
|
||||||
this._emitDidFocus(this.state.routeStack[newObservedTopOfStack]);
|
|
||||||
|
|
||||||
invariant(
|
invariant(
|
||||||
newObservedTopOfStack <= this.state.requestedTopOfStack,
|
newObservedTopOfStack <= this.state.requestedTopOfStack,
|
||||||
|
@ -661,14 +653,6 @@ var NavigatorIOS = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_emitDidFocus: function(route: Route) {
|
|
||||||
this.navigationContext.emit('didfocus', {route: route});
|
|
||||||
},
|
|
||||||
|
|
||||||
_emitWillFocus: function(route: Route) {
|
|
||||||
this.navigationContext.emit('willfocus', {route: route});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigate forward to a new route.
|
* Navigate forward to a new route.
|
||||||
* @param route The new route to navigate to.
|
* @param route The new route to navigate to.
|
||||||
|
@ -678,7 +662,6 @@ var NavigatorIOS = React.createClass({
|
||||||
// Make sure all previous requests are caught up first. Otherwise reject.
|
// Make sure all previous requests are caught up first. Otherwise reject.
|
||||||
if (this.state.requestedTopOfStack === this.state.observedTopOfStack) {
|
if (this.state.requestedTopOfStack === this.state.observedTopOfStack) {
|
||||||
this._tryLockNavigator(() => {
|
this._tryLockNavigator(() => {
|
||||||
this._emitWillFocus(route);
|
|
||||||
|
|
||||||
var nextStack = this.state.routeStack.concat([route]);
|
var nextStack = this.state.routeStack.concat([route]);
|
||||||
var nextIDStack = this.state.idStack.concat([getuid()]);
|
var nextIDStack = this.state.idStack.concat([getuid()]);
|
||||||
|
@ -709,7 +692,6 @@ var NavigatorIOS = React.createClass({
|
||||||
this._tryLockNavigator(() => {
|
this._tryLockNavigator(() => {
|
||||||
var newRequestedTopOfStack = this.state.requestedTopOfStack - n;
|
var newRequestedTopOfStack = this.state.requestedTopOfStack - n;
|
||||||
invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0');
|
invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0');
|
||||||
this._emitWillFocus(this.state.routeStack[newRequestedTopOfStack]);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
requestedTopOfStack: newRequestedTopOfStack,
|
requestedTopOfStack: newRequestedTopOfStack,
|
||||||
makingNavigatorRequest: true,
|
makingNavigatorRequest: true,
|
||||||
|
@ -758,8 +740,6 @@ var NavigatorIOS = React.createClass({
|
||||||
updatingAllIndicesAtOrBeyond: index,
|
updatingAllIndicesAtOrBeyond: index,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._emitWillFocus(route);
|
|
||||||
this._emitDidFocus(route);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue