From ebf32d833963ee03796b25bf8a74953904abfdd8 Mon Sep 17 00:00:00 2001 From: sun-xinyan Date: Tue, 27 May 2025 22:41:02 +0800 Subject: [PATCH] add router static and dynamic transfer Signed-off-by: sun-xinyan --- .../arkoala-arkts/arkui-ohos/ohos.observer.ts | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/ohos.observer.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/ohos.observer.ts index 92d000e6c63..b1b4aa403d1 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/ohos.observer.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/ohos.observer.ts @@ -1,8 +1,68 @@ -export declare namespace observer { +import { InteropNativeModule, runtimeType, RuntimeType } from "@koalaui/interop"; +import { NavPathStack } from "./src/component/navigation" +import { ResourceStr } from "./src/component/units" +import { UIContext, UIObserver } from "./ohos.arkui.UIContext" + +type Any = Object | undefined | null; + +export namespace observer { export interface UIObserver { on(type: string, callback: () => void): void; off(type: string, callback?: () => void): void; } - export function createUIObserver(id: number): UIObserver; + export function createUIObserver(id: number): UIObserver | null { + return null + } + + export interface NavigationInfo { + navigationId: string; + pathStack: NavPathStack; + } + + export enum NavDestinationState { + ON_SHOWN = 0, + ON_HIDDEN = 1, + ON_APPEAR = 2, + ON_DISAPPEAR = 3, + ON_WILL_SHOW = 4, + ON_WILL_HIDE = 5, + ON_WILL_APPEAR = 6, + ON_WILL_DISAPPEAR = 7, + ON_BACKPRESS = 100 + } + + export interface NavDestinationInfo { + navigationId: ResourceStr; + name: ResourceStr; + state: NavDestinationState; + index: number; + param?: Object; + navDestinationId: string; + } + + export enum RouterPageState { + ABOUT_TO_APPEAR = 0, + ABOUT_TO_DISAPPEAR = 1, + ON_PAGE_SHOW = 2, + ON_PAGE_HIDE = 3, + ON_BACK_PRESS = 4 + } + + export class RouterPageInfo { + context: UIContext = new UIContext(100000); // tbd: UIAbilityContext + index: number = -1; + name: string = 'a'; + path: string = 'b'; + state: observer.RouterPageState = observer.RouterPageState.ABOUT_TO_APPEAR; + pageId: string = '1'; + static transferStatic(input: Any): Object { + InteropNativeModule._NativeLog("AceRouter:: enter RouterPageInfo transferStatic") + return new Object() + } + static transferDynamic(input: Object): Any { + InteropNativeModule._NativeLog("AceRouter:: enter RouterPageInfo transferDynamic") + return new Object() as Any + } + } } -- Gitee