Skip to content

Commit

Permalink
fix: export navigation util methods like resolveFrame and `resolveC…
Browse files Browse the repository at this point in the history
…omponentElement`
  • Loading branch information
farfromrefug committed Jul 2, 2024
1 parent f74b1aa commit 019a835
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/dom/navigation.ts
Original file line number Diff line number Diff line change
@@ -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<View>
Expand All @@ -22,7 +21,7 @@ export interface NavigationOptions<T> {
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;
Expand All @@ -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;
}
Expand All @@ -43,7 +42,7 @@ function resolveTarget(viewSpec: ViewSpec): View {

interface ComponentInstanceInfo<T = any> { element: NativeViewElementNode<View>, pageInstance: SvelteComponent<T> }

function resolveComponentElement<T>(pageSpec: PageSpec<T>, props?: T): ComponentInstanceInfo<T> {
export function resolveComponentElement<T>(pageSpec: PageSpec<T>, props?: T): ComponentInstanceInfo<T> {
let dummy = createElement('fragment', window.document as unknown as DocumentNode);
let pageInstance = new pageSpec({ target: dummy, props: props });
let element = dummy.firstElement() as NativeViewElementNode<View>;
Expand Down Expand Up @@ -140,7 +139,7 @@ export interface ShowModalOptions<T> {
export function showModal<T, U>(modalOptions: ShowModalOptions<U>): Promise<T> {
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;
Expand Down

0 comments on commit 019a835

Please sign in to comment.