Skip to content

Commit

Permalink
fix(frame): root tabview with modal frame when suspend/resume app (#5408
Browse files Browse the repository at this point in the history
)
  • Loading branch information
manoldonev committed Feb 12, 2018
1 parent b113b00 commit 2edef3d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/app/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ import * as cssAnimationTests from "./ui/animation/css-animation-tests";
allTests["CSS-ANIMATION"] = cssAnimationTests;

import * as transitionTests from "./navigation/transition-tests";
allTests["TANSITIONS"] = transitionTests;
allTests["TRANSITIONS"] = transitionTests;
import * as searchBarTests from "./ui/search-bar/search-bar-tests";
allTests["SEARCH-BAR"] = searchBarTests;

Expand Down
17 changes: 16 additions & 1 deletion tests/app/ui/page/page-tests-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as helper from "../helper";
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
import { View, PercentLength, Observable, unsetValue, EventData, isIOS } from "tns-core-modules/ui/core/view";
import { Frame } from "tns-core-modules/ui/frame";
import { Frame, stack } from "tns-core-modules/ui/frame";
import { Label } from "tns-core-modules/ui/label";
import { Color } from "tns-core-modules/color";

Expand Down Expand Up @@ -548,6 +548,7 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
let ready = false;

const modalCloseCallback = function (returnValue: any) {
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
ready = true;
}

Expand All @@ -567,6 +568,10 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
hostNavigatedFromCount++;
};

const modalPageShownModallyEventHandler = function() {
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
}

const hostNavigatedToEventHandler2 = function(args: NavigatedData) {
const page = <Page>args.object;
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler2);
Expand All @@ -576,7 +581,11 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
moduleName: basePath + "modal-page"
};

TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");

const modalPage = createViewFromEntry(entry) as Page;
modalPage.on(Frame.shownModallyEvent, modalPageShownModallyEventHandler);

page.showModal(modalPage, {}, modalCloseCallback, false, false);
}

Expand Down Expand Up @@ -694,6 +703,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
let ready = false;

const modalCloseCallback = function (returnValue: any) {
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
ready = true;
}

Expand All @@ -703,6 +713,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {

const modalFrameShownModallyEventHandler = function(args: ShownModallyData) {
shownModallyCount++;
TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!");

args.closeCallback("return value");
}
Expand All @@ -720,11 +731,15 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {

const modalPage = createViewFromEntry(entry) as Page;

TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");

modalFrame = new Frame();
modalFrame.on(Frame.showingModallyEvent, modalFrameShowingModallyEventHandler);
modalFrame.on(Frame.shownModallyEvent, modalFrameShownModallyEventHandler);
modalFrame.navigate(() => modalPage);

TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!");

page.showModal(modalFrame, {}, modalCloseCallback, false, false);
}

Expand Down
4 changes: 4 additions & 0 deletions tns-core-modules/ui/core/view-base/view-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ export abstract class ViewBase extends Observable {
*/
public _removeViewCore(view: ViewBase): void;
public _parentChanged(oldParent: ViewBase): void;
/**
* Method is intended to be overridden by inheritors and used as "protected"
*/
public _dialogClosed(): void;

_domId: number;

Expand Down
4 changes: 4 additions & 0 deletions tns-core-modules/ui/core/view-base/view-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
parent.closeModal();
}
}

public _dialogClosed(): void {
return;
}
}

ViewBase.prototype.isCollapsed = false;
Expand Down
4 changes: 3 additions & 1 deletion tns-core-modules/ui/core/view/view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
const modalIndex = _rootModalViews.indexOf(that);
_rootModalViews.splice(modalIndex);
that._hideNativeModalView(parent);
that._modalParent = null
that._modalParent = null;
that._modalContext = null;
that._closeModalCallback = null;
that._dialogClosed();
parent._modal = null;

if (typeof closeCallback === "function") {
closeCallback.apply(undefined, arguments);
}
Expand Down
16 changes: 7 additions & 9 deletions tns-core-modules/ui/frame/frame-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
@profile
public onLoaded() {
super.onLoaded();

this._pushInFrameStack();

this._processNextNavigationEntry();
}

@profile
public onUnloaded() {
super.onUnloaded();

this._popFromFrameStack();
}

public canGoBack(): boolean {
let backstack = this._backStack.length;
let previousForwardNotInBackstack = false;
Expand Down Expand Up @@ -192,6 +184,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
// app.on(app.orientationChangedEvent, (data) => this._onOrientationChanged());
// }

this._pushInFrameStack();

const backstackEntry: BackstackEntry = {
entry: entry,
resolvedPage: page,
Expand Down Expand Up @@ -430,6 +424,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
this._isInFrameStack = false;
}

public _dialogClosed(): void {
this._popFromFrameStack();
}

get _childrenCount(): number {
if (this.currentPage) {
return 1;
Expand Down
4 changes: 3 additions & 1 deletion tns-core-modules/ui/frame/frame.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ export class Frame extends FrameBase {
if (this.canGoBack()) {
this.goBack();
return true;
} else if (!this.navigationQueueIsEmpty()) {
}

if (!this.navigationQueueIsEmpty()) {
const manager = this._getFragmentManager();
if (manager) {
manager.executePendingTransactions();
Expand Down

0 comments on commit 2edef3d

Please sign in to comment.