Fixed navigation events

This commit is contained in:
Hristo Hristov
2016-03-18 11:53:36 +02:00
parent 7458880f28
commit 2cabf02215
19 changed files with 408 additions and 236 deletions

2
ui/core/view.d.ts vendored
View File

@@ -471,7 +471,7 @@ declare module "ui/core/view" {
* @param callback An optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed.
* @param thisArg An optional parameter which when set will be used to refine search of the correct callback which will be removed as event listener.
*/
off(eventNames: string | gestures.GestureTypes, callback?: any, thisArg?: any);
off(eventNames: string | gestures.GestureTypes, callback?: (data: observable.EventData) => void, thisArg?: any);
/**
* Raised when a loaded event occurs.

View File

@@ -231,7 +231,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
var entry = this._navigationQueue[0].entry;
var currentNavigationPage = entry.resolvedPage;
if (page !== currentNavigationPage) {
throw new Error(`Corrupted navigation stack; page: ${page.id}; currentNavigationPage: ${currentNavigationPage.id}`);
throw new Error(`Corrupted navigation stack; page: ${page}; currentNavigationPage: ${currentNavigationPage}`);
}
// remove completed operation.
@@ -275,7 +275,6 @@ export class Frame extends CustomLayoutView implements definition.Frame {
private performNavigation(navigationContext: NavigationContext) {
var navContext = navigationContext.entry;
this._onNavigatingTo(navContext, navigationContext.isBackNavigation);
// TODO: This should happen once navigation is completed.
if (navigationContext.entry.entry.clearHistory) {
@@ -285,15 +284,15 @@ export class Frame extends CustomLayoutView implements definition.Frame {
this._backStack.push(this._currentEntry);
}
this._onNavigatingTo(navContext, navigationContext.isBackNavigation);
this._navigateCore(navContext);
this._onNavigatedTo(navContext, false);
}
private performGoBack(navigationContext: NavigationContext) {
var navContext = navigationContext.entry;
this._onNavigatingTo(navContext, navigationContext.isBackNavigation);
this._goBackCore(navContext);
this._onNavigatedTo(navContext, true);
}
public _goBackCore(backstackEntry: definition.BackstackEntry) {
@@ -312,12 +311,6 @@ export class Frame extends CustomLayoutView implements definition.Frame {
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack);
}
public _onNavigatedTo(backstackEntry: definition.BackstackEntry, isBack: boolean) {
if (this.currentPage) {
this.currentPage.onNavigatedFrom(isBack);
}
}
public get animated(): boolean {
return this._animated;
}

View File

@@ -31,13 +31,16 @@ export class Frame extends frameCommon.Frame {
constructor() {
super();
this._ios = new iOSFrame(this);
// When there is a 40px high "in-call" status bar, nobody moves the navigationBar top from 20 to 40 and it remains underneath the status bar.
var that = this;
let frameRef = new WeakRef(this);
application.ios.addNotificationObserver(UIApplicationDidChangeStatusBarFrameNotification, (notification: NSNotification) => {
that._handleHigherInCallStatusBarIfNeeded();
if (this._ios.controller.owner.currentPage) {
this._ios.controller.owner.currentPage.requestLayout();
let frame = frameRef.get();
if (frame) {
frame._handleHigherInCallStatusBarIfNeeded();
if (frame.currentPage) {
frame.currentPage.requestLayout();
}
}
});
}
@@ -61,7 +64,7 @@ export class Frame extends frameCommon.Frame {
}
public _navigateCore(backstackEntry: definition.BackstackEntry) {
trace.write(`${this}._navigateCore(pageId: ${backstackEntry.resolvedPage.id}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry) }, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
trace.write(`${this}._navigateCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
var viewController: UIViewController = backstackEntry.resolvedPage.ios;
if (!viewController) {
throw new Error("Required page does not have a viewController created.");
@@ -132,7 +135,7 @@ export class Frame extends frameCommon.Frame {
public _goBackCore(backstackEntry: definition.BackstackEntry) {
navDepth = backstackEntry[NAV_DEPTH];
trace.write(`${this}._goBackCore(pageId: ${backstackEntry.resolvedPage.id}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry) }, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
trace.write(`${this}._goBackCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
if (!this._shouldSkipNativePop) {
var controller = backstackEntry.resolvedPage.ios;
@@ -292,6 +295,10 @@ export class Frame extends frameCommon.Frame {
}
}
public _onNavigatingTo(backstackEntry: definition.BackstackEntry, isBack: boolean) {
//
}
_handleHigherInCallStatusBarIfNeeded() {
let statusBarHeight = uiUtils.ios.getStatusBarHeight();
if (!this._ios ||
@@ -391,100 +398,6 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
}
}
public navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
trace.write(`UINavigationControllerImpl.navigationControllerWillShowViewControllerAnimated(${navigationController}, ${viewController}, ${animated})`, trace.categories.NativeLifecycle);
// In this method we need to layout the new page otherwise page will be shown empty and update after that which is bad UX.
let frame = this._owner.get();
if (!frame) {
return;
}
let newEntry: definition.BackstackEntry = viewController[ENTRY];
let newPage = newEntry.resolvedPage;
if (!newPage.parent) {
if (!frame._currentEntry) {
// First navigation
frame._currentEntry = newEntry;
}
else {
frame._navigateToEntry = newEntry;
}
frame._addView(newPage);
frame.remeasureFrame();
}
else if (newPage.parent !== frame) {
throw new Error("Page is already shown on another frame.");
}
newPage.actionBar.update();
//HACK: https://github.com/NativeScript/NativeScript/issues/1021
viewController["willShowCalled"] = true;
}
public navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
trace.write(`UINavigationControllerImpl.navigationControllerDidShowViewControllerAnimated(${navigationController}, ${viewController}, ${animated})`, trace.categories.NativeLifecycle);
//HACK: https://github.com/NativeScript/NativeScript/issues/1021
if (viewController["willShowCalled"] === undefined) {
return;
}
else {
viewController["willShowCalled"] = undefined;
}
let frame = this._owner.get();
if (!frame) {
return;
}
let newEntry: definition.BackstackEntry = viewController[ENTRY];
let newPage = newEntry.resolvedPage;
let backStack = frame.backStack;
let currentEntry = backStack.length > 0 ? backStack[backStack.length - 1] : null;
// This code check if navigation happened through UI (e.g. back button or swipe gesture).
// When calling goBack on frame isBack will be false.
let isBack: boolean = currentEntry && newEntry === currentEntry;
let currentNavigationContext;
let navigationQueue = (<any>frame)._navigationQueue;
for (let i = 0; i < navigationQueue.length; i++) {
if (navigationQueue[i].entry === newEntry) {
currentNavigationContext = navigationQueue[i];
break;
}
}
let isBackNavigation = currentNavigationContext ? currentNavigationContext.isBackNavigation : false;
if (isBack) {
try {
frame._shouldSkipNativePop = true;
frame.goBack();
}
finally {
frame._shouldSkipNativePop = false;
}
}
let page = frame.currentPage;
if (page && !navigationController.viewControllers.containsObject(page.ios)) {
frame._removeView(page);
}
frame._navigateToEntry = null;
frame._currentEntry = newEntry;
frame.remeasureFrame();
frame._updateActionBar(newPage);
// notify the page
newPage.onNavigatedTo(isBack || isBackNavigation);
frame._processNavigationQueue(newPage);
}
public supportedInterfaceOrientation(): number {
return UIInterfaceOrientationMask.UIInterfaceOrientationMaskAll;
}
@@ -672,25 +585,25 @@ function _getNativeTransition(navigationTransition: definition.NavigationTransit
return null;
}
export function _getNativeCurve(transition: definition.NavigationTransition) : UIViewAnimationCurve{
export function _getNativeCurve(transition: definition.NavigationTransition): UIViewAnimationCurve {
if (transition.curve) {
switch (transition.curve) {
case enums.AnimationCurve.easeIn:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseIn.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseIn;
case enums.AnimationCurve.easeOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseOut.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseOut;
case enums.AnimationCurve.easeInOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseInOut.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseInOut;
case enums.AnimationCurve.linear:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveLinear.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveLinear;
default:
trace.write("Transition curve resolved to original: " + transition.curve, trace.categories.Transition);
return transition.curve;
}
switch (transition.curve) {
case enums.AnimationCurve.easeIn:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseIn.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseIn;
case enums.AnimationCurve.easeOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseOut.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseOut;
case enums.AnimationCurve.easeInOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseInOut.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveEaseInOut;
case enums.AnimationCurve.linear:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveLinear.", trace.categories.Transition);
return UIViewAnimationCurve.UIViewAnimationCurveLinear;
default:
trace.write("Transition curve resolved to original: " + transition.curve, trace.categories.Transition);
return transition.curve;
}
}
return UIViewAnimationCurve.UIViewAnimationCurveEaseInOut;

View File

@@ -57,7 +57,7 @@ export class Page extends ContentView implements dts.Page {
private _styleScope: styleScope.StyleScope = new styleScope.StyleScope();
private _actionBar: ActionBar;
private _modal: Page;
public _modal: Page;
constructor(options?: dts.Options) {
super(options);
@@ -206,18 +206,20 @@ export class Page extends ContentView implements dts.Page {
this._navigationContext = undefined;
}
public showModal() {
public showModal(): Page {
ensureFrame();
if (arguments.length === 0) {
this._showNativeModalView(<any>frame.topmost().currentPage, undefined, undefined, true);
return this;
} else {
var moduleName: string = arguments[0];
var context: any = arguments[1];
var closeCallback: Function = arguments[2];
var fullscreen: boolean = arguments[3];
var page = frame.resolvePageFromEntry({ moduleName: moduleName });
(<Page>page)._showNativeModalView(this, context, closeCallback, fullscreen);
var page = <Page>frame.resolvePageFromEntry({ moduleName: moduleName });
page._showNativeModalView(this, context, closeCallback, fullscreen);
return page;
}
}
@@ -255,7 +257,7 @@ export class Page extends ContentView implements dts.Page {
}
protected _hideNativeModalView(parent: Page) {
parent._modal = undefined;
//
}
protected _raiseShownModallyEvent(parent: Page, context: any, closeCallback: Function) {

View File

@@ -166,6 +166,7 @@ export class Page extends pageCommon.Page {
this.onUnloaded();
this._isAddedToNativeVisualTree = false;
this._onDetached(true);
parent._modal = undefined;
super._hideNativeModalView(parent);
}

18
ui/page/page.d.ts vendored
View File

@@ -141,32 +141,32 @@ declare module "ui/page" {
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any): void;
/**
* Raised when navigation to the page has started.
*/
on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any);
on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any): void;
/**
* Raised when navigation to the page has finished.
*/
on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any);
on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any): void;
/**
* Raised when navigation from the page has started.
*/
on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any);
on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any): void;
/**
* Raised when navigation from the page has finished.
*/
on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any);
on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any): void;
/**
* Raised before the page is shown as a modal dialog.
*/
on(event: "showingModally", callback: (args: observable.EventData) => void, thisArg?: any);
on(event: "showingModally", callback: (args: observable.EventData) => void, thisArg?: any): void;
/**
* Raised after the page is shown as a modal dialog.
@@ -180,17 +180,17 @@ declare module "ui/page" {
* @param closeCallback - A function that will be called when the page is closed. Any arguments provided when calling ShownModallyData.closeCallback will be available here.
* @param fullscreen - An optional parameter specifying whether to show the modal page in full-screen mode.
*/
showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean);
showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean): Page;
/**
* Shows the page as a modal view.
*/
showModal();
showModal(): Page;
/**
* Closes the current modal view that this page is showing.
*/
closeModal();
closeModal(): void;
/**
* Returns the current modal view that this page is showing (is parent of), if any.

View File

@@ -8,6 +8,27 @@ import {device} from "platform";
import {DeviceType} from "ui/enums";
global.moduleMerge(pageCommon, exports);
var ENTRY = "_entry";
function isBackNavigation(frame: any, entry): boolean {
if (!frame) {
return false;
}
if (frame._navigationQueue.length === 0) {
return true;
}
else {
var navigationQueue = frame._navigationQueue;
for (var i = 0; i < navigationQueue.length; i++) {
if (navigationQueue[i].entry === entry) {
return navigationQueue[i].isBackNavigation;
}
}
}
return false;
}
class UIViewControllerImpl extends UIViewController {
@@ -31,7 +52,7 @@ class UIViewControllerImpl extends UIViewController {
return;
}
if (owner._isModal) {
if (owner._modalParent) {
let isTablet = device.deviceType === DeviceType.Tablet;
let isFullScreen = !owner._UIModalPresentationFormSheet || !isTablet;
let frame = isFullScreen ? UIScreen.mainScreen().bounds : this.view.frame;
@@ -85,54 +106,151 @@ class UIViewControllerImpl extends UIViewController {
}
}
public viewWillAppear() {
let owner = this._owner.get();
if (!owner) {
public viewWillAppear(animated: boolean): void {
let page = this._owner.get();
trace.write(page + " viewWillAppear", trace.categories.Navigation);
if (!page) {
return;
}
trace.write(owner + " viewWillAppear", trace.categories.Navigation);
owner._enableLoadedEvents = true;
let frame = this.navigationController ? (<any>this.navigationController).owner : null;
let newEntry = this[ENTRY];
// Don't raise event if currentPage was showing modal page.
if (!page.modal && newEntry && (!frame || frame.currentPage !== page)) {
let isBack = isBackNavigation(frame, newEntry)
page.onNavigatingTo(newEntry.entry.context, isBack);
}
if (frame) {
if (!page.parent) {
if (!frame._currentEntry) {
frame._currentEntry = newEntry;
} else {
frame._navigateToEntry = newEntry;
}
frame._addView(page);
frame.remeasureFrame();
} else if (page.parent !== frame) {
throw new Error("Page is already shown on another frame.");
}
page.actionBar.update();
}
//https://github.com/NativeScript/NativeScript/issues/1201
owner._viewWillDisappear = false;
owner.onLoaded();
owner._enableLoadedEvents = false;
page._viewWillDisappear = false;
page._enableLoadedEvents = true;
// If page was in backstack or showing modal page it will have parent but it will be in unloaded state so raise loaded here.
if (!page.isLoaded) {
page.onLoaded();
}
page._enableLoadedEvents = false;
}
public viewWillDisappear() {
let owner = this._owner.get();
if (!owner) {
public viewDidAppear(animated: boolean): void {
let page = this._owner.get();
trace.write(page + " viewDidAppear", trace.categories.Navigation);
if (!page) {
return;
}
trace.write(owner + " viewWillDisappear", trace.categories.Navigation);
//https://github.com/NativeScript/NativeScript/issues/1201
owner._viewWillDisappear = true;
page._viewWillDisappear = false;
let frame = this.navigationController ? (<any>this.navigationController).owner : null;
// Skip navigation events if modal page is shown.
if (!page.modal && frame) {
let newEntry = this[ENTRY];
let isBack = isBackNavigation(frame, newEntry);
// We are on the current page which happens when navigation is canceled so isBack should be false.
if (frame.currentPage === page && frame._navigationQueue.length === 0) {
isBack = false;
}
frame._navigateToEntry = null;
frame._currentEntry = newEntry;
frame.remeasureFrame();
frame._updateActionBar(page);
page.onNavigatedTo(isBack);
frame._processNavigationQueue(page);
}
};
public viewWillDisappear(animated: boolean): void {
let page = this._owner.get();
trace.write(page + " viewWillDisappear", trace.categories.Navigation);
if (!page) {
return;
}
var frame = page.frame;
// Skip navigation events if we are hiding because we are about to show modal page.
if (!page.modal && frame && frame.currentPage === page) {
var isBack = page.frame && (!this.navigationController || !this.navigationController.viewControllers.containsObject(this));
page.onNavigatingFrom(isBack);
}
//https://github.com/NativeScript/NativeScript/issues/1201
page._viewWillDisappear = true;
}
public viewDidDisappear() {
let owner = this._owner.get();
if (!owner) {
public viewDidDisappear(animated: boolean): void {
let page = this._owner.get();
trace.write(page + " viewDidDisappear", trace.categories.Navigation);
// Exit if no page or page is hiding because it shows another page modally.
if (!page || page.modal) {
return;
}
trace.write(owner + " viewDidDisappear", trace.categories.Navigation);
if (owner.modal) {
// Don't emit unloaded if this page is disappearing because of a modal view being shown.
return;
let modalParent = page._modalParent;
page._modalParent = undefined;
page._UIModalPresentationFormSheet = false;
// Clear modal flag on parent page.
if (modalParent) {
modalParent._modal = undefined;
}
// Manually pop backStack when Back button is pressed or navigating back with edge swipe.
// Don't pop if we are hiding modally shown page.
let frame = page.frame;
if (!modalParent && frame && frame.backStack.length > 0 && (<any>frame)._navigationQueue.length === 0 && frame.currentPage === page) {
(<any>frame)._backStack.pop();
}
page._enableLoadedEvents = true;
// Remove from parent if page was in frame and we navigated back.
// Showing page modally will not pass isBack check so currentPage won't be removed from Frame.
let isBack = frame && (!this.navigationController || !this.navigationController.viewControllers.containsObject(this));
if (isBack) {
// Remove parent when navigating back.
frame._removeView(page);
}
// Forward navigation does not remove page from frame so we raise unloaded manually.
if (page.isLoaded) {
page.onUnloaded();
}
page._enableLoadedEvents = false;
if (!modalParent) {
// Last raise onNavigatedFrom event if we are not modally shown.
page.onNavigatedFrom(isBack);
}
owner._enableLoadedEvents = true;
owner.onUnloaded();
owner._enableLoadedEvents = false;
}
}
export class Page extends pageCommon.Page {
private _ios: UIViewController;
public _enableLoadedEvents: boolean;
public _isModal: boolean;
public _modalParent: Page;
public _UIModalPresentationFormSheet: boolean;
public _viewWillDisappear: boolean;
@@ -203,7 +321,7 @@ export class Page extends pageCommon.Page {
protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) {
super._showNativeModalView(parent, context, closeCallback, fullscreen);
this._isModal = true;
this._modalParent = parent;
if (!parent.ios.view.window) {
throw new Error("Parent page is not part of the window hierarchy. Close the current modal page before showing another one!");
@@ -218,17 +336,17 @@ export class Page extends pageCommon.Page {
}
super._raiseShowingModallyEvent();
var that = this;
parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 9, function completion() {
parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 8, null);
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(parent.ios.transitionCoordinator(), null, function () {
that._raiseShownModallyEvent(parent, context, closeCallback);
});
}
protected _hideNativeModalView(parent: Page) {
this._isModal = false;
this._UIModalPresentationFormSheet = false;
parent.requestLayout();
parent._ios.dismissModalViewControllerAnimated(utils.ios.MajorVersion >= 9);
parent._ios.dismissModalViewControllerAnimated(utils.ios.MajorVersion >= 8);
super._hideNativeModalView(parent);
}
@@ -241,7 +359,6 @@ export class Page extends pageCommon.Page {
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
@@ -258,12 +375,12 @@ export class Page extends pageCommon.Page {
if (this.frame && this.frame.parent) {
statusBarHeight = 0;
}
// Phones does not support fullScreen=false for modal pages so we reduce statusbar only when on tablet and not in fullscreen
if (this._isModal && this._UIModalPresentationFormSheet && device.deviceType === DeviceType.Tablet) {
if (this._modalParent && this._UIModalPresentationFormSheet && device.deviceType === DeviceType.Tablet) {
statusBarHeight = 0;
}
if (this.frame && this.frame._getNavBarVisible(this)) {
// Measure ActionBar with the full height.
let actionBarSize = View.measureChild(this, this.actionBar, widthMeasureSpec, heightMeasureSpec);
@@ -294,14 +411,14 @@ export class Page extends pageCommon.Page {
}
let statusBarHeight = this.backgroundSpanUnderStatusBar ? uiUtils.ios.getStatusBarHeight() : 0;
// If this page is inside nested frame - don't substract statusBarHeight again.
if (this.frame && this.frame.parent) {
statusBarHeight = 0;
}
// Phones does not support fullScreen=false for modal pages so we reduce statusbar only when on tablet and not in fullscreen
if (this._isModal && this._UIModalPresentationFormSheet && device.deviceType === DeviceType.Tablet) {
if (this._modalParent && this._UIModalPresentationFormSheet && device.deviceType === DeviceType.Tablet) {
statusBarHeight = 0;
}
@@ -316,4 +433,4 @@ export class Page extends pageCommon.Page {
return super._addViewToNativeVisualTree(view);
}
}
}

View File

@@ -235,7 +235,7 @@ export function _onFragmentHidden(fragment: android.app.Fragment, isBack: boolea
if (fragment[COMPLETE_PAGE_REMOVAL_WHEN_TRANSITION_ENDS] === undefined) {
// This might be a second call if the fragment is hidden and then destroyed.
_completePageRemoval(fragment, true);
_completePageRemoval(fragment, true, isBack);
}
}
@@ -253,7 +253,7 @@ function _completePageAddition(fragment: android.app.Fragment, isBack: boolean,
}
}
function _completePageRemoval(fragment: android.app.Fragment, force?: boolean) {
function _completePageRemoval(fragment: android.app.Fragment, force: boolean = false, isBack: boolean = false) {
if (fragment[COMPLETE_PAGE_REMOVAL_WHEN_TRANSITION_ENDS] || force) {
fragment[COMPLETE_PAGE_REMOVAL_WHEN_TRANSITION_ENDS] = undefined;
var frame = (<any>fragment).frame;
@@ -261,7 +261,9 @@ function _completePageRemoval(fragment: android.app.Fragment, force?: boolean) {
var page: pageModule.Page = entry.resolvedPage;
if (page.frame) {
frame._removeView(page);
page.onNavigatedFrom(isBack);
}
trace.write(`REMOVAL of ${page} completed`, trace.categories.Transition);
}
}