mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
feature(frame): introduce src property (#5320)
This commit is contained in:

committed by
Alexander Vakrilov

parent
923d48b23a
commit
af934ccabf
@ -3,7 +3,7 @@ import { Frame as FrameDefinition, NavigationEntry, BackstackEntry, NavigationTr
|
|||||||
import { Page } from "../page";
|
import { Page } from "../page";
|
||||||
|
|
||||||
// Types.
|
// 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 { resolveFileName } from "../../file-system/file-name-resolver";
|
||||||
import { knownFolders, path } from "../../file-system";
|
import { knownFolders, path } from "../../file-system";
|
||||||
import { parse, createViewFromEntry } from "../builder";
|
import { parse, createViewFromEntry } from "../builder";
|
||||||
@ -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.
|
// 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) {
|
public _addChildFromBuilder(name: string, value: any) {
|
||||||
if (value instanceof Page) {
|
throw new Error(`Frame should not have a view. Use 'defaultPage' property instead.`);
|
||||||
this.navigate({ create: () => value });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@profile
|
@profile
|
||||||
@ -580,3 +578,11 @@ export function goBack(): boolean {
|
|||||||
export function stack(): Array<FrameBase> {
|
export function stack(): Array<FrameBase> {
|
||||||
return frameStack;
|
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)
|
Reference in New Issue
Block a user