diff --git a/arkoala-arkts/arkui/src/ArkCustomComponent.ts b/arkoala-arkts/arkui/src/ArkCustomComponent.ts index 803efe952d1311f54104d89a331846e4b205a070..c3ebed74418c8e10a4ac0dea96aa56c5a3b34791 100644 --- a/arkoala-arkts/arkui/src/ArkCustomComponent.ts +++ b/arkoala-arkts/arkui/src/ArkCustomComponent.ts @@ -67,6 +67,8 @@ export interface ArkCustomComponent { } export class ArkCustomComponentImpl implements ArkCustomComponent { + setInstanceId(value: number): void {} + /** @memo */ build(): void { } diff --git a/arkoala-arkts/arkui/src/generated/ArkColumn.ts b/arkoala-arkts/arkui/src/generated/ArkColumn.ts index 7429c739aee283cdc5fbbfbba89aeced4f39a4ef..b6c5cd7ba9dd7c29c34dac9a6fd0fa20f9b6a192 100644 --- a/arkoala-arkts/arkui/src/generated/ArkColumn.ts +++ b/arkoala-arkts/arkui/src/generated/ArkColumn.ts @@ -49,12 +49,26 @@ import { GestureModifier } from "./ArkGestureModifierMaterialized" import { GestureInfo, GestureJudgeResult, GestureType, GestureMask } from "./ArkGestureInterfaces" import { BaseGestureEvent } from "./ArkBaseGestureEventMaterialized" import { PixelMap } from "./ArkPixelMapMaterialized" -import { ColumnOptions, ColumnAttribute } from "./ArkColumnInterfaces" +import { ColumnOptions, ColumnAttribute, ColumnInterface } from "./ArkColumnInterfaces" +import { AttributeUpdater } from "../handwritten/modifiers/ArkAttributeUpdater" +import { ArkColumnNode } from "../handwritten/modifiers/ArkColumnNode" +import { ArkColumnAttributeSet } from "../handwritten/modifiers/ArkColumnModifier" +import { applyUIAttributes } from "../handwritten/modifiers/ArkCommonModifier" + /** @memo:stable */ export class ArkColumnComponent extends ArkCommonMethodComponent { getPeer(): ArkColumnPeer { return (this.peer as ArkColumnPeer) } + + getModifierHost(): ArkColumnNode { + if (this._modifierHost === undefined || this._modifierHost === null) { + this._modifierHost = new ArkColumnNode() + this._modifierHost!.setPeer(this.getPeer()) + } + return this._modifierHost as ArkColumnNode + } + /** @memo */ public setColumnOptions(options?: ColumnOptions): this { if (this.checkPriority("setColumnOptions")) { @@ -100,6 +114,24 @@ export class ArkColumnComponent extends ArkCommonMethodComponent { } return this } + + attributeModifier(modifier: AttributeModifier): this { + let attributeUpdater = modifier as AttributeUpdater + attributeUpdater.attribute = this.getModifierHost() + if (modifier.isUpdater) { + let attributeUpdater = modifier as AttributeUpdater + attributeUpdater.attribute = this.getModifierHost() + } else { + let peerNode = this.getPeer() + if (!peerNode._attributeSet) { + peerNode._attributeSet = new ArkColumnAttributeSet() + } + applyUIAttributes(modifier, peerNode); + peerNode._attributeSet!.applyModifierPatch(peerNode); + } + return this + } + public applyAttributesFinish(): void { // we calls this function outside of class, so need to make it public super.applyAttributesFinish() diff --git a/arkoala-arkts/arkui/src/generated/ArkColumnInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkColumnInterfaces.ts index 67e0867d3579bba7e72a472c160cd7f675cf7843..f77ed4d92f3de9a3aee900f98e103159dfaa897c 100644 --- a/arkoala-arkts/arkui/src/generated/ArkColumnInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkColumnInterfaces.ts @@ -19,7 +19,7 @@ import { int32, int64, float32 } from "@koalaui/common" import { KInt, KPointer, KBoolean, KStringPtr, wrapCallback, NativeBuffer } from "@koalaui/interop" import { NodeAttach, remember } from "@koalaui/runtime" -import { CommonMethod, Rectangle, TouchTestInfo, TouchResult, PixelRoundPolicy, BackgroundEffectOptions, ForegroundEffectOptions, VisualEffect, Filter, BorderImageOption, OutlineStyle, AccessibilityCallback, AnimateParam, TransitionOptions, MotionBlurOptions, InvertOptions, TranslateOptions, ScaleOptions, RotateOptions, AlignRuleOption, LocalizedAlignRuleOptions, ClickEffect, CustomBuilder, DragItemInfo, UniformDataType, PreDragStatus, MotionPathOptions, ShadowOptions, ShadowStyle, StateStyles, PixelStretchEffectOptions, BackgroundBrightnessOptions, GestureRecognizerJudgeBeginCallback, ShouldBuiltInRecognizerParallelWithCallback, SizeChangeCallback, SafeAreaType, SafeAreaEdge, BlurStyle, BackgroundBlurStyleOptions, ForegroundBlurStyleOptions, TransitionFinishCallback, BlurOptions, LinearGradientBlurOptions, EffectType, sharedTransitionOptions, ChainStyle, DragPreviewOptions, DragInteractionOptions, ComponentContent, OverlayOptions, BlendMode, BlendApplyType, Blender, GeometryTransitionOptions, PopupOptions, CustomPopupOptions, MenuElement, MenuOptions, ContextMenuOptions, ModalTransition, ContentCoverOptions, SheetOptions, VisibleAreaChangeCallback, PointLightStyle } from "./ArkCommonInterfaces" +import { CommonMethod, Rectangle, TouchTestInfo, TouchResult, PixelRoundPolicy, BackgroundEffectOptions, ForegroundEffectOptions, VisualEffect, Filter, BorderImageOption, OutlineStyle, AccessibilityCallback, AnimateParam, TransitionOptions, MotionBlurOptions, InvertOptions, TranslateOptions, ScaleOptions, RotateOptions, AlignRuleOption, LocalizedAlignRuleOptions, ClickEffect, CustomBuilder, DragItemInfo, UniformDataType, PreDragStatus, MotionPathOptions, ShadowOptions, ShadowStyle, StateStyles, PixelStretchEffectOptions, BackgroundBrightnessOptions, GestureRecognizerJudgeBeginCallback, ShouldBuiltInRecognizerParallelWithCallback, SizeChangeCallback, SafeAreaType, SafeAreaEdge, BlurStyle, BackgroundBlurStyleOptions, ForegroundBlurStyleOptions, TransitionFinishCallback, BlurOptions, LinearGradientBlurOptions, EffectType, sharedTransitionOptions, ChainStyle, DragPreviewOptions, DragInteractionOptions, ComponentContent, OverlayOptions, BlendMode, BlendApplyType, Blender, GeometryTransitionOptions, PopupOptions, CustomPopupOptions, MenuElement, MenuOptions, ContextMenuOptions, ModalTransition, ContentCoverOptions, SheetOptions, VisibleAreaChangeCallback, PointLightStyle, CommonAttribute } from "./ArkCommonInterfaces" import { Length, SizeOptions, ConstraintSizeOptions, ChainWeightOptions, Padding, LocalizedPadding, Margin, LocalizedMargin, ResourceColor, Position, BorderOptions, EdgeStyles, EdgeWidths, LocalizedEdgeWidths, EdgeColors, LocalizedEdgeColors, BorderRadiuses, LocalizedBorderRadiuses, OutlineOptions, EdgeOutlineStyles, Dimension, EdgeOutlineWidths, OutlineRadiuses, Area, Edges, LocalizedEdges, LocalizedPosition, ResourceStr, AccessibilityOptions } from "./ArkUnitsInterfaces" import { DrawModifier } from "./ArkDrawModifierMaterialized" import { HitTestMode, ImageSize, Alignment, BorderStyle, ColoringStrategy, HoverEffect, Color, Visibility, ItemAlign, Direction, GradientDirection, ObscuredReasons, RenderFit, ImageRepeat, Axis, ResponseType, FunctionKey, ModifierKey, HorizontalAlign, FlexAlign } from "./ArkEnumsInterfaces" @@ -49,9 +49,9 @@ export interface ColumnOptions { space?: string | number; } export type ColumnInterface = (options?: ColumnOptions) => ColumnAttribute; -export interface ColumnAttribute extends CommonMethod { - alignItems: HorizontalAlign; - justifyContent: FlexAlign; - pointLight: PointLightStyle; - reverse: boolean | undefined; +export interface ColumnAttribute extends CommonAttribute { + alignItems(value: HorizontalAlign | undefined): this; + // justifyContent: FlexAlign; + // pointLight: PointLightStyle; + // reverse: boolean | undefined; } diff --git a/arkoala-arkts/arkui/src/generated/ArkCommon.ts b/arkoala-arkts/arkui/src/generated/ArkCommon.ts index 9cb630d2dd131b5407dabce2bdbef359df15fd73..502af25614aceff7d7b994d6d44a112f3a8c237a 100644 --- a/arkoala-arkts/arkui/src/generated/ArkCommon.ts +++ b/arkoala-arkts/arkui/src/generated/ArkCommon.ts @@ -24,7 +24,7 @@ import { TypeChecker } from "#components" import { ArkCommonMethodPeer, ArkCommonShapeMethodPeer, ArkCommonPeer, ArkScrollableCommonMethodPeer } from "./peers/ArkCommonPeer" import { Length, SizeOptions, ConstraintSizeOptions, ChainWeightOptions, Padding, LocalizedPadding, Margin, LocalizedMargin, ResourceColor, Position, BorderOptions, EdgeStyles, EdgeWidths, LocalizedEdgeWidths, EdgeColors, LocalizedEdgeColors, BorderRadiuses, LocalizedBorderRadiuses, OutlineOptions, EdgeOutlineStyles, Dimension, EdgeOutlineWidths, OutlineRadiuses, Area, Edges, LocalizedEdges, LocalizedPosition, ResourceStr, AccessibilityOptions } from "./ArkUnitsInterfaces" import { DrawModifier } from "./ArkDrawModifierMaterialized" -import { Rectangle, TouchTestInfo, TouchResult, PixelRoundPolicy, BackgroundEffectOptions, ForegroundEffectOptions, VisualEffect, Filter, BorderImageOption, OutlineStyle, AccessibilityCallback, AnimateParam, TransitionOptions, MotionBlurOptions, InvertOptions, TranslateOptions, ScaleOptions, RotateOptions, AlignRuleOption, LocalizedAlignRuleOptions, ClickEffect, CustomBuilder, DragItemInfo, UniformDataType, PreDragStatus, MotionPathOptions, ShadowOptions, ShadowStyle, StateStyles, PixelStretchEffectOptions, BackgroundBrightnessOptions, GestureRecognizerJudgeBeginCallback, ShouldBuiltInRecognizerParallelWithCallback, SizeChangeCallback, SafeAreaType, SafeAreaEdge, BlurStyle, BackgroundBlurStyleOptions, ForegroundBlurStyleOptions, TransitionFinishCallback, BlurOptions, LinearGradientBlurOptions, EffectType, sharedTransitionOptions, ChainStyle, DragPreviewOptions, DragInteractionOptions, ComponentContent, OverlayOptions, BlendMode, BlendApplyType, Blender, GeometryTransitionOptions, PopupOptions, CustomPopupOptions, MenuElement, MenuOptions, ContextMenuOptions, ModalTransition, ContentCoverOptions, SheetOptions, VisibleAreaChangeCallback, CommonMethod, CommonAttribute, NestedScrollOptions, ContentClipMode, EdgeEffectOptions, FadingEdgeOptions } from "./ArkCommonInterfaces" +import { Rectangle, TouchTestInfo, TouchResult, PixelRoundPolicy, BackgroundEffectOptions, ForegroundEffectOptions, VisualEffect, Filter, BorderImageOption, OutlineStyle, AccessibilityCallback, AnimateParam, TransitionOptions, MotionBlurOptions, InvertOptions, TranslateOptions, ScaleOptions, RotateOptions, AlignRuleOption, LocalizedAlignRuleOptions, ClickEffect, CustomBuilder, DragItemInfo, UniformDataType, PreDragStatus, MotionPathOptions, ShadowOptions, ShadowStyle, StateStyles, PixelStretchEffectOptions, BackgroundBrightnessOptions, GestureRecognizerJudgeBeginCallback, ShouldBuiltInRecognizerParallelWithCallback, SizeChangeCallback, SafeAreaType, SafeAreaEdge, BlurStyle, BackgroundBlurStyleOptions, ForegroundBlurStyleOptions, TransitionFinishCallback, BlurOptions, LinearGradientBlurOptions, EffectType, sharedTransitionOptions, ChainStyle, DragPreviewOptions, DragInteractionOptions, ComponentContent, OverlayOptions, BlendMode, BlendApplyType, Blender, GeometryTransitionOptions, PopupOptions, CustomPopupOptions, MenuElement, MenuOptions, ContextMenuOptions, ModalTransition, ContentCoverOptions, SheetOptions, VisibleAreaChangeCallback, CommonMethod, CommonAttribute, NestedScrollOptions, ContentClipMode, EdgeEffectOptions, FadingEdgeOptions, CommonInterface } from "./ArkCommonInterfaces" import { HitTestMode, ImageSize, Alignment, BorderStyle, ColoringStrategy, HoverEffect, Color, Visibility, ItemAlign, Direction, GradientDirection, ObscuredReasons, RenderFit, ImageRepeat, Axis, ResponseType, FunctionKey, ModifierKey, LineCapStyle, LineJoinStyle, BarState, EdgeEffect } from "./ArkEnumsInterfaces" import { Callback_Array_TouchTestInfo_TouchResult, Callback_ClickEvent_Void, Callback_Boolean_HoverEvent_Void, Callback_MouseEvent_Void, Callback_TouchEvent_Void, Callback_KeyEvent_Void, Callback_KeyEvent_Boolean, Callback_Void, Callback_Area_Area_Void, Literal_Union_Number_Literal_Number_offset_span_lg_md_sm_xs, Literal_Number_offset_span, Callback_DragEvent_String_Union_CustomBuilder_DragItemInfo, Callback_DragEvent_String_Void, Callback_PreDragStatus_Void, Type_CommonMethod_linearGradient_value, Tuple_ResourceColor_Number, Type_CommonMethod_sweepGradient_value, Tuple_Length_Length, Type_CommonMethod_radialGradient_value, Callback_GestureInfo_BaseGestureEvent_GestureJudgeResult, Callback_TouchEvent_HitTestMode, Literal_Alignment_align, Callback_Number_Number_Void } from "./SyntheticDeclarations" import { LengthMetrics } from "./ArkLengthMetricsMaterialized" @@ -49,8 +49,26 @@ import { GestureInfo, GestureJudgeResult, GestureType, GestureMask } from "./Ark import { BaseGestureEvent } from "./ArkBaseGestureEventMaterialized" import { PixelMap } from "./ArkPixelMapMaterialized" import { ScrollOnWillScrollCallback, ScrollOnScrollCallback } from "./ArkScrollInterfaces" +import { ArkBaseNode } from "../handwritten/modifiers/ArkBaseNode" +import { AttributeUpdater } from "../handwritten/modifiers/ArkAttributeUpdater" +import { applyUIAttributes, ArkCommonAttributeSet } from "../handwritten/modifiers/ArkCommonModifier" + /** @memo:stable */ export class ArkCommonMethodComponent extends ComponentBase { + protected _modifierHost: ComponentBase | undefined + + setModifierHost(value: ComponentBase): void { + this._modifierHost = value + } + + getModifierHost(): ArkBaseNode { + if (this._modifierHost === undefined || this._modifierHost === null) { + this._modifierHost = new ArkBaseNode() + this._modifierHost!.setPeer(this.getPeer()) + } + return this._modifierHost as ArkBaseNode + } + getPeer(): ArkCommonMethodPeer { return (this.peer as ArkCommonMethodPeer) } @@ -426,9 +444,9 @@ export class ArkCommonMethodComponent extends ComponentBase { return this } /** @memo */ - public onHover(value: ((isHover: boolean,event: HoverEvent) => void)): this { + public onHover(value: ((isHover: boolean, event: HoverEvent) => void)): this { if (this.checkPriority("onHover")) { - const value_casted = value as (((isHover: boolean,event: HoverEvent) => void)) + const value_casted = value as (((isHover: boolean, event: HoverEvent) => void)) this.getPeer()?.onHoverAttribute(value_casted) return this } @@ -808,9 +826,9 @@ export class ArkCommonMethodComponent extends ComponentBase { return this } /** @memo */ - public onAreaChange(value: ((oldValue: Area,newValue: Area) => void)): this { + public onAreaChange(value: ((oldValue: Area, newValue: Area) => void)): this { if (this.checkPriority("onAreaChange")) { - const value_casted = value as (((oldValue: Area,newValue: Area) => void)) + const value_casted = value as (((oldValue: Area, newValue: Area) => void)) this.getPeer()?.onAreaChangeAttribute(value_casted) return this } @@ -979,54 +997,54 @@ export class ArkCommonMethodComponent extends ComponentBase { return this } /** @memo */ - public onDragStart(value: ((event: DragEvent,extraParams?: string) => CustomBuilder | DragItemInfo)): this { + public onDragStart(value: ((event: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo)): this { if (this.checkPriority("onDragStart")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => CustomBuilder | DragItemInfo)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo)) this.getPeer()?.onDragStartAttribute(value_casted) return this } return this } /** @memo */ - public onDragEnter(value: ((event: DragEvent,extraParams?: string) => void)): this { + public onDragEnter(value: ((event: DragEvent, extraParams?: string) => void)): this { if (this.checkPriority("onDragEnter")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => void)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => void)) this.getPeer()?.onDragEnterAttribute(value_casted) return this } return this } /** @memo */ - public onDragMove(value: ((event: DragEvent,extraParams?: string) => void)): this { + public onDragMove(value: ((event: DragEvent, extraParams?: string) => void)): this { if (this.checkPriority("onDragMove")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => void)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => void)) this.getPeer()?.onDragMoveAttribute(value_casted) return this } return this } /** @memo */ - public onDragLeave(value: ((event: DragEvent,extraParams?: string) => void)): this { + public onDragLeave(value: ((event: DragEvent, extraParams?: string) => void)): this { if (this.checkPriority("onDragLeave")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => void)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => void)) this.getPeer()?.onDragLeaveAttribute(value_casted) return this } return this } /** @memo */ - public onDrop(value: ((event: DragEvent,extraParams?: string) => void)): this { + public onDrop(value: ((event: DragEvent, extraParams?: string) => void)): this { if (this.checkPriority("onDrop")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => void)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => void)) this.getPeer()?.onDropAttribute(value_casted) return this } return this } /** @memo */ - public onDragEnd(value: ((event: DragEvent,extraParams?: string) => void)): this { + public onDragEnd(value: ((event: DragEvent, extraParams?: string) => void)): this { if (this.checkPriority("onDragEnd")) { - const value_casted = value as (((event: DragEvent,extraParams?: string) => void)) + const value_casted = value as (((event: DragEvent, extraParams?: string) => void)) this.getPeer()?.onDragEndAttribute(value_casted) return this } @@ -1397,9 +1415,9 @@ export class ArkCommonMethodComponent extends ComponentBase { return this } /** @memo */ - public onGestureJudgeBegin(value: ((gestureInfo: GestureInfo,event: BaseGestureEvent) => GestureJudgeResult)): this { + public onGestureJudgeBegin(value: ((gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult)): this { if (this.checkPriority("onGestureJudgeBegin")) { - const value_casted = value as (((gestureInfo: GestureInfo,event: BaseGestureEvent) => GestureJudgeResult)) + const value_casted = value as (((gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult)) this.getPeer()?.onGestureJudgeBeginAttribute(value_casted) return this } @@ -1795,7 +1813,21 @@ export class ArkCommonMethodComponent extends ComponentBase { } return this } - attributeModifier(modifier: AttributeModifier): this { throw new Error("not implemented") } + attributeModifier(modifier: AttributeModifier): this { + if (modifier.isUpdater) { + let attributeUpdater = modifier as AttributeUpdater + attributeUpdater.attribute = this.getModifierHost() + attributeUpdater.updateConstructorParams = () => { return this.getModifierHost()! as CommonAttribute }; + } else { + let peerNode = this.getPeer() + if (!peerNode._attributeSet) { + peerNode._attributeSet = new ArkCommonAttributeSet() + } + applyUIAttributes(modifier, peerNode); + peerNode._attributeSet!.applyModifierPatch(peerNode); + } + return this + } public applyAttributesFinish(): void { // we calls this function outside of class, so need to make it public super.applyAttributesFinish() @@ -1931,11 +1963,11 @@ export class ArkCommonComponent extends ArkCommonMethodComponent { /** @memo */ export function ArkCommon( - /** @memo */ - style: ((attributes: ArkCommonComponent) => void) | undefined, - /** @memo */ - content_: (() => void) | undefined, - + /** @memo */ + style: ((attributes: ArkCommonComponent) => void) | undefined, + /** @memo */ + content_: (() => void) | undefined, + ) { const receiver = remember(() => { return new ArkCommonComponent() @@ -2007,9 +2039,9 @@ export class ArkScrollableCommonMethodComponent extends ArkCommonMethodComponent return this } /** @memo */ - public onScroll(value: ((first: number,last: number) => void)): this { + public onScroll(value: ((first: number, last: number) => void)): this { if (this.checkPriority("onScroll")) { - const value_casted = value as (((first: number,last: number) => void)) + const value_casted = value as (((first: number, last: number) => void)) this.getPeer()?.onScrollAttribute(value_casted) return this } diff --git a/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts index 5f3c6fcbfe7f582a86709cc634b1a7de78834968..7881f004650b90df19b920721c1099b308e60892 100644 --- a/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts @@ -766,167 +766,10 @@ export interface InvertOptions { thresholdRange: number; } export interface CommonMethod { - width: Length; - height: Length; - drawModifier: DrawModifier | undefined; - responseRegion: Array | Rectangle; - mouseResponseRegion: Array | Rectangle; - size: SizeOptions; - constraintSize: ConstraintSizeOptions; - touchable: boolean; - hitTestBehavior: HitTestMode; - onChildTouchTest: ((value: Array) => TouchResult); - layoutWeight: number | string; - chainWeight: ChainWeightOptions; - padding: Padding | Length | LocalizedPadding; - safeAreaPadding: Padding | LengthMetrics | LocalizedPadding; - margin: Margin | Length | LocalizedMargin; - backgroundColor: ResourceColor; - pixelRound: PixelRoundPolicy; - backgroundImageSize: SizeOptions | ImageSize; - backgroundImagePosition: Position | Alignment; - backgroundEffect: BackgroundEffectOptions; - backgroundImageResizable: ResizableOptions; - foregroundEffect: ForegroundEffectOptions; - visualEffect: VisualEffect; - backgroundFilter: Filter; - foregroundFilter: Filter; - compositingFilter: Filter; - opacity: number | Resource; - border: BorderOptions; - borderStyle: BorderStyle | EdgeStyles; - borderWidth: Length | EdgeWidths | LocalizedEdgeWidths; - borderColor: ResourceColor | EdgeColors | LocalizedEdgeColors; - borderRadius: Length | BorderRadiuses | LocalizedBorderRadiuses; - borderImage: BorderImageOption; - outline: OutlineOptions; - outlineStyle: OutlineStyle | EdgeOutlineStyles; - outlineWidth: Dimension | EdgeOutlineWidths; - outlineColor: ResourceColor | EdgeColors | LocalizedEdgeColors; - outlineRadius: Dimension | OutlineRadiuses; - foregroundColor: ResourceColor | ColoringStrategy; - onClick: ((event: ClickEvent) => void); - onHover: ((isHover: boolean,event: HoverEvent) => void); - onAccessibilityHover: AccessibilityCallback; - hoverEffect: HoverEffect; - onMouse: ((event: MouseEvent) => void); - onTouch: ((event: TouchEvent) => void); - onKeyEvent: ((event: KeyEvent) => void); - onKeyPreIme: ((parameter: KeyEvent) => boolean); - focusable: boolean; - onFocus: (() => void); - onBlur: (() => void); - tabIndex: number; - defaultFocus: boolean; - groupDefaultFocus: boolean; - focusOnTouch: boolean; - focusBox: FocusBoxStyle; - animation: AnimateParam; - transition: TransitionOptions | TransitionEffect; - motionBlur: MotionBlurOptions; - brightness: number; - contrast: number; - grayscale: number; - colorBlend: Color | string | Resource; - saturate: number; - sepia: number; - invert: number | InvertOptions; - hueRotate: number | string; - useShadowBatching: boolean; - useEffect: boolean; - renderGroup: boolean; - freeze: boolean; - translate: TranslateOptions; - scale: ScaleOptions; - gridSpan: number; - gridOffset: number; - rotate: RotateOptions; - transform: Object; - onAppear: (() => void); - onDisAppear: (() => void); - onAttach: (() => void); - onDetach: (() => void); - onAreaChange: ((oldValue: Area,newValue: Area) => void); - visibility: Visibility; - flexGrow: number; - flexShrink: number; - flexBasis: number | string; - alignSelf: ItemAlign; - displayPriority: number; - zIndex: number; - direction: Direction; - align: Alignment; - position: Position | Edges | LocalizedEdges; - markAnchor: Position | LocalizedPosition; - offset: Position | Edges | LocalizedEdges; - enabled: boolean; - useSizeType: Literal_Union_Number_Literal_Number_offset_span_lg_md_sm_xs; - alignRules: AlignRuleOption; - - aspectRatio: number; - clickEffect: ClickEffect | undefined; - onDragStart: ((event: DragEvent,extraParams?: string) => CustomBuilder | DragItemInfo); - onDragEnter: ((event: DragEvent,extraParams?: string) => void); - onDragMove: ((event: DragEvent,extraParams?: string) => void); - onDragLeave: ((event: DragEvent,extraParams?: string) => void); - onDrop: ((event: DragEvent,extraParams?: string) => void); - onDragEnd: ((event: DragEvent,extraParams?: string) => void); - allowDrop: Array | undefined; - draggable: boolean; - dragPreview: CustomBuilder | DragItemInfo | string; - onPreDrag: ((parameter: PreDragStatus) => void); - linearGradient: Type_CommonMethod_linearGradient_value; - sweepGradient: Type_CommonMethod_sweepGradient_value; - radialGradient: Type_CommonMethod_radialGradient_value; - motionPath: MotionPathOptions; - shadow: ShadowOptions | ShadowStyle; - clip: boolean | undefined; - - clipShape: CircleShape | EllipseShape | PathShape | RectShape; - mask: ProgressMask | undefined; - - maskShape: CircleShape | EllipseShape | PathShape | RectShape; - key: string; - id: string; - geometryTransition: string; - stateStyles: StateStyles; - restoreId: number; - sphericalEffect: number; - lightUpEffect: number; - pixelStretchEffect: PixelStretchEffectOptions; - accessibilityGroup: boolean; - accessibilityText: string; - - accessibilityTextHint: string; - accessibilityDescription: string; - - accessibilityLevel: string; - accessibilityVirtualNode: CustomBuilder; - accessibilityChecked: boolean; - accessibilitySelected: boolean; - obscured: Array; - reuseId: string; - renderFit: RenderFit; - attributeModifier: AttributeModifier; - gestureModifier: GestureModifier; - backgroundBrightness: BackgroundBrightnessOptions; - onGestureJudgeBegin: ((gestureInfo: GestureInfo,event: BaseGestureEvent) => GestureJudgeResult); - onGestureRecognizerJudgeBegin: GestureRecognizerJudgeBeginCallback; - shouldBuiltInRecognizerParallelWith: ShouldBuiltInRecognizerParallelWithCallback; - monopolizeEvents: boolean; - onTouchIntercept: ((parameter: TouchEvent) => HitTestMode); - onSizeChange: SizeChangeCallback; - - - - - - - - - - + width(value: Length | undefined): T; + height(value: Length | undefined): T; } + export interface CommonAttribute extends CommonMethod { } export type CommonInterface = () => CommonAttribute; diff --git a/arkoala-arkts/arkui/src/generated/ArkParticleInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkParticleInterfaces.ts index f803fa8f08696817962aec52dd20bcba3d7cf53d..d0a8d51221f55095f5f656d989ed93d1b34c6ade 100644 --- a/arkoala-arkts/arkui/src/generated/ArkParticleInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkParticleInterfaces.ts @@ -22,6 +22,8 @@ import { NodeAttach, remember } from "@koalaui/runtime" import { VP, ResourceStr, Dimension } from "./ArkUnitsInterfaces" import { ImageFit, Curve } from "./ArkEnumsInterfaces" import { ICurve } from "./ArkICurveMaterialized" +import { CommonMethod } from "./ArkCommonInterfaces" + export type ParticleTuple = [ T1, T2 diff --git a/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts b/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts index 344797b687c61c3a8f973055ef2d9b0308e59a09..e042f6f069e8c2613a36ed7562cf935eb0ed9444 100644 --- a/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts +++ b/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts @@ -58,7 +58,11 @@ import { DotIndicator } from "./../ArkDotIndicatorBuilder" import { DigitIndicator } from "./../ArkDigitIndicatorBuilder" import { SubTabBarStyle } from "./../ArkSubTabBarStyleBuilder" import { BottomTabBarStyle } from "./../ArkBottomTabBarStyleBuilder" +import { ArkCommonAttributeSet } from '../../handwritten/modifiers/ArkCommonModifier' + export class ArkCommonMethodPeer extends PeerNode { + _attributeSet?: ArkCommonAttributeSet + protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } diff --git a/arkoala-arkts/arkui/src/handwritten/index.ts b/arkoala-arkts/arkui/src/handwritten/index.ts index eeb6fe2981f5a793b234b5ed48ee269e25f71cea..b2a9ba5253f6a936193417a408f542ba60aa988d 100644 --- a/arkoala-arkts/arkui/src/handwritten/index.ts +++ b/arkoala-arkts/arkui/src/handwritten/index.ts @@ -7,7 +7,9 @@ export * from "./resources" // TODO: implement this -export interface AttributeModifier {} +export interface AttributeModifier { + isUpdater: boolean; +} export interface SubscribaleAbstract {} export interface CommonTransition {} export interface AbstractProperty {} diff --git a/arkoala-arkts/arkui/src/handwritten/modifiers/ArkAttributeUpdater.ts b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkAttributeUpdater.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b629f7abe8a423841f86cb6bc8186f2bb296ec3 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkAttributeUpdater.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { AttributeModifier } from "../.."; + +export type Initializer = () => T; + +export class AttributeUpdater> implements AttributeModifier { + isUpdater: boolean = true + + private value: T | undefined = undefined; + private constructorParams: C | undefined = undefined; + + public set attribute(value: T) { + this.value = value + } + + public get attribute(): T { + return this.value! + } + + public set updateConstructorParams(value: C) { + this.constructorParams = value + } + + public get updateConstructorParams() : C { + return this.constructorParams!; + } +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/handwritten/modifiers/ArkBaseNode.ts b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkBaseNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..c21e59b848f9360f7959cacfc0a06177b071af50 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkBaseNode.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { ComponentBase } from "../../ComponentBase"; +import { CommonAttribute, CommonMethod, Length } from "../../generated"; +import { ArkCommonMethodPeer } from "../../generated/peers/ArkCommonPeer"; + +export class ArkBaseNode extends ComponentBase implements CommonAttribute { + getPeer() : ArkCommonMethodPeer { + return this.peer as ArkCommonMethodPeer + } + + width(value: Length | undefined) : this { + if (!value) { + // this.getPeer().resetWidthAttribute() + return this; + } + this.getPeer().widthAttribute(value) + return this; + } + height(value: Length | undefined): this { + if (!value) { + // this.getPeer().resetHeightAttribute() + return this; + } + this.getPeer().heightAttribute(value) + return this; + } +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnModifier.ts b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnModifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa9e7ac384731f0fb0dfddb253add3e17362da79 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnModifier.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { int32 } from "@koalaui/common" +import { AttributeModifier, ColumnAttribute, HorizontalAlign } from "../.."; +import { ArkColumnPeer } from "../../generated/peers/ArkColumnPeer"; +import { ArkCommonMethodPeer } from "../../generated/peers/ArkCommonPeer"; +import { ArkCommonAttributeSet, modifierNullWithKey, modifierWithKey, ModifierWithKey } from "./ArkCommonModifier"; + +class AlignItemsModifier extends ModifierWithKey { + static identity: string = 'alignItems'; + + constructor(value: int32) { + super(value) + } + + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + let columnPeerNode = node as ArkColumnPeer + if (reset) { + // columnPeerNode.resetAlignItemsAttribute(); + } else { + if (this.value! === 0) { + columnPeerNode.alignItemsAttribute(HorizontalAlign.START); + } else if (this.value! === 1) { + columnPeerNode.alignItemsAttribute(HorizontalAlign.CENTER); + } else { + columnPeerNode.alignItemsAttribute(HorizontalAlign.END); + } + } + } + + static factory(value: int32): AlignItemsModifier { + return new AlignItemsModifier(value) + } +} + +export class ArkColumnAttributeSet extends ArkCommonAttributeSet implements ColumnAttribute { + alignItems(value: HorizontalAlign | undefined): this { + if (value) { + modifierWithKey(this._modifiersWithKeys, AlignItemsModifier.identity, AlignItemsModifier.factory, ((value as HorizontalAlign) as int32)); + } else { + modifierNullWithKey(this._modifiersWithKeys, AlignItemsModifier.identity) + } + return this; + } +} + +export class ColumnModifier extends ArkColumnAttributeSet implements AttributeModifier { + isUpdater: boolean = false +} diff --git a/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnNode.ts b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a9f43354d9a48cd782857c45dce6b1ab9cc10da --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnNode.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 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 { ColumnAttribute, HorizontalAlign } from "../../generated"; +import { ArkColumnPeer } from "../../generated/peers/ArkColumnPeer"; +import { ArkBaseNode } from "./ArkBaseNode"; + +export class ArkColumnNode extends ArkBaseNode implements ColumnAttribute { + alignItems(value: HorizontalAlign | undefined): this { + if (value) { + this.getPeer().alignItemsAttribute(value); + } else { + // this.getPeer().resetAlignItemsAttribute(value); + } + return this; + } + getPeer() : ArkColumnPeer { + return this.peer as ArkColumnPeer + } +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/handwritten/modifiers/ArkCommonModifier.ts b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkCommonModifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..28f6db006fa1128a36cd433079faeba71feb725d --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkCommonModifier.ts @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2025 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 { AttributeModifier, CommonAttribute, Length, ResourceColor } from "../.."; +import { ArkCommonMethodPeer } from "../../generated/peers/ArkCommonPeer"; + +enum ModifierType { + ORIGIN = 0, + STATE = 1, + FRAME_NODE = 2, + EXPOSE_MODIFIER = 3, +} + +abstract class BaseModifier { + abstract applyStage(node: ArkCommonMethodPeer): boolean + + abstract applyStageImmediately(node: ArkCommonMethodPeer): void + + abstract applyPeer(node: ArkCommonMethodPeer, reset: boolean): void + + abstract checkObjectDiff(): boolean + + abstract reset(): void +} + +class ObservedMap { + private map_: Map = new Map(); + private changeCallback?: (key: string, value: BaseModifier) => void; + + public clear(): void { + this.map_.clear(); + } + + public delete(key: string): boolean { + return this.map_.delete(key); + } + + public forEach(callbackfn: (value: BaseModifier, key: string, + map: Map) => void): void { + this.map_.forEach(callbackfn); + } + public get(key: string): BaseModifier | undefined { + return this.map_.get(key); + } + public has(key: string): boolean { + return this.map_.has(key); + } + public set(key: string, value: BaseModifier): this { + this.map_.set(key, value); + if (this.changeCallback) { + this.changeCallback!(key, value) + } + return this; + } + public get size(): number { + return this.map_.size; + } + public entries(): IterableIterator<[string, BaseModifier]> { + return this.map_.entries(); + } + public keys(): IterableIterator { + return this.map_.keys(); + } + public values(): IterableIterator { + return this.map_.values(); + } + public setOnChange(callback: (key: string, value: BaseModifier) => void): void { + if (!this.changeCallback) { + this.changeCallback = callback; + } + } +} + +const UI_STATE_NORMAL = 0; +const UI_STATE_PRESSED = 1; +const UI_STATE_FOCUSED = 1 << 1; +const UI_STATE_DISABLED = 1 << 2; +const UI_STATE_SELECTED = 1 << 3; + +function applyUIAttributesInit(modifier: AttributeModifier, nativeNode: ArkCommonMethodPeer): void { + // if (modifier.applyPressedAttribute === undefined && modifier.applyFocusedAttribute === undefined && + // modifier.applyDisabledAttribute === undefined && modifier.applySelectedAttribute === undefined) { + // return; + // } + // let state = 0; + // if (modifier.applyPressedAttribute !== undefined) { + // state |= UI_STATE_PRESSED; + // } + // if (modifier.applyFocusedAttribute !== undefined) { + // state |= UI_STATE_FOCUSED; + // } + // if (modifier.applyDisabledAttribute !== undefined) { + // state |= UI_STATE_DISABLED; + // } + // if (modifier.applySelectedAttribute !== undefined) { + // state |= UI_STATE_SELECTED; + // } + // commonPeerNode.setSupportedUIState(state); +} + +export function applyUIAttributes(modifier: AttributeModifier, nativeNode: ArkCommonMethodPeer): void { + applyUIAttributesInit(modifier, nativeNode); + // const currentUIState = nativeNode.getCurrentState(); + const currentUIState = UI_STATE_NORMAL; + + // if (modifier.applyNormalAttribute !== undefined) { + // modifier.applyNormalAttribute(nativeNode._attributeSet! as T); + // } + // if ((currentUIState & UI_STATE_PRESSED) && (modifier.applyPressedAttribute !== undefined)) { + // modifier.applyPressedAttribute(nativeNode._attributeSet! as T); + // } + // if ((currentUIState & UI_STATE_FOCUSED) && (modifier.applyFocusedAttribute !== undefined)) { + // modifier.applyFocusedAttribute(nativeNode._attributeSet! as T); + // } + // if ((currentUIState & UI_STATE_DISABLED) && (modifier.applyDisabledAttribute !== undefined)) { + // modifier.applyDisabledAttribute(nativeNode._attributeSet! as T); + // } + // if ((currentUIState & UI_STATE_SELECTED) && (modifier.applySelectedAttribute !== undefined)) { + // modifier.applySelectedAttribute(nativeNode._attributeSet! as T); + // } +} + +export class ModifierWithKey extends BaseModifier { + stageValue: T | undefined; + value: T | undefined; + constructor(value: T) { + super() + this.stageValue = value; + } + + reset(): void { + this.stageValue = undefined + } + + applyStage(node: ArkCommonMethodPeer): boolean { + if (this.stageValue === undefined || this.stageValue === null) { + this.value = this.stageValue + this.applyPeer(node, true) + return true; + } + let needDiff = this.checkObjectDiff() + if (needDiff) { + this.value = this.stageValue + this.applyPeer(node, false) + return true + } + return false + } + + applyStageImmediately(node: ArkCommonMethodPeer): void { + this.value = this.stageValue; + if (this.stageValue === undefined || this.stageValue === null) { + this.applyPeer(node, true); + return; + } + this.applyPeer(node, false); + } + + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { } + + checkObjectDiff(): boolean { + const stageTypeInfo: string = typeof this.stageValue; + const valueTypeInfo: string = typeof this.value; + if (stageTypeInfo !== valueTypeInfo) { + return true; + } + if (stageTypeInfo === 'number' || stageTypeInfo === 'string' || stageTypeInfo === 'boolean') { + return (this.stageValue !== this.value); + } + // if (this.stageValue instanceof ArkResourceImpl) { + // return (this.stageValue as ArkResource).isEqual(this.value as ArkResource) + // } + return false; + } +} + +class BackgroundColorModifier extends ModifierWithKey { + constructor(value: ResourceColor) { + super(value); + } + static identity: string = 'backgroundColor'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetBackgroundColor(); + } else { + node.backgroundColorAttribute(this.value!); + } + } + static factory(value: ResourceColor): BackgroundColorModifier { + return new BackgroundColorModifier(value) + } +} + +class WidthModifier extends ModifierWithKey { + constructor(value: Length) { + super(value); + } + static identity: string = 'width'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetWidthAttribute(); + } else { + node.widthAttribute(this.value!); + } + } + static factory(value: Length): WidthModifier { + return new WidthModifier(value) + } +} + +class HeightModifier extends ModifierWithKey { + constructor(value: Length) { + super(value); + } + static identity: string = 'height'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetWidthAttribute(); + } else { + node.heightAttribute(this.value!); + } + } + static factory(value: Length): HeightModifier { + return new HeightModifier(value) + } +} + +export function modifierWithKey>( + modifiers: ObservedMap, + identity: string, + modifierClass: (value: T) => M, + value: T +) { + const item = modifiers.get(identity) as ModifierWithKey; + if (item) { + item.stageValue = value; + modifiers.set(identity, item); + } else { + modifiers.set(identity, modifierClass(value)); + } +} + +export function modifierNullWithKey(modifiers: ObservedMap, identity: string) { + const item = modifiers.get(identity) + if (item) { + item.reset() + modifiers.set(identity, item); + } +} + +export class ArkCommonAttributeSet implements CommonAttribute { + _modifiersWithKeys: ObservedMap = new ObservedMap(); + _instanceId: number = -1; + + setInstanceId(instanceId: number): void { + this._instanceId = instanceId; + } + + cleanStageValue(): void { + if (!this._modifiersWithKeys) { + return; + } + this._modifiersWithKeys.forEach((value, key) => { + value.reset(); + }); + } + + applyModifierPatch(peerNode: ArkCommonMethodPeer): void { + let expiringItemsWithKeys = new Array; + this._modifiersWithKeys.forEach((value, key) => { + if (value.applyStage(peerNode)) { + expiringItemsWithKeys.push(key); + } + }); + + for (let i = 0; i < expiringItemsWithKeys.length; i++) { + this._modifiersWithKeys.delete(expiringItemsWithKeys[i]); + } + } + + width(value: Length | undefined): this { + if (value) { + modifierWithKey(this._modifiersWithKeys, WidthModifier.identity, WidthModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, WidthModifier.identity) + } + return this; + } + + height(value: Length | undefined): this { + if (value) { + modifierWithKey(this._modifiersWithKeys, HeightModifier.identity, HeightModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, HeightModifier.identity) + } + return this; + } + + backgroundColor(value: ResourceColor | undefined): this { + if (value) { + modifierWithKey(this._modifiersWithKeys, BackgroundColorModifier.identity, BackgroundColorModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, BackgroundColorModifier.identity) + } + return this; + } +} + \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/index.ts b/arkoala-arkts/arkui/src/index.ts index b2ed0e9af0218c6ef301f2703fda18c68eb84357..3552b89f77cc97503281d959053751f31cccb19b 100644 --- a/arkoala-arkts/arkui/src/index.ts +++ b/arkoala-arkts/arkui/src/index.ts @@ -25,6 +25,7 @@ export * from "./stateOf" export * from "./ForEach" export * from "./LazyForEach" export * from "./ohos.router" +export * from "./ohos.arkui.modifier" export * from "./ArkNavigation" export * from "./PeerNode" export * from "./generated/Events" diff --git a/arkoala-arkts/arkui/src/ohos.arkui.modifier.ts b/arkoala-arkts/arkui/src/ohos.arkui.modifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbd2bcc95e8fd841a6300fd79476564ffd494b01 --- /dev/null +++ b/arkoala-arkts/arkui/src/ohos.arkui.modifier.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + +export { AttributeUpdater } from './handwritten/modifiers/ArkAttributeUpdater' + +export { ColumnModifier } from './handwritten/modifiers/ArkColumnModifier' diff --git a/arkoala-arkts/har/package.json b/arkoala-arkts/har/package.json index 299d8788f1bd0d17d282694a77374b78e96af3b6..e7b6b5650b0299c9df59d121ec9c0dfc863abc65 100644 --- a/arkoala-arkts/har/package.json +++ b/arkoala-arkts/har/package.json @@ -22,6 +22,6 @@ "har-arm32": "npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-arkoala-har.mjs --arch arm32 && npm run pack", "har-arm64": "npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-arkoala-har.mjs --arch arm64 && npm run pack", "har-universal": "npm run --prefix ../../arkoala/ohos-sdk download && node scripts/build-arkoala-har-universal.mjs && npm run pack", - "cli-tools:download": "node ../ohos-sdk/scripts/oh-sdk-cli.mjs cli-tools" + "cli-tools:download": "node ../../arkoala/ohos-sdk/scripts/oh-sdk-cli.mjs cli-tools" } } diff --git a/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json b/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json index 26a55886841846bc07f570f8ee1eaf73ad6a30e4..3aa78384a5c546eb21421c8069b08a01fba898a2 100644 --- a/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json +++ b/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json @@ -34,6 +34,9 @@ "#arkstate": ["../../../arkoala/arkui-common/build/unmemoized/src"] } }, + "files": [ + "../../arkui/types/index-full.d.ts" + ], "include": [ "./build/unmemoized/**/*.ts" ] diff --git a/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets b/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets index b7d8e3c4b58e6b98e5d7373a018f21cb7f025639..a6a6951a912bae514f5eb49a851f57b3ca7e795b 100644 --- a/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets +++ b/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets @@ -23,6 +23,13 @@ import { Detail } from './detailPage/detail' import { SearchPage } from './search/searchPage' //import mediaquery from '@ohos.mediaquery'; import { SearchParam } from '../model/routeModel' + +import { AttributeUpdater, ColumnModifier } from '@ohos.arkui.modifier' + +class MyColumnModifier extends AttributeUpdater { + initializeModifier(instance: ColumnAttribute): void {} +} + @Entry @Component struct Index { @@ -36,6 +43,9 @@ struct Index { @State ratio: number = 1 @Provide('pathInfos') pathInfos : NavPathStack = new NavPathStack() //listener = mediaQuery.matchMediaSync('(orientation:landscape)') + updater: MyColumnModifier = new MyColumnModifier() + + modifier: ColumnModifier = new ColumnModifier().width(20) aboutToAppear() { //this.listener.on('change', this.onPortrait) @@ -114,9 +124,11 @@ struct Index { .height('8%') } .width('100%') + .attributeModifier(this.updater) } .width(`${this.width1}%`) .backgroundColor(Color.White) + .attributeModifier(this.modifier) } .width('100%') .backgroundColor('#10000000') diff --git a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json index 2abbabdde2f936ab1172c39bccee6d2e47bc60fb..543b496672e700327d966ebf803c1c0cae55a4ff 100644 --- a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json +++ b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json @@ -28,6 +28,9 @@ "@koalaui/arkts-arkui/ohos.router": [ "../../arkui/src/ohos.router.ts" ], + "@koalaui/arkts-arkui/ohos.arkui.modifier": [ + "../../arkui/src/ohos.arkui.modifier.ts" + ], "app/*": [ "./build/generated/*" ] diff --git a/arkoala/ets-plugin/src/Importer.ts b/arkoala/ets-plugin/src/Importer.ts index 9cf566ace523460ac965e136cd6fa0e7194c0acd..eb0f7b516a328872934e8eaff54abacaeea1a9b4 100644 --- a/arkoala/ets-plugin/src/Importer.ts +++ b/arkoala/ets-plugin/src/Importer.ts @@ -115,7 +115,8 @@ function implementedPackages(kind: ArkUIImplementation): string[] { 'system.router' ] if (kind == ArkUIImplementation.ARKTS) return [ - 'ohos.router' + 'ohos.router', + 'ohos.arkui.modifier' ] assertUnreachable(kind) diff --git a/arkoala/ets-plugin/src/StructTransformer.ts b/arkoala/ets-plugin/src/StructTransformer.ts index 5d08497bbbc6a6b39a4b7b6e6189f43822067238..3b0c01dcdf40447da4a09d875de55853a4da4bb7 100644 --- a/arkoala/ets-plugin/src/StructTransformer.ts +++ b/arkoala/ets-plugin/src/StructTransformer.ts @@ -21,6 +21,7 @@ import { Importer, isOhosImport } from './Importer' import { adaptorClassName, adaptorComponentName, + adaptorEtsAttributeName, adaptorEtsName, backingField, backingFieldName, @@ -882,6 +883,10 @@ export class StructTransformer extends AbstractVisitor { if (ts.isIdentifier(name)) { const newName = adaptorClassName(name) this.importer.addAdaptorImport(ts.idText(newName)) + const attributeName = adaptorEtsAttributeName(name) + if (!ts.idText(attributeName).includes("Page")) { + this.importer.addAdaptorImport(ts.idText(attributeName)) + } return newName } else { throw new Error("expected ETS name to be an Identifier, got: " + ts.SyntaxKind[name.kind])