feat(frame): handle back navigation when common layout is used as a root element (#5608)

* test(e2e): update modal navigation app

Add layout as root.
Add show modal layout.

* chore(frame): move frame stack modifiers in a separate frame-stack module

* feat(frame): handle back navigation when using common layout as root element
This commit is contained in:
Alexander Djenkov
2018-04-02 22:27:44 +03:00
committed by Svetoslav
parent 8a1958e82e
commit 70f01123df
12 changed files with 161 additions and 48 deletions

View File

@ -9,10 +9,9 @@ import { knownFolders, path } from "../../file-system";
import { parse, createViewFromEntry } from "../builder";
import { profile } from "../../profiling";
import { frameStack, topmost as frameStackTopmost, _pushInFrameStack, _popFromFrameStack, _removeFromFrameStack } from "./frame-stack";
export * from "../core/view";
let frameStack: Array<FrameBase> = [];
function buildEntryFromArgs(arg: any): NavigationEntry {
let entry: NavigationEntry;
if (typeof arg === "string") {
@ -403,41 +402,15 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
}
public _pushInFrameStack() {
if (this._isInFrameStack && frameStack[frameStack.length - 1] === this) {
return;
}
if (this._isInFrameStack) {
const indexOfFrame = frameStack.indexOf(this);
frameStack.splice(indexOfFrame, 1);
}
frameStack.push(this);
this._isInFrameStack = true;
_pushInFrameStack(this);
}
public _popFromFrameStack() {
if (!this._isInFrameStack) {
return;
}
const top = topmost();
if (top !== this) {
throw new Error("Cannot pop a Frame which is not at the top of the navigation stack.");
}
frameStack.pop();
this._isInFrameStack = false;
_popFromFrameStack(this);
}
public _removeFromFrameStack() {
if (!this._isInFrameStack) {
return;
}
const index = frameStack.indexOf(this);
frameStack.splice(index, 1);
this._isInFrameStack = false;
_removeFromFrameStack(this);
}
public _dialogClosed(): void {
@ -585,11 +558,7 @@ export function getFrameById(id: string): FrameBase {
}
export function topmost(): FrameBase {
if (frameStack.length > 0) {
return frameStack[frameStack.length - 1];
}
return undefined;
return frameStackTopmost();
}
export function goBack(): boolean {