From 019a835617f15e21415b19737e9107963c93c6dc Mon Sep 17 00:00:00 2001 From: farfromrefug <> Date: Tue, 2 Jul 2024 10:15:45 +0200 Subject: [PATCH] fix: export navigation util methods like `resolveFrame` and `resolveComponentElement` --- src/dom/navigation.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dom/navigation.ts b/src/dom/navigation.ts index 44d55a94..70d4a5b4 100644 --- a/src/dom/navigation.ts +++ b/src/dom/navigation.ts @@ -1,9 +1,8 @@ -import { ViewBase, View, NavigatedData, NavigationTransition, Frame, BackstackEntry } from "@nativescript/core"; +import { ViewBase, View, NavigatedData, NavigationTransition, Frame, BackstackEntry, Application } from "@nativescript/core"; import FrameElement from "./native/FrameElement"; import { createElement, DocumentNode, logger as log } from "./basicdom"; import PageElement from "./native/PageElement"; import NativeViewElementNode from "./native/NativeViewElementNode"; -import { getRootView } from "@nativescript/core/application"; import { _rootModalViews } from "@nativescript/core/ui/core/view"; export type ViewSpec = View | NativeViewElementNode @@ -22,7 +21,7 @@ export interface NavigationOptions { transitioniOS?: NavigationTransition; } -function resolveFrame(frameSpec: FrameSpec): Frame { +export function resolveFrame(frameSpec: FrameSpec): Frame { let targetFrame: Frame; if (!frameSpec) targetFrame = Frame.topmost(); if (frameSpec instanceof FrameElement) targetFrame = frameSpec.nativeView as Frame; @@ -34,7 +33,7 @@ function resolveFrame(frameSpec: FrameSpec): Frame { return targetFrame; } -function resolveTarget(viewSpec: ViewSpec): View { +export function resolveTarget(viewSpec: ViewSpec): View { if (viewSpec instanceof View) { return viewSpec; } @@ -43,7 +42,7 @@ function resolveTarget(viewSpec: ViewSpec): View { interface ComponentInstanceInfo { element: NativeViewElementNode, pageInstance: SvelteComponent } -function resolveComponentElement(pageSpec: PageSpec, props?: T): ComponentInstanceInfo { +export function resolveComponentElement(pageSpec: PageSpec, props?: T): ComponentInstanceInfo { let dummy = createElement('fragment', window.document as unknown as DocumentNode); let pageInstance = new pageSpec({ target: dummy, props: props }); let element = dummy.firstElement() as NativeViewElementNode; @@ -140,7 +139,7 @@ export interface ShowModalOptions { export function showModal(modalOptions: ShowModalOptions): Promise { let { page, props = {}, target, ...options } = modalOptions; - let modalLauncher = resolveTarget(target) || getRootView(); + let modalLauncher = resolveTarget(target) || Application.getRootView(); let componentInstanceInfo = resolveComponentElement(page, props); let modalView: ViewBase = componentInstanceInfo.element.nativeView;