Skip to content

Commit 2edef3d

Browse files
authored
fix(frame): root tabview with modal frame when suspend/resume app (#5408)
1 parent b113b00 commit 2edef3d

7 files changed

Lines changed: 38 additions & 13 deletions

File tree

tests/app/testRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ import * as cssAnimationTests from "./ui/animation/css-animation-tests";
226226
allTests["CSS-ANIMATION"] = cssAnimationTests;
227227

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

tests/app/ui/page/page-tests-common.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as helper from "../helper";
1919
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
2020
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
2121
import { View, PercentLength, Observable, unsetValue, EventData, isIOS } from "tns-core-modules/ui/core/view";
22-
import { Frame } from "tns-core-modules/ui/frame";
22+
import { Frame, stack } from "tns-core-modules/ui/frame";
2323
import { Label } from "tns-core-modules/ui/label";
2424
import { Color } from "tns-core-modules/color";
2525

@@ -548,6 +548,7 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
548548
let ready = false;
549549

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

@@ -567,6 +568,10 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
567568
hostNavigatedFromCount++;
568569
};
569570

571+
const modalPageShownModallyEventHandler = function() {
572+
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
573+
}
574+
570575
const hostNavigatedToEventHandler2 = function(args: NavigatedData) {
571576
const page = <Page>args.object;
572577
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler2);
@@ -576,7 +581,11 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
576581
moduleName: basePath + "modal-page"
577582
};
578583

584+
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
585+
579586
const modalPage = createViewFromEntry(entry) as Page;
587+
modalPage.on(Frame.shownModallyEvent, modalPageShownModallyEventHandler);
588+
580589
page.showModal(modalPage, {}, modalCloseCallback, false, false);
581590
}
582591

@@ -694,6 +703,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
694703
let ready = false;
695704

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

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

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

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

721732
const modalPage = createViewFromEntry(entry) as Page;
722733

734+
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
735+
723736
modalFrame = new Frame();
724737
modalFrame.on(Frame.showingModallyEvent, modalFrameShowingModallyEventHandler);
725738
modalFrame.on(Frame.shownModallyEvent, modalFrameShownModallyEventHandler);
726739
modalFrame.navigate(() => modalPage);
727740

741+
TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!");
742+
728743
page.showModal(modalFrame, {}, modalCloseCallback, false, false);
729744
}
730745

tns-core-modules/ui/core/view-base/view-base.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ export abstract class ViewBase extends Observable {
263263
*/
264264
public _removeViewCore(view: ViewBase): void;
265265
public _parentChanged(oldParent: ViewBase): void;
266+
/**
267+
* Method is intended to be overridden by inheritors and used as "protected"
268+
*/
269+
public _dialogClosed(): void;
266270

267271
_domId: number;
268272

tns-core-modules/ui/core/view-base/view-base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
956956
parent.closeModal();
957957
}
958958
}
959+
960+
public _dialogClosed(): void {
961+
return;
962+
}
959963
}
960964

961965
ViewBase.prototype.isCollapsed = false;

tns-core-modules/ui/core/view/view-common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
251251
const modalIndex = _rootModalViews.indexOf(that);
252252
_rootModalViews.splice(modalIndex);
253253
that._hideNativeModalView(parent);
254-
that._modalParent = null
254+
that._modalParent = null;
255255
that._modalContext = null;
256256
that._closeModalCallback = null;
257+
that._dialogClosed();
257258
parent._modal = null;
259+
258260
if (typeof closeCallback === "function") {
259261
closeCallback.apply(undefined, arguments);
260262
}

tns-core-modules/ui/frame/frame-common.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
5858
@profile
5959
public onLoaded() {
6060
super.onLoaded();
61-
62-
this._pushInFrameStack();
61+
6362
this._processNextNavigationEntry();
6463
}
6564

66-
@profile
67-
public onUnloaded() {
68-
super.onUnloaded();
69-
70-
this._popFromFrameStack();
71-
}
72-
7365
public canGoBack(): boolean {
7466
let backstack = this._backStack.length;
7567
let previousForwardNotInBackstack = false;
@@ -192,6 +184,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
192184
// app.on(app.orientationChangedEvent, (data) => this._onOrientationChanged());
193185
// }
194186

187+
this._pushInFrameStack();
188+
195189
const backstackEntry: BackstackEntry = {
196190
entry: entry,
197191
resolvedPage: page,
@@ -430,6 +424,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
430424
this._isInFrameStack = false;
431425
}
432426

427+
public _dialogClosed(): void {
428+
this._popFromFrameStack();
429+
}
430+
433431
get _childrenCount(): number {
434432
if (this.currentPage) {
435433
return 1;

tns-core-modules/ui/frame/frame.android.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ export class Frame extends FrameBase {
243243
if (this.canGoBack()) {
244244
this.goBack();
245245
return true;
246-
} else if (!this.navigationQueueIsEmpty()) {
246+
}
247+
248+
if (!this.navigationQueueIsEmpty()) {
247249
const manager = this._getFragmentManager();
248250
if (manager) {
249251
manager.executePendingTransactions();

0 commit comments

Comments
 (0)