mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(frame): root tabview with modal frame when suspend/resume app (#5408)
This commit is contained in:
@ -226,7 +226,7 @@ import * as cssAnimationTests from "./ui/animation/css-animation-tests";
|
|||||||
allTests["CSS-ANIMATION"] = cssAnimationTests;
|
allTests["CSS-ANIMATION"] = cssAnimationTests;
|
||||||
|
|
||||||
import * as transitionTests from "./navigation/transition-tests";
|
import * as transitionTests from "./navigation/transition-tests";
|
||||||
allTests["TANSITIONS"] = transitionTests;
|
allTests["TRANSITIONS"] = transitionTests;
|
||||||
import * as searchBarTests from "./ui/search-bar/search-bar-tests";
|
import * as searchBarTests from "./ui/search-bar/search-bar-tests";
|
||||||
allTests["SEARCH-BAR"] = searchBarTests;
|
allTests["SEARCH-BAR"] = searchBarTests;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import * as helper from "../helper";
|
|||||||
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
|
import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
|
||||||
import { StackLayout } from "tns-core-modules/ui/layouts/stack-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 { 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 { Label } from "tns-core-modules/ui/label";
|
||||||
import { Color } from "tns-core-modules/color";
|
import { Color } from "tns-core-modules/color";
|
||||||
|
|
||||||
@ -548,6 +548,7 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
|
|||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
||||||
const modalCloseCallback = function (returnValue: any) {
|
const modalCloseCallback = function (returnValue: any) {
|
||||||
|
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,6 +568,10 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
|
|||||||
hostNavigatedFromCount++;
|
hostNavigatedFromCount++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const modalPageShownModallyEventHandler = function() {
|
||||||
|
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
|
||||||
|
}
|
||||||
|
|
||||||
const hostNavigatedToEventHandler2 = function(args: NavigatedData) {
|
const hostNavigatedToEventHandler2 = function(args: NavigatedData) {
|
||||||
const page = <Page>args.object;
|
const page = <Page>args.object;
|
||||||
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler2);
|
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler2);
|
||||||
@ -576,7 +581,11 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
|
|||||||
moduleName: basePath + "modal-page"
|
moduleName: basePath + "modal-page"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
|
||||||
|
|
||||||
const modalPage = createViewFromEntry(entry) as Page;
|
const modalPage = createViewFromEntry(entry) as Page;
|
||||||
|
modalPage.on(Frame.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||||
|
|
||||||
page.showModal(modalPage, {}, modalCloseCallback, false, false);
|
page.showModal(modalPage, {}, modalCloseCallback, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,6 +703,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
|
|||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
||||||
const modalCloseCallback = function (returnValue: any) {
|
const modalCloseCallback = function (returnValue: any) {
|
||||||
|
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,6 +713,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
|
|||||||
|
|
||||||
const modalFrameShownModallyEventHandler = function(args: ShownModallyData) {
|
const modalFrameShownModallyEventHandler = function(args: ShownModallyData) {
|
||||||
shownModallyCount++;
|
shownModallyCount++;
|
||||||
|
TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!");
|
||||||
|
|
||||||
args.closeCallback("return value");
|
args.closeCallback("return value");
|
||||||
}
|
}
|
||||||
@ -720,11 +731,15 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
|
|||||||
|
|
||||||
const modalPage = createViewFromEntry(entry) as Page;
|
const modalPage = createViewFromEntry(entry) as Page;
|
||||||
|
|
||||||
|
TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!");
|
||||||
|
|
||||||
modalFrame = new Frame();
|
modalFrame = new Frame();
|
||||||
modalFrame.on(Frame.showingModallyEvent, modalFrameShowingModallyEventHandler);
|
modalFrame.on(Frame.showingModallyEvent, modalFrameShowingModallyEventHandler);
|
||||||
modalFrame.on(Frame.shownModallyEvent, modalFrameShownModallyEventHandler);
|
modalFrame.on(Frame.shownModallyEvent, modalFrameShownModallyEventHandler);
|
||||||
modalFrame.navigate(() => modalPage);
|
modalFrame.navigate(() => modalPage);
|
||||||
|
|
||||||
|
TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!");
|
||||||
|
|
||||||
page.showModal(modalFrame, {}, modalCloseCallback, false, false);
|
page.showModal(modalFrame, {}, modalCloseCallback, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +263,10 @@ export abstract class ViewBase extends Observable {
|
|||||||
*/
|
*/
|
||||||
public _removeViewCore(view: ViewBase): void;
|
public _removeViewCore(view: ViewBase): void;
|
||||||
public _parentChanged(oldParent: ViewBase): void;
|
public _parentChanged(oldParent: ViewBase): void;
|
||||||
|
/**
|
||||||
|
* Method is intended to be overridden by inheritors and used as "protected"
|
||||||
|
*/
|
||||||
|
public _dialogClosed(): void;
|
||||||
|
|
||||||
_domId: number;
|
_domId: number;
|
||||||
|
|
||||||
|
@ -956,6 +956,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
|||||||
parent.closeModal();
|
parent.closeModal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public _dialogClosed(): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewBase.prototype.isCollapsed = false;
|
ViewBase.prototype.isCollapsed = false;
|
||||||
|
@ -251,10 +251,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
const modalIndex = _rootModalViews.indexOf(that);
|
const modalIndex = _rootModalViews.indexOf(that);
|
||||||
_rootModalViews.splice(modalIndex);
|
_rootModalViews.splice(modalIndex);
|
||||||
that._hideNativeModalView(parent);
|
that._hideNativeModalView(parent);
|
||||||
that._modalParent = null
|
that._modalParent = null;
|
||||||
that._modalContext = null;
|
that._modalContext = null;
|
||||||
that._closeModalCallback = null;
|
that._closeModalCallback = null;
|
||||||
|
that._dialogClosed();
|
||||||
parent._modal = null;
|
parent._modal = null;
|
||||||
|
|
||||||
if (typeof closeCallback === "function") {
|
if (typeof closeCallback === "function") {
|
||||||
closeCallback.apply(undefined, arguments);
|
closeCallback.apply(undefined, arguments);
|
||||||
}
|
}
|
||||||
|
@ -58,18 +58,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
|||||||
@profile
|
@profile
|
||||||
public onLoaded() {
|
public onLoaded() {
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
|
|
||||||
this._pushInFrameStack();
|
|
||||||
this._processNextNavigationEntry();
|
this._processNextNavigationEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@profile
|
|
||||||
public onUnloaded() {
|
|
||||||
super.onUnloaded();
|
|
||||||
|
|
||||||
this._popFromFrameStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
public canGoBack(): boolean {
|
public canGoBack(): boolean {
|
||||||
let backstack = this._backStack.length;
|
let backstack = this._backStack.length;
|
||||||
let previousForwardNotInBackstack = false;
|
let previousForwardNotInBackstack = false;
|
||||||
@ -192,6 +184,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
|||||||
// app.on(app.orientationChangedEvent, (data) => this._onOrientationChanged());
|
// app.on(app.orientationChangedEvent, (data) => this._onOrientationChanged());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
this._pushInFrameStack();
|
||||||
|
|
||||||
const backstackEntry: BackstackEntry = {
|
const backstackEntry: BackstackEntry = {
|
||||||
entry: entry,
|
entry: entry,
|
||||||
resolvedPage: page,
|
resolvedPage: page,
|
||||||
@ -430,6 +424,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
|||||||
this._isInFrameStack = false;
|
this._isInFrameStack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public _dialogClosed(): void {
|
||||||
|
this._popFromFrameStack();
|
||||||
|
}
|
||||||
|
|
||||||
get _childrenCount(): number {
|
get _childrenCount(): number {
|
||||||
if (this.currentPage) {
|
if (this.currentPage) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -243,7 +243,9 @@ export class Frame extends FrameBase {
|
|||||||
if (this.canGoBack()) {
|
if (this.canGoBack()) {
|
||||||
this.goBack();
|
this.goBack();
|
||||||
return true;
|
return true;
|
||||||
} else if (!this.navigationQueueIsEmpty()) {
|
}
|
||||||
|
|
||||||
|
if (!this.navigationQueueIsEmpty()) {
|
||||||
const manager = this._getFragmentManager();
|
const manager = this._getFragmentManager();
|
||||||
if (manager) {
|
if (manager) {
|
||||||
manager.executePendingTransactions();
|
manager.executePendingTransactions();
|
||||||
|
Reference in New Issue
Block a user