Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions tns-core-modules/ui/frame/frame-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Frame as FrameDefinition, NavigationEntry, BackstackEntry, NavigationTr
import { Page } from "../page";

// Types.
import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, EventData } from "../core/view";
import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, EventData, Property } from "../core/view";
import { resolveFileName } from "../../file-system/file-name-resolver";
import { knownFolders, path } from "../../file-system";
import { parse, createViewFromEntry } from "../builder";
Expand Down Expand Up @@ -52,9 +52,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
// TODO: Currently our navigation will not be synchronized in case users directly call native navigation methods like Activity.startActivity.

public _addChildFromBuilder(name: string, value: any) {
if (value instanceof Page) {
this.navigate({ create: () => value });
}
throw new Error(`Frame should not have a view. Use 'defaultPage' property instead.`);
}

@profile
Expand Down Expand Up @@ -215,7 +213,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
this._addView(newPage);
newPage._frame = this;
}

this._currentEntry = entry;
this._executingEntry = null;
newPage.onNavigatedTo(isBack);
Expand Down Expand Up @@ -579,4 +577,12 @@ export function goBack(): boolean {

export function stack(): Array<FrameBase> {
return frameStack;
}
}

export const defaultPage = new Property<FrameBase, string>({
name: "defaultPage", valueChanged: (frame: FrameBase, oldValue: string, newValue: string) => {
frame.navigate({ moduleName: newValue });
}
});

defaultPage.register(FrameBase)