diff --git a/arkoala-arkts/arkui/src/generated/index.ts b/arkoala-arkts/arkui/src/generated/index.ts index d259baa8378c1dd6e7ee8797c5ccd1896fa5705a..7ea815f9c0635f41ef73d60fd7458c181781861b 100644 --- a/arkoala-arkts/arkui/src/generated/index.ts +++ b/arkoala-arkts/arkui/src/generated/index.ts @@ -48,7 +48,7 @@ export * from "./ArkMediaCachedImage" export * from "./ArkMenu" export * from "./ArkMenuItem" export * from "./ArkMenuItemGroup" -export * from "./ArkNavDestination" +export * from "../handwritten/ArkNavDestination" export * from "./ArkNavRouter" export * from "./ArkNavigator" export * from "./ArkNodeContainer" diff --git a/arkoala-arkts/arkui/src/generated/ArkNavDestination.ts b/arkoala-arkts/arkui/src/handwritten/ArkNavDestination.ts similarity index 90% rename from arkoala-arkts/arkui/src/generated/ArkNavDestination.ts rename to arkoala-arkts/arkui/src/handwritten/ArkNavDestination.ts index 65ae1a9b199f66ba24cd78d10a3eea97ed148ac3..3f66de7e68a66c5a4da6841b2258cc5023836654 100644 --- a/arkoala-arkts/arkui/src/generated/ArkNavDestination.ts +++ b/arkoala-arkts/arkui/src/handwritten/ArkNavDestination.ts @@ -1,277 +1,277 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! - -import { int32 } from "@koalaui/common" -import { KStringPtr, KBoolean } from "@koalaui/interop" -import { NodeAttach, remember } from "@koalaui/runtime" -import { runtimeType, RuntimeType, isResource, isInstanceOf } from "./peers/SerializerBase" -import { ComponentBase } from "./ComponentBase" -import { TypeChecker } from "#components" -import { ArkCommonMethodComponent } from "./ArkCommon" -import { ArkNavDestinationPeer } from "./peers/ArkNavDestinationPeer" -import { UseEventsProperties } from "./use_properties" -import { CommonMethod, SymbolGlyphModifier, CustomBuilder, LayoutSafeAreaType, LayoutSafeAreaEdge } from "./ArkCommonInterfaces" -import { NavDestinationAttribute, NavDestinationMode, NavigationSystemTransitionType, NestedScrollInfo, NavDestinationCommonTitle, NavDestinationCustomTitle } from "./ArkNavDestinationInterfaces" -import { Callback_Void, Callback_Boolean, Callback_NavDestinationContext_Void } from "./SyntheticDeclarations" -import { ResourceStr } from "./ArkUnitsInterfaces" -import { PixelMap } from "./ArkPixelMapMaterialized" -import { NavigationMenuItem, SystemBarStyle, NavigationTitleOptions, ToolbarItem, NavigationToolbarOptions } from "./ArkNavigationInterfaces" -import { NavDestinationContext } from "./ArkNavDestinationContextMaterialized" -import { Scroller } from "./ArkScrollerMaterialized" -import { Resource } from "./ArkResourceInterfaces" -/** @memo:stable */ -export class ArkNavDestinationComponent extends ArkCommonMethodComponent { - getPeer(): ArkNavDestinationPeer { - return (this.peer as ArkNavDestinationPeer) - } - /** @memo */ - setNavDestinationOptions(): this { - if (this.checkPriority("setNavDestinationOptions")) { - this.getPeer()?.setNavDestinationOptionsAttribute() - return this - } - return this - } - /** @memo */ - hideTitleBar(hide: boolean, animated?: boolean): this { - if (this.checkPriority("hideTitleBar")) { - const hide_type = runtimeType(hide) - const animated_type = runtimeType(animated) - if ((((RuntimeType.BOOLEAN == hide_type))) && (((RuntimeType.BOOLEAN == animated_type)))) { - const hide_casted = hide as (boolean) - const animated_casted = animated as (boolean) - this.getPeer()?.hideTitleBar1Attribute(hide_casted, animated_casted) - return this - } - if ((((RuntimeType.BOOLEAN == hide_type))) && (((RuntimeType.UNDEFINED == animated_type)))) { - const hide_casted = hide as (boolean) - this.getPeer()?.hideTitleBar0Attribute(hide_casted) - return this - } - throw new Error("Can not select appropriate overload") - } - return this - } - /** @memo */ - onShown(value: Function0): this { - if (this.checkPriority("onShown")) { - const value_casted = value as (Function0) - this.getPeer()?.onShownAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onHidden(value: Function0): this { - if (this.checkPriority("onHidden")) { - const value_casted = value as (Function0) - this.getPeer()?.onHiddenAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onBackPressed(value: Function0): this { - if (this.checkPriority("onBackPressed")) { - const value_casted = value as (Function0) - this.getPeer()?.onBackPressedAttribute(value_casted) - return this - } - return this - } - /** @memo */ - mode(value: NavDestinationMode): this { - if (this.checkPriority("mode")) { - const value_casted = value as (NavDestinationMode) - this.getPeer()?.modeAttribute(value_casted) - return this - } - return this - } - /** @memo */ - backButtonIcon(value: ResourceStr | PixelMap | SymbolGlyphModifier): this { - if (this.checkPriority("backButtonIcon")) { - const value_casted = value as (ResourceStr | PixelMap | SymbolGlyphModifier) - this.getPeer()?.backButtonIconAttribute(value_casted) - return this - } - return this - } - /** @memo */ - menus(value: Array | CustomBuilder): this { - if (this.checkPriority("menus")) { - const value_casted = value as (Array | CustomBuilder) - this.getPeer()?.menusAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onReady(value: Function1): this { - if (this.checkPriority("onReady")) { - const value_casted = value as (Function1) - this.getPeer()?.onReadyAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onWillAppear(value: Function0): this { - if (this.checkPriority("onWillAppear")) { - const value_casted = value as (Function0) - this.getPeer()?.onWillAppearAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onWillDisappear(value: Function0): this { - if (this.checkPriority("onWillDisappear")) { - const value_casted = value as (Function0) - this.getPeer()?.onWillDisappearAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onWillShow(value: Function0): this { - if (this.checkPriority("onWillShow")) { - const value_casted = value as (Function0) - this.getPeer()?.onWillShowAttribute(value_casted) - return this - } - return this - } - /** @memo */ - onWillHide(value: Function0): this { - if (this.checkPriority("onWillHide")) { - const value_casted = value as (Function0) - this.getPeer()?.onWillHideAttribute(value_casted) - return this - } - return this - } - /** @memo */ - systemBarStyle(value?: SystemBarStyle): this { - if (this.checkPriority("systemBarStyle")) { - const value_casted = value as (SystemBarStyle | undefined) - this.getPeer()?.systemBarStyleAttribute(value_casted) - return this - } - return this - } - /** @memo */ - recoverable(value?: boolean): this { - if (this.checkPriority("recoverable")) { - const value_casted = value as (boolean | undefined) - this.getPeer()?.recoverableAttribute(value_casted) - return this - } - return this - } - /** @memo */ - systemTransition(value: NavigationSystemTransitionType): this { - if (this.checkPriority("systemTransition")) { - const value_casted = value as (NavigationSystemTransitionType) - this.getPeer()?.systemTransitionAttribute(value_casted) - return this - } - return this - } - /** @memo */ - bindToScrollable(value: Array): this { - if (this.checkPriority("bindToScrollable")) { - const value_casted = value as (Array) - this.getPeer()?.bindToScrollableAttribute(value_casted) - return this - } - return this - } - /** @memo */ - bindToNestedScrollable(value: Array): this { - if (this.checkPriority("bindToNestedScrollable")) { - const value_casted = value as (Array) - this.getPeer()?.bindToNestedScrollableAttribute(value_casted) - return this - } - return this - } - /** @memo */ - title(value: string | CustomBuilder | NavDestinationCommonTitle | NavDestinationCustomTitle | Resource, options?: NavigationTitleOptions): this { - if (this.checkPriority("title")) { - const value_casted = value as (string | CustomBuilder | NavDestinationCommonTitle | NavDestinationCustomTitle | Resource) - const options_casted = options as (NavigationTitleOptions | undefined) - this.getPeer()?.titleAttribute(value_casted, options_casted) - return this - } - return this - } - /** @memo */ - toolbarConfiguration(toolbarParam: Array | CustomBuilder, options?: NavigationToolbarOptions): this { - if (this.checkPriority("toolbarConfiguration")) { - const toolbarParam_casted = toolbarParam as (Array | CustomBuilder) - const options_casted = options as (NavigationToolbarOptions | undefined) - this.getPeer()?.toolbarConfigurationAttribute(toolbarParam_casted, options_casted) - return this - } - return this - } - /** @memo */ - hideToolBar(hide: boolean, animated?: boolean): this { - if (this.checkPriority("hideToolBar")) { - const hide_casted = hide as (boolean) - const animated_casted = animated as (boolean | undefined) - this.getPeer()?.hideToolBarAttribute(hide_casted, animated_casted) - return this - } - return this - } - /** @memo */ - ignoreLayoutSafeArea(types?: Array, edges?: Array): this { - if (this.checkPriority("ignoreLayoutSafeArea")) { - const types_casted = types as (Array | undefined) - const edges_casted = edges as (Array | undefined) - this.getPeer()?.ignoreLayoutSafeAreaAttribute(types_casted, edges_casted) - return this - } - return this - } - public applyAttributesFinish(): void { - // we calls this function outside of class, so need to make it public - super.applyAttributesFinish() - } -} - -/** @memo */ -export function ArkNavDestination( - /** @memo */ - style: ((attributes: ArkNavDestinationComponent) => void) | undefined, - /** @memo */ - content_: (() => void) | undefined, - -) { - const receiver = remember(() => { - return new ArkNavDestinationComponent() - }) - NodeAttach((): ArkNavDestinationPeer => ArkNavDestinationPeer.create(receiver), (_: ArkNavDestinationPeer) => { - receiver.setNavDestinationOptions() - style?.(receiver) - content_?.() - receiver.applyAttributesFinish() - }) -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { int32 } from "@koalaui/common" +import { KStringPtr, KBoolean } from "@koalaui/interop" +import { NodeAttach, remember } from "@koalaui/runtime" +import { runtimeType, RuntimeType, isResource, isInstanceOf } from "../generated/peers/SerializerBase" +import { ComponentBase } from "../generated/ComponentBase" +import { TypeChecker } from "#components" +import { ArkCommonMethodComponent } from "../generated/ArkCommon" +import { ArkNavDestinationPeer } from "./peers/ArkNavDestinationPeer" +import { UseEventsProperties } from "../generated/use_properties" +import { CommonMethod, SymbolGlyphModifier, CustomBuilder, LayoutSafeAreaType, LayoutSafeAreaEdge } from "../generated/ArkCommonInterfaces" +import { NavDestinationAttribute, NavDestinationMode, NavigationSystemTransitionType, NestedScrollInfo, NavDestinationCommonTitle, NavDestinationCustomTitle } from "../generated/ArkNavDestinationInterfaces" +import { Callback_Void, Callback_Boolean, Callback_NavDestinationContext_Void } from "../generated/SyntheticDeclarations" +import { ResourceStr } from "../generated/ArkUnitsInterfaces" +import { PixelMap } from "../generated/ArkArkui-externalInterfaces" +import { NavigationMenuItem, SystemBarStyle, NavigationTitleOptions, ToolbarItem, NavigationToolbarOptions } from "../generated/ArkNavigationInterfaces" +import { NavDestinationContext } from "../generated/ArkNavDestinationContextMaterialized" +import { Scroller } from "../generated/ArkScrollerMaterialized" +import { Resource } from "../generated/ArkResourceInterfaces" +/** @memo:stable */ +export class ArkNavDestinationComponent extends ArkCommonMethodComponent { + getPeer(): ArkNavDestinationPeer { + return (this.peer as ArkNavDestinationPeer) + } + /** @memo */ + setNavDestinationOptions(): this { + if (this.checkPriority("setNavDestinationOptions")) { + this.getPeer()?.setNavDestinationOptionsAttribute() + return this + } + return this + } + /** @memo */ + hideTitleBar(hide: boolean, animated?: boolean): this { + if (this.checkPriority("hideTitleBar")) { + const hide_type = runtimeType(hide) + const animated_type = runtimeType(animated) + if ((((RuntimeType.BOOLEAN == hide_type))) && (((RuntimeType.BOOLEAN == animated_type)))) { + const hide_casted = hide as (boolean) + const animated_casted = animated as (boolean) + this.getPeer()?.hideTitleBar1Attribute(hide_casted, animated_casted) + return this + } + if ((((RuntimeType.BOOLEAN == hide_type))) && (((RuntimeType.UNDEFINED == animated_type)))) { + const hide_casted = hide as (boolean) + this.getPeer()?.hideTitleBar0Attribute(hide_casted) + return this + } + throw new Error("Can not select appropriate overload") + } + return this + } + /** @memo */ + onShown(value: Function0): this { + if (this.checkPriority("onShown")) { + const value_casted = value as (Function0) + this.getPeer()?.onShownAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onHidden(value: Function0): this { + if (this.checkPriority("onHidden")) { + const value_casted = value as (Function0) + this.getPeer()?.onHiddenAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onBackPressed(value: Function0): this { + if (this.checkPriority("onBackPressed")) { + const value_casted = value as (Function0) + this.getPeer()?.onBackPressedAttribute(value_casted) + return this + } + return this + } + /** @memo */ + mode(value: NavDestinationMode): this { + if (this.checkPriority("mode")) { + const value_casted = value as (NavDestinationMode) + this.getPeer()?.modeAttribute(value_casted) + return this + } + return this + } + /** @memo */ + backButtonIcon(value: ResourceStr | PixelMap | SymbolGlyphModifier): this { + if (this.checkPriority("backButtonIcon")) { + const value_casted = value as (ResourceStr | PixelMap | SymbolGlyphModifier) + this.getPeer()?.backButtonIconAttribute(value_casted) + return this + } + return this + } + /** @memo */ + menus(value: Array | CustomBuilder): this { + if (this.checkPriority("menus")) { + const value_casted = value as (Array | CustomBuilder) + this.getPeer()?.menusAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onReady(value: Function1): this { + if (this.checkPriority("onReady")) { + const value_casted = value as (Function1) + this.getPeer()?.onReadyAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onWillAppear(value: Function0): this { + if (this.checkPriority("onWillAppear")) { + const value_casted = value as (Function0) + this.getPeer()?.onWillAppearAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onWillDisappear(value: Function0): this { + if (this.checkPriority("onWillDisappear")) { + const value_casted = value as (Function0) + this.getPeer()?.onWillDisappearAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onWillShow(value: Function0): this { + if (this.checkPriority("onWillShow")) { + const value_casted = value as (Function0) + this.getPeer()?.onWillShowAttribute(value_casted) + return this + } + return this + } + /** @memo */ + onWillHide(value: Function0): this { + if (this.checkPriority("onWillHide")) { + const value_casted = value as (Function0) + this.getPeer()?.onWillHideAttribute(value_casted) + return this + } + return this + } + /** @memo */ + systemBarStyle(value?: SystemBarStyle): this { + if (this.checkPriority("systemBarStyle")) { + const value_casted = value as (SystemBarStyle | undefined) + this.getPeer()?.systemBarStyleAttribute(value_casted) + return this + } + return this + } + /** @memo */ + recoverable(value?: boolean): this { + if (this.checkPriority("recoverable")) { + const value_casted = value as (boolean | undefined) + this.getPeer()?.recoverableAttribute(value_casted) + return this + } + return this + } + /** @memo */ + systemTransition(value: NavigationSystemTransitionType): this { + if (this.checkPriority("systemTransition")) { + const value_casted = value as (NavigationSystemTransitionType) + this.getPeer()?.systemTransitionAttribute(value_casted) + return this + } + return this + } + /** @memo */ + bindToScrollable(value: Array): this { + if (this.checkPriority("bindToScrollable")) { + const value_casted = value as (Array) + this.getPeer()?.bindToScrollableAttribute(value_casted) + return this + } + return this + } + /** @memo */ + bindToNestedScrollable(value: Array): this { + if (this.checkPriority("bindToNestedScrollable")) { + const value_casted = value as (Array) + this.getPeer()?.bindToNestedScrollableAttribute(value_casted) + return this + } + return this + } + /** @memo */ + title(value: string | CustomBuilder | NavDestinationCommonTitle | NavDestinationCustomTitle | Resource, options?: NavigationTitleOptions): this { + if (this.checkPriority("title")) { + const value_casted = value as (string | CustomBuilder | NavDestinationCommonTitle | NavDestinationCustomTitle | Resource) + const options_casted = options as (NavigationTitleOptions | undefined) + this.getPeer()?.titleAttribute(value_casted, options_casted) + return this + } + return this + } + /** @memo */ + toolbarConfiguration(toolbarParam: Array | CustomBuilder, options?: NavigationToolbarOptions): this { + if (this.checkPriority("toolbarConfiguration")) { + const toolbarParam_casted = toolbarParam as (Array | CustomBuilder) + const options_casted = options as (NavigationToolbarOptions | undefined) + this.getPeer()?.toolbarConfigurationAttribute(toolbarParam_casted, options_casted) + return this + } + return this + } + /** @memo */ + hideToolBar(hide: boolean, animated?: boolean): this { + if (this.checkPriority("hideToolBar")) { + const hide_casted = hide as (boolean) + const animated_casted = animated as (boolean | undefined) + this.getPeer()?.hideToolBarAttribute(hide_casted, animated_casted) + return this + } + return this + } + /** @memo */ + ignoreLayoutSafeArea(types?: Array, edges?: Array): this { + if (this.checkPriority("ignoreLayoutSafeArea")) { + const types_casted = types as (Array | undefined) + const edges_casted = edges as (Array | undefined) + this.getPeer()?.ignoreLayoutSafeAreaAttribute(types_casted, edges_casted) + return this + } + return this + } + public applyAttributesFinish(): void { + // we calls this function outside of class, so need to make it public + super.applyAttributesFinish() + } +} + +/** @memo */ +export function ArkNavDestination( + /** @memo */ + style: ((attributes: ArkNavDestinationComponent) => void) | undefined, + /** @memo */ + content_: (() => void) | undefined, + +) { + const receiver = remember(() => { + return new ArkNavDestinationComponent() + }) + NodeAttach((): ArkNavDestinationPeer => ArkNavDestinationPeer.create(receiver), (_: ArkNavDestinationPeer) => { + receiver.setNavDestinationOptions() + style?.(receiver) + content_?.() + receiver.applyAttributesFinish() + }) +} diff --git a/arkoala-arkts/arkui/src/handwritten/ArkNavPatchInfo.ts b/arkoala-arkts/arkui/src/handwritten/ArkNavPatchInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa1b4576798d9a1ec48574631613ce259a227712 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/ArkNavPatchInfo.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { PopInfo } from "../generated/ArkNavigationInterfaces" + +/** + * Represents navigation path information. + */ +export class NavPathInfo { + /** + * Creates an instance of NavPathInfo. + * @param name - The name of the navigation path. + * @param param - Additional parameters associated with the path. + * @param onPop - Optional callback invoked when the path is popped. + * @param isEntry - Indicates if this path is an entry point. + */ + constructor( + public name: string, + public param?: unknown, + public onPop?: (parameter: PopInfo) => void, + public isEntry: boolean = false + ) { + // Initialization logic can be added here if needed + } + + /** + * Handles the pop action for the navigation path. + * @param parameter - Information about the pop event. + */ + handlePop(parameter: PopInfo): void { + if (this.onPop) { + this.onPop(parameter) + } + } + + /** + * Checks if the navigation path is an entry point. + * @returns True if it's an entry path, otherwise false. + */ + isEntryPoint(): boolean { + return this.isEntry + } +} diff --git a/arkoala-arkts/arkui/src/handwritten/ArkNavPatchStack.ts b/arkoala-arkts/arkui/src/handwritten/ArkNavPatchStack.ts new file mode 100644 index 0000000000000000000000000000000000000000..e13d8624c6ee2e64d995a2a844a6b94afdca33a4 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/ArkNavPatchStack.ts @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NavPathInfo, NavigationOptions, PopInfo, NavigationInterception } from "../generated/ArkNavigationInterfaces"; + +/** + * Represents a stack of navigation paths. + */ +export class NavPathStack { + private stack: NavPathInfo[] = [] + private parentStack?: NavPathStack + private interception?: NavigationInterception + private animationsDisabled: boolean = false + + /** + * Creates an instance of NavPathStack. + */ + constructor() { + // Initialization logic can be added here if needed + } + + /** + * Pushes a navigation path onto the stack. + * @param info - The navigation path information. + * @param animated - Optional flag to animate the transition. + */ + pushPath(info: NavPathInfo, animated: boolean = true): void { + if (!this.animationsDisabled && animated) { + // Perform animation logic + } + this.stack.push(info) + } + + /** + * Pushes a destination onto the stack asynchronously. + * @param info - The navigation path information. + * @param animated - Optional flag to animate the transition. + * @returns A promise that resolves when the destination is pushed. + */ + pushDestination(info: NavPathInfo, animated: boolean = true): Promise { + return new Promise((resolve) => { + this.pushPath(info, animated) + resolve() + }) + } + + /** + * Replaces the current navigation path with a new one. + * @param info - The new navigation path information. + * @param animated - Optional flag to animate the transition. + */ + replacePath(info: NavPathInfo, animated: boolean = true): void { + if (this.stack.length > 0) { + this.popToIndex(this.stack.length - 1, {}, animated) + } + this.pushPath(info, animated) + } + + /** + * Pops the stack to the specified index with an optional result. + * @param index - The index to pop to. + * @param result - The result to pass back. + * @param animated - Optional flag to animate the transition. + */ + popToIndex(index: number, result: Object, animated: boolean = true): void { + if (index < 0 || index >= this.stack.length) { + throw new Error("Index out of bounds") + } + + while (this.stack.length > index + 1) { + const popped = this.stack.pop() + if (popped && popped.onPop) { + // Создаем объект PopInfo с корректным NavPathInfo + const popInfo: PopInfo = { + info: popped, // `popped` уже должен быть типа NavPathInfo + result: result, + } + + // Передаем объект popInfo в onPop + popped.onPop(popInfo) + } + } + if (!this.animationsDisabled && animated) { + // Perform animation logic + } + } + + /** + * Clears all navigation paths from the stack. + * @param animated - Optional flag to animate the clearing. + */ + clear(animated: boolean = true): void { + while (this.stack.length > 0) { + const popped = this.stack.pop() + if (popped && popped.onPop) { + const popInfo: PopInfo = { + info: popped, + result: {}, + } + popped.onPop(popInfo) + } + } + if (!this.animationsDisabled && animated) { + // Perform animation logic + } + } + + /** + * Retrieves the names of all navigation paths in the stack. + * @returns An array of path names. + */ + getAllPathName(): string[] { + return this.stack.map((path) => path.name) + } + + /** + * Retrieves the size of the stack. + * @returns The number of paths in the stack. + */ + size(): number { + return this.stack.length + } + + /** + * Disables or enables animations for navigation transitions. + * @param value - True to disable animations, false to enable. + */ + disableAnimation(value: boolean): void { + this.animationsDisabled = value + } + + /** + * Sets the navigation interception handler. + * @param interception - The navigation interception handler. + */ + setInterception(interception: NavigationInterception): void { + this.interception = interception + } + + /** + * Retrieves the parent navigation path stack, if any. + * @returns The parent NavPathStack or undefined if there is no parent. + */ + getParent(): NavPathStack | undefined { + return this.parentStack + } +} diff --git a/arkoala-arkts/arkui/src/generated/peers/ArkNavDestinationPeer.ts b/arkoala-arkts/arkui/src/handwritten/peers/ArkNavDestinationPeer.ts similarity index 87% rename from arkoala-arkts/arkui/src/generated/peers/ArkNavDestinationPeer.ts rename to arkoala-arkts/arkui/src/handwritten/peers/ArkNavDestinationPeer.ts index 9f6bc280dd14cd41d6319340d1ba24416f5a7dcd..6affb7dfd26577a4c3ffc11aeecda8fe575fcb3c 100644 --- a/arkoala-arkts/arkui/src/generated/peers/ArkNavDestinationPeer.ts +++ b/arkoala-arkts/arkui/src/handwritten/peers/ArkNavDestinationPeer.ts @@ -18,41 +18,44 @@ import { int32 } from "@koalaui/common" import { nullptr, KPointer, KInt, KBoolean, KStringPtr } from "@koalaui/interop" -import { isResource, isInstanceOf, runtimeType, RuntimeType } from "./SerializerBase" -import { Serializer } from "./Serializer" -import { ArkUINodeType } from "./ArkUINodeType" -import { ComponentBase } from "../ComponentBase" -import { PeerNode } from "../PeerNode" +import { isResource, isInstanceOf, runtimeType, RuntimeType } from "../../generated/peers/SerializerBase" +import { Serializer } from "../../generated/peers/Serializer" +import { ArkUINodeType } from "../../generated/peers/ArkUINodeType" +import { ComponentBase } from "../../generated/ComponentBase" +import { PeerNode } from "../../generated/PeerNode" import { NativeModule } from "#components" -import { ArkCommonMethodPeer, ArkCommonMethodAttributes } from "./ArkCommonPeer" -import { CommonMethod, SymbolGlyphModifier, CustomBuilder, LayoutSafeAreaType, LayoutSafeAreaEdge } from "./../ArkCommonInterfaces" -import { NavDestinationAttribute, NavDestinationMode, NavigationSystemTransitionType, NestedScrollInfo, NavDestinationCommonTitle, NavDestinationCustomTitle } from "./../ArkNavDestinationInterfaces" -import { Callback_Void, Callback_Boolean, Callback_NavDestinationContext_Void } from "./../SyntheticDeclarations" -import { ResourceStr } from "./../ArkUnitsInterfaces" -import { PixelMap } from "./../ArkPixelMapMaterialized" -import { NavigationMenuItem, SystemBarStyle, NavigationTitleOptions, ToolbarItem, NavigationToolbarOptions } from "./../ArkNavigationInterfaces" -import { NavDestinationContext } from "./../ArkNavDestinationContextMaterialized" -import { Scroller } from "./../ArkScrollerMaterialized" -import { Resource } from "./../ArkResourceInterfaces" -import { GestureName, GestureComponent } from "./../shared/generated-utils" -import { CallbackKind } from "./CallbackKind" -import { CallbackTransformer } from "./CallbackTransformer" +import { ArkCommonMethodPeer, ArkCommonMethodAttributes } from "../../generated/peers/ArkCommonPeer" +import { CommonMethod, SymbolGlyphModifier, CustomBuilder, LayoutSafeAreaType, LayoutSafeAreaEdge } from "../../generated/ArkCommonInterfaces" +import { NavDestinationAttribute, NavDestinationMode, NavigationSystemTransitionType, NestedScrollInfo, NavDestinationCommonTitle, NavDestinationCustomTitle } from "../../generated/ArkNavDestinationInterfaces" +import { Callback_Void, Callback_Boolean, Callback_NavDestinationContext_Void, Callback_Any } from "../../generated/SyntheticDeclarations" +import { ResourceStr } from "../../generated/ArkUnitsInterfaces" +import { PixelMap } from "../../generated/ArkArkui-externalInterfaces" +import { NavigationMenuItem, SystemBarStyle, NavigationTitleOptions, ToolbarItem, NavigationToolbarOptions } from "../../generated/ArkNavigationInterfaces" +import { NavDestinationContext } from "../../generated/ArkNavDestinationContextMaterialized" +import { Scroller } from "../../generated/ArkScrollerMaterialized" +import { Resource } from "../../generated/ArkResourceInterfaces" +import { GestureName, GestureComponent } from "../../generated/shared/generated-utils" +import { CallbackKind } from "../../generated/peers/CallbackKind" import { TypeChecker } from "#components" -import { registerCallback } from "./SerializerBase" +import { registerCallback } from "../../generated/peers/SerializerBase" import { wrapCallback } from "@koalaui/interop" -import { MaterializedBase } from "./../MaterializedBase" -import { DotIndicator } from "./../ArkDotIndicatorBuilder" -import { DigitIndicator } from "./../ArkDigitIndicatorBuilder" -import { SubTabBarStyle } from "./../ArkSubTabBarStyleBuilder" -import { BottomTabBarStyle } from "./../ArkBottomTabBarStyleBuilder" +import { MaterializedBase } from "../../generated/MaterializedBase" +import { DotIndicator } from "../../generated/ArkDotIndicatorBuilder" +import { DigitIndicator } from "../../generated/ArkDigitIndicatorBuilder" +import { SubTabBarStyle } from "../../generated/ArkSubTabBarStyleBuilder" +import { BottomTabBarStyle } from "../../generated/ArkBottomTabBarStyleBuilder" export class ArkNavDestinationPeer extends ArkCommonMethodPeer { - protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { - super(peerPtr, id, name, flags) + protected constructor(peerPtr: KPointer, name: string = "", flags: int32 = 0) { + super(peerPtr, name, flags) } public static create(component?: ComponentBase, flags: int32 = 0): ArkNavDestinationPeer { - const peerId = PeerNode.nextId() - const _peerPtr = NativeModule._NavDestination_construct(peerId, flags) - const _peer = new ArkNavDestinationPeer(_peerPtr, peerId, "NavDestination", flags) + /** + TODO: Edit PeersPrinter and USE this line + const _peerPtr = NativeModule._NavDestination_construct(PeerNode.nextId(), flags) + */ + const nodeType = ArkUINodeType.CustomNode // !!!!делаем вместо ArkUINodeType.NavDestination + const _peerPtr = NativeModule._CreateNode(nodeType as int32, PeerNode.nextId(), flags) + const _peer = new ArkNavDestinationPeer(_peerPtr, "NavDestination", flags) component?.setPeer(_peer) return _peer } @@ -106,7 +109,7 @@ export class ArkNavDestinationPeer extends ArkCommonMethodPeer { thisSerializer.writeResource(value_0_1) } } - else if (((RuntimeType.OBJECT) == (value_type)) && (value instanceof PixelMap)) { + else if (((RuntimeType.OBJECT) == (value_type)) && (TypeChecker.isPixelMap(value, false, false))) { thisSerializer.writeInt8(1 as int32) const value_1 = value as PixelMap thisSerializer.writePixelMap(value_1) @@ -135,7 +138,7 @@ export class ArkNavDestinationPeer extends ArkCommonMethodPeer { else if (((RuntimeType.FUNCTION == value_type))) { thisSerializer.writeInt8(1 as int32) const value_1 = value as CustomBuilder - thisSerializer.holdAndWriteCallback(CallbackTransformer.transformFromCustomBuilder(value_1)) + thisSerializer.holdAndWriteCallback(value_1) } NativeModule._NavDestinationAttribute_menus(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length()) thisSerializer.release() @@ -229,7 +232,7 @@ export class ArkNavDestinationPeer extends ArkCommonMethodPeer { else if (((RuntimeType.FUNCTION == value_type))) { thisSerializer.writeInt8(1 as int32) const value_1 = value as CustomBuilder - thisSerializer.holdAndWriteCallback(CallbackTransformer.transformFromCustomBuilder(value_1)) + thisSerializer.holdAndWriteCallback(value_1) } else if (((RuntimeType.OBJECT) == (value_type)) && (TypeChecker.isNavDestinationCommonTitle(value, false, false))) { thisSerializer.writeInt8(2 as int32) @@ -272,7 +275,7 @@ export class ArkNavDestinationPeer extends ArkCommonMethodPeer { else if (((RuntimeType.FUNCTION == toolbarParam_type))) { thisSerializer.writeInt8(1 as int32) const toolbarParam_1 = toolbarParam as CustomBuilder - thisSerializer.holdAndWriteCallback(CallbackTransformer.transformFromCustomBuilder(toolbarParam_1)) + thisSerializer.holdAndWriteCallback(toolbarParam_1) } let options_type : int32 = RuntimeType.UNDEFINED options_type = runtimeType(options)