diff --git a/arkoala-arkts/arkui/src/ArkCustomComponent.ts b/arkoala-arkts/arkui/src/ArkCustomComponent.ts index 3f494f42e377d0d9d1e9944b28a27f5e947780d6..fe1ed2b8878b16b0048ce69d2fccfe20e1010ac4 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..338dbd1b58c83a3a14ecb2d98bdc123065463a96 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,ColumnModifier } 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,33 @@ export class ArkColumnComponent extends ArkCommonMethodComponent { } return this } + + attributeModifier(modifier: AttributeModifier): this { + let peerNode = this.getPeer(); + let attributeSet = peerNode._attributeSet; + let isAttributeUpdater = modifier instanceof AttributeUpdater + if (isAttributeUpdater) { + let attributeUpdater = modifier as AttributeUpdater; + attributeUpdater.attribute = this.getModifierHost(); + if (!attributeSet) { + attributeSet = new ArkColumnAttributeSet(); + peerNode._attributeSet = attributeSet; + } + attributeUpdater.initializeModifier((peerNode._attributeSet as Object) as ColumnAttribute) + } else { + let attributeModifier = ((modifier as Object) as AttributeModifier); + let columnModifier = (attributeModifier as Object) as ColumnModifier; + if (!attributeSet) { + attributeSet = new ArkColumnAttributeSet(); + attributeSet._modifiersWithKeys = columnModifier._modifiersWithKeys; + peerNode._attributeSet = attributeSet; + } + } + 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 6827b8e8b84dd84f7fda99b6a25d89878352ccd4..5cceff3c523be50a074feb09664e907deab4e775 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" @@ -48,8 +48,27 @@ import { GestureModifier } from "./ArkGestureModifierMaterialized" import { GestureInfo, GestureJudgeResult, GestureType, GestureMask } from "./ArkGestureInterfaces" 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, CommonModifier } 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) } @@ -425,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 } @@ -807,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 } @@ -978,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 } @@ -1396,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 } @@ -1794,7 +1813,22 @@ export class ArkCommonMethodComponent extends ComponentBase { } return this } - attributeModifier(modifier: AttributeModifier): this { throw new Error("not implemented") } + attributeModifier(modifier: AttributeModifier): this { + let peerNode = this.getPeer() + if (!peerNode._attributeSet) { + peerNode._attributeSet = new ArkCommonAttributeSet() + } + applyUIAttributes(modifier, peerNode); + let isAttributeUpdater: boolean = (modifier instanceof AttributeUpdater); + if (isAttributeUpdater) { + let attributeUpdater = modifier as AttributeUpdater + attributeUpdater.initializeModifier(peerNode._attributeSet as CommonAttribute); + attributeUpdater.attribute = this.getModifierHost() + attributeUpdater.updateConstructorParams = () => { return this.getModifierHost()! as CommonAttribute }; + } + peerNode._attributeSet!.applyModifierPatch(peerNode); + return this + } public applyAttributesFinish(): void { // we calls this function outside of class, so need to make it public super.applyAttributesFinish() @@ -1930,11 +1964,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() @@ -2006,9 +2040,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 8fe71049fa18b44389ca14f1e5aab567d32af7b8..900f2b4c484080fb0dd838e07a22ab2f14d0e7d6 100644 --- a/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkCommonInterfaces.ts @@ -765,167 +765,13 @@ 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; + onClick(value:(event: ClickEvent) => void):T; + zIndex(value:number):T; + size(value:SizeOptions):T; } + export interface CommonAttribute extends CommonMethod { } export type CommonInterface = () => CommonAttribute; diff --git a/arkoala-arkts/arkui/src/generated/ArkEnumsInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkEnumsInterfaces.ts index 3dc3d223021502a2c91ad5a084dd53b18c25f541..c77368480dd3af797764504ddfe8b8084cacd4c4 100644 --- a/arkoala-arkts/arkui/src/generated/ArkEnumsInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkEnumsInterfaces.ts @@ -308,11 +308,9 @@ export enum Axis { Horizontal = 1 } export enum HorizontalAlign { - START = 0, + Start = 0, - CENTER = 1, Center = 1, - END = 2, End = 2 } export enum FlexAlign { diff --git a/arkoala-arkts/arkui/src/generated/ArkFormComponentInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkFormComponentInterfaces.ts index da1a6dc164ecc027b8b9df8c1442941ea1f66506..38ab8622d14df4941a4346ec3fb11328275d4671 100644 --- a/arkoala-arkts/arkui/src/generated/ArkFormComponentInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkFormComponentInterfaces.ts @@ -86,7 +86,7 @@ export interface FormCallbackInfo { idString: string; } export interface FormComponentAttribute extends CommonMethod { - size: SizeOptions; + // size: SizeOptions; moduleName: string; dimension: FormDimension; allowUpdate: boolean; diff --git a/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts b/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts index 6eea599719141fb6b8f589ab8d8045e451881ef9..9def0ea2615b3ab18ebf74dd891fbbf06a2d5170 100644 --- a/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts +++ b/arkoala-arkts/arkui/src/generated/peers/ArkCommonPeer.ts @@ -61,7 +61,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 + private supportedUIState: number = 0; protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } @@ -2858,6 +2862,12 @@ export class ArkCommonMethodPeer extends PeerNode { ArkUIGeneratedNativeModule._CommonMethod_keyboardShortcut(this.peer.ptr, thisSerializer.asBuffer(), thisSerializer.length()) thisSerializer.release() } + getCurrentState():number { + return this.supportedUIState; + } + setSupportedUIState(sate: number):void { + this.supportedUIState = sate; + } } export interface ArkCommonMethodAttributes { width?: Length diff --git a/arkoala-arkts/arkui/src/generated/ts/type_check.ts b/arkoala-arkts/arkui/src/generated/ts/type_check.ts index 4ffc1a3901287332d04a3703fc397260a905dcfb..82b55dbf6ad238c2389e8011cd8a76c6a4936a8c 100644 --- a/arkoala-arkts/arkui/src/generated/ts/type_check.ts +++ b/arkoala-arkts/arkui/src/generated/ts/type_check.ts @@ -10539,9 +10539,6 @@ export class TypeChecker { static isNodeContainerInterface(value: object|string|number|undefined|null|boolean): boolean { throw new Error("Can not discriminate value typeof NodeContainerInterface") } - static isNodeController(value: object|string|number|undefined|null|boolean): boolean { - throw new Error("Can not discriminate value typeof NodeController") - } static isNonCurrentDayStyle(value: object|string|number|undefined|null|boolean, duplicated_nonCurrentMonthDayColor: boolean, duplicated_nonCurrentMonthLunarColor: boolean, duplicated_nonCurrentMonthWorkDayMarkColor: boolean, duplicated_nonCurrentMonthOffDayMarkColor: boolean): boolean { if ((!duplicated_nonCurrentMonthDayColor) && (value?.hasOwnProperty("nonCurrentMonthDayColor"))) { return true diff --git a/arkoala-arkts/arkui/src/handwritten/AttributeModifier.ts b/arkoala-arkts/arkui/src/handwritten/AttributeModifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..6d6f6a5cd238373496e6ef8d5847009c840a7e30 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/AttributeModifier.ts @@ -0,0 +1,28 @@ +/* + * 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 interface AttributeModifier { + + applyNormalAttribute(instance: T) : void; + + applyPressedAttribute(instance: T) : void; + + applyFocusedAttribute(instance: T) : void; + + applyDisabledAttribute(instance: T) : void; + + applySelectedAttribute(instance: T) : void; + +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/handwritten/index.ts b/arkoala-arkts/arkui/src/handwritten/index.ts index d2bde379dd3be8325b6d3f42f85c1c5759c9acc6..13d6a05aaad0cae8f9e4a5a14611e8649bb3c701 100644 --- a/arkoala-arkts/arkui/src/handwritten/index.ts +++ b/arkoala-arkts/arkui/src/handwritten/index.ts @@ -4,10 +4,9 @@ export * from "./ArkPageTransitionData" export * from "./Router" export * from "./ForeignFunctions" export * from "./resources" - +export * from "./AttributeModifier" // TODO: implement this -export interface AttributeModifier {} 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..ef8c0a5be55c895642fc9acdf825e34000de3d68 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkAttributeUpdater.ts @@ -0,0 +1,58 @@ +/* + * 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 { + + applyNormalAttribute(instance: T): void { + + } + applyPressedAttribute(instance: T): void { + + } + applyFocusedAttribute(instance: T): void { + + } + applyDisabledAttribute(instance: T): void { + + } + applySelectedAttribute(instance: T): void { + + } + + initializeModifier(instance: T): void { + } + + 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!; + } +} 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..33fdf133331d8ff8343d523fbd51244b6b30d890 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkBaseNode.ts @@ -0,0 +1,56 @@ +/* + * 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 { ClickEvent, CommonAttribute, CommonMethod, Length, SizeOptions } 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; + } + zIndex(value: number): CommonAttribute { + this.getPeer().zIndexAttribute(value) + return this; + } + size(value: SizeOptions): CommonAttribute { + if (!value) { + return this; + } + this.getPeer().sizeAttribute(value); + return this; + } + onClick(value: (event: ClickEvent) => void): CommonAttribute { + this.getPeer().onClick0Attribute(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..afc785f17c2a11e969e1fbe782adc32ecbf36f41 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkColumnModifier.ts @@ -0,0 +1,64 @@ +/* + * 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: HorizontalAlign | undefined) { + super(value) + } + + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + let columnPeerNode = node as ArkColumnPeer + if (reset) { + // columnPeerNode.resetAlignItemsAttribute(); + } else { + if (this.value != undefined) { + columnPeerNode.alignItemsAttribute(this.value as HorizontalAlign); + } + } + } + + static factory(value: HorizontalAlign | undefined): AlignItemsModifier { + if (value) { + return new AlignItemsModifier(value) + } + else { + return new AlignItemsModifier(undefined); + } + } +} + +export class ArkColumnAttributeSet extends ArkCommonAttributeSet implements ColumnAttribute { + + alignItems(value: HorizontalAlign|undefined): this { + modifierWithKey(this._modifiersWithKeys, AlignItemsModifier.identity, AlignItemsModifier.factory, value); + return this; + } +} + +export class ColumnModifier extends ArkColumnAttributeSet implements AttributeModifier { + applyNormalAttribute(instance: ColumnAttribute) { this.alignItems(HorizontalAlign.End); } + applyPressedAttribute(instance: ColumnAttribute) {} + applyFocusedAttribute(instance: ColumnAttribute){} + applyDisabledAttribute(instance: ColumnAttribute){} + applySelectedAttribute(instance: ColumnAttribute){} +} 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..55e942d9b33836ab39eb5c4587f9e243717d1d4d --- /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..dbe0923594f4da9b07c4e2b7e12b5f51fa3ac6de --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/modifiers/ArkCommonModifier.ts @@ -0,0 +1,375 @@ +/* + * 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, ClickEvent, CommonAttribute, Length, ResourceColor, SizeOptions } 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) => 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; + +export function applyUIAttributes(modifier: AttributeModifier, nativeNode: ArkCommonMethodPeer): void { + modifier.applyNormalAttribute(nativeNode._attributeSet! as T); + modifier.applyPressedAttribute(nativeNode._attributeSet! as T); + modifier.applyFocusedAttribute(nativeNode._attributeSet! as T); + modifier.applyDisabledAttribute(nativeNode._attributeSet! as T); + 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 OnClickModifier extends ModifierWithKey<(event: ClickEvent) => void> { + constructor(value: (event: ClickEvent) => void) { + super(value); + } + static identity: string = 'onClick'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetBackgroundColor(); + } else { + node.onClick0Attribute(this.value!); + } + } + + static factory(value:(event: ClickEvent) => void): OnClickModifier { + return new OnClickModifier(value) + } +} + +class ZIndexModifier extends ModifierWithKey { + constructor(value: number) { + super(value); + } + static identity: string = 'zIndex'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetBackgroundColor(); + } else { + node.zIndexAttribute(this.value!); + } + } + static factory(value: number): ZIndexModifier { + return new ZIndexModifier(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) + } +} + +class SizeModifier extends ModifierWithKey { + constructor(value: SizeOptions) { + super(value); + } + static identity: string = 'height'; + applyPeer(node: ArkCommonMethodPeer, reset: boolean): void { + if (reset) { + // commomPeerNode.resetWidthAttribute(); + } else { + node.sizeAttribute(this.value!); + } + } + static factory(value: SizeOptions): SizeModifier { + return new SizeModifier(value) + } +} + +export function modifierWithKey>( + modifiers: ObservedMap, + identity: string, + modifierClass: (value: T) => M, value: T) { + let item = modifiers.get(identity) + if (item == undefined) { + modifiers.set(identity, modifierClass(value)); + return; + } + let item1 = item as ModifierWithKey; + item1.stageValue = value; + modifiers.set(identity, item1); +} +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); + } + }); + } + + 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; + } + + zIndex(value:number):this { + if (value) { + modifierWithKey(this._modifiersWithKeys, ZIndexModifier.identity, ZIndexModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, ZIndexModifier.identity) + } + return this; + } + + onClick(value:(event: ClickEvent) => void):this { + if (value) { + modifierWithKey(this._modifiersWithKeys, OnClickModifier.identity, OnClickModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, OnClickModifier.identity) + } + return this; + } + size(value: SizeOptions): this { + if (value) { + modifierWithKey(this._modifiersWithKeys, SizeModifier.identity, SizeModifier.factory, value); + } else { + modifierNullWithKey(this._modifiersWithKeys, SizeModifier.identity) + } + return this; + } +} +export class CommonModifier extends ArkCommonAttributeSet implements AttributeModifier { + applyNormalAttribute(instance: CommonAttribute): void { + + } + applyPressedAttribute(instance: CommonAttribute): void { + + } + applyFocusedAttribute(instance: CommonAttribute): void { + + } + applyDisabledAttribute(instance: CommonAttribute): void { + + } + applySelectedAttribute(instance: CommonAttribute): void { + + } + +} + diff --git a/arkoala-arkts/arkui/src/handwritten/resources.ts b/arkoala-arkts/arkui/src/handwritten/resources.ts index 97501d9b49f3b8a1285e1095030bde22be2a6af4..dd94deae97e5b6d8ae70a53681099b2d8ea6ba4e 100644 --- a/arkoala-arkts/arkui/src/handwritten/resources.ts +++ b/arkoala-arkts/arkui/src/handwritten/resources.ts @@ -3,10 +3,6 @@ import { int32 } from "@koalaui/common"; import { ArkUIGeneratedNativeModule } from "#components"; import { Serializer } from "../generated/peers/Serializer"; -export interface AttributeModifier { - isUpdater: boolean; -} - class ArkResource implements Resource { bundleName: string = ""; moduleName: string = ""; diff --git a/arkoala-arkts/arkui/src/index.ts b/arkoala-arkts/arkui/src/index.ts index 890e78d2236c1e1f294feab8293ca1931aeaef64..42327fe3fad3c8b360f3d62e0a694814e4a94d75 100644 --- a/arkoala-arkts/arkui/src/index.ts +++ b/arkoala-arkts/arkui/src/index.ts @@ -26,6 +26,7 @@ export * from "./UserView" 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..4d1e7b773140559036e351376de2b54a9aa15a39 --- /dev/null +++ b/arkoala-arkts/arkui/src/ohos.arkui.modifier.ts @@ -0,0 +1,20 @@ +/* + * 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' + +export { CommonModifier } from './handwritten/modifiers/ArkCommonModifier' diff --git a/arkoala-arkts/arkui/types/index-full.d.ts b/arkoala-arkts/arkui/types/index-full.d.ts index 4de299b586003113694f51a0117a53011987d4fe..ea7b3c9a680d0b5d64fbc44175082802375ca63d 100644 --- a/arkoala-arkts/arkui/types/index-full.d.ts +++ b/arkoala-arkts/arkui/types/index-full.d.ts @@ -2112,6 +2112,7 @@ declare interface AttributeModifier { applyDisabledAttribute?(instance: T): void; applySelectedAttribute?(instance: T): void; } + declare interface ContentModifier { stub: string; } 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/Page.ts b/arkoala-arkts/shopping/user/src/Page.ts index e71474c5feffe3156c171dbfdbba0ae2c3c62a1b..aa2084fea8152f33dd6c4da8b9b55733441a434a 100644 --- a/arkoala-arkts/shopping/user/src/Page.ts +++ b/arkoala-arkts/shopping/user/src/Page.ts @@ -1,4 +1,4 @@ -import { Index } from "app/pages/index-entry" +import { Index } from "app/pages/page1" import { UserView, UserViewBuilder } from "@koalaui/arkts-arkui" export class ComExampleShoppingApplication extends UserView { 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 b52e9bc96a4eae51bd6733cd5d29c03be6ca5dd9..684083691ce1aef1d85fa2100f480b282f4d79a7 100644 --- a/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets +++ b/arkoala-arkts/shopping/user/src/ets/pages/index-entry.ets @@ -49,6 +49,7 @@ struct Index { @Provide('pathInfos') pathInfos : NavPathStack = new NavPathStack() //listener = mediaQuery.matchMediaSync('(orientation:landscape)') + aboutToAppear() { //this.listener.on('change', this.onPortrait) } diff --git a/arkoala-arkts/shopping/user/src/ets/pages/page1.ets b/arkoala-arkts/shopping/user/src/ets/pages/page1.ets new file mode 100644 index 0000000000000000000000000000000000000000..d78f97cab939374edfa605d3dd13ba3b69d56925 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/pages/page1.ets @@ -0,0 +1,36 @@ +import { CommonModifier } from '@ohos.arkui.modifier' + +class MyCommonModifier extends CommonModifier { + applyNormalAttribute(instance: CommonAttribute): void { + + instance.width(100) + instance.height("40%") + instance.zIndex(2) + } +} + +class MyCommonModifier2 extends CommonModifier { + applyNormalAttribute(instance: CommonAttribute): void { + instance.size({width:150,height:150}) + instance.onClick((e:ClickEvent ) => { + console.log("wjh 123") + }) + } +} + +@Entry +@Component +struct Index { + modifier: MyCommonModifier = new MyCommonModifier() + build() { + Stack() { + Text("hello word").attributeModifier(this.modifier) + .backgroundColor(Color.Orange) + Button("test button") + .zIndex(1) + .backgroundColor(Color.Orange) + .attributeModifier(new MyCommonModifier2()) + }.width(200) + .height(200) + } +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json index 26a46e6a86c68f15c55ecce07f6b24efd516801d..accdc01e479582cf1abe419e5b5f6a73a986171c 100644 --- a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json +++ b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json @@ -34,6 +34,9 @@ "@koalaui/arkts-arkui/ohos.arkui.UIContext": [ "../../arkui/src/ohos.arkui.UIContext.ts" ], + "@koalaui/arkts-arkui/ohos.arkui.modifier": [ + "../../arkui/src/ohos.arkui.modifier.ts" + ], "app/*": [ "./build/generated/*" ] diff --git a/arkoala-arkts/trivial/user/tsconfig-unmemoize.json b/arkoala-arkts/trivial/user/tsconfig-unmemoize.json index 901e24298f1dd8bc0a7a725868562d5e0e2519b3..cd2fbcfa30603a2acb7ea39ad87d77f28d3488c2 100644 --- a/arkoala-arkts/trivial/user/tsconfig-unmemoize.json +++ b/arkoala-arkts/trivial/user/tsconfig-unmemoize.json @@ -31,6 +31,9 @@ "@koalaui/arkts-arkui/ohos.measure": [ "../../arkui/src/ohos.measure.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 4c8de6303c4e62dc0f426b85ef534f8a6268cf4d..a5861215e66b32cf1b4bf3bc945f4d3c6dbe6e90 100644 --- a/arkoala/ets-plugin/src/Importer.ts +++ b/arkoala/ets-plugin/src/Importer.ts @@ -117,7 +117,8 @@ function implementedPackages(kind: ArkUIImplementation): string[] { if (kind == ArkUIImplementation.ARKTS) return [ 'ohos.router', 'ohos.arkui.UIContext', - 'ohos.measure' + 'ohos.measure', + 'ohos.arkui.modifier' ] assertUnreachable(kind) diff --git a/arkoala/ets-plugin/src/StructTransformer.ts b/arkoala/ets-plugin/src/StructTransformer.ts index ded322b0f3e77a1c89ccbeff42bffa037a6a386d..257e5e515c8da7ecf2cc500ef7e931dce53de8ae 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,