From dadf8280e7063d550a6a51fe65993a9d5311353e Mon Sep 17 00:00:00 2001 From: g00500048 Date: Thu, 14 Aug 2025 22:35:56 +0800 Subject: [PATCH] span modifier Signed-off-by: g00500048 --- .../arkui-ohos/src/AttributeUpdater.ts | 3 +- .../arkui-ohos/src/BaseSpanModifier.ts | 126 +++++ .../arkui-ohos/src/ContainerSpanModifier.ts | 81 ++++ .../arkui-ohos/src/ImageSpanModifier.ts | 312 +++++++++++++ .../arkui-ohos/src/MarqueeModifier.ts | 1 - .../arkui-ohos/src/SpanModifier.ts | 442 ++++++++++++++++++ .../arkui-ohos/src/SymbolSpanModifier.ts | 313 +++++++++++++ .../arkui-ohos/src/TextModifier.ts | 8 +- .../arkui-ohos/src/component/containerSpan.ts | 13 +- .../arkui-ohos/src/component/imageSpan.ts | 23 +- .../arkui-ohos/src/component/span.ts | 38 +- .../arkui-ohos/src/component/symbolSpan.ts | 22 +- .../AttributeModifierOpsHandWritten.ts | 154 +++++- .../modifiers/ArkCommonModifier.ts | 33 +- .../arkui-ohos/src/ohos.arkui.modifier.ts | 8 + 15 files changed, 1531 insertions(+), 46 deletions(-) create mode 100644 frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/BaseSpanModifier.ts create mode 100644 frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ContainerSpanModifier.ts create mode 100644 frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ImageSpanModifier.ts create mode 100644 frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SpanModifier.ts create mode 100644 frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SymbolSpanModifier.ts diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/AttributeUpdater.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/AttributeUpdater.ts index dc58eee5355..b80b46f7b7e 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/AttributeUpdater.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/AttributeUpdater.ts @@ -14,6 +14,7 @@ */ import { AttributeModifier, ArkCommonMethodPeer } from "arkui/component/common"; +import { PeerNode } from "./PeerNode" export type Initializer = (...params:FixedArray) => T; @@ -25,7 +26,7 @@ export class AttributeUpdater implements AttributeModifier { } private value: T | undefined = undefined; private constructorParams: Initializer | undefined = undefined; - public peerNode_?: ArkCommonMethodPeer; + public peerNode_?: PeerNode; public set attribute(value: T) { this.value = value diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/BaseSpanModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/BaseSpanModifier.ts new file mode 100644 index 00000000000..48ffd275f35 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/BaseSpanModifier.ts @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { AttributeModifier } from "./component/common" +import { AttributeUpdaterFlag, CommonMethodModifier } from "./CommonMethodModifier" + +import { ArkBaseSpanPeer, BaseSpan, TextBackgroundStyle } from "./component/span" +import { LengthMetrics } from "./Graphics" +import { PeerNode } from "./PeerNode" + +export class BaseSpanModifier extends CommonMethodModifier implements BaseSpan { + _textBackgroundStyle_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _textBackgroundStyle_0_0value?: TextBackgroundStyle | undefined + _baselineOffset_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _baselineOffset_0_0value?: LengthMetrics | undefined + applyModifierPatch(value: PeerNode): void { + super.applyModifierPatch(value) + const peer: ArkBaseSpanPeer = value as ArkBaseSpanPeer + if (this._textBackgroundStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._textBackgroundStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.textBackgroundStyleAttribute((this._textBackgroundStyle_0_0value as TextBackgroundStyle | undefined)); + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.INITIAL; + peer.textBackgroundStyleAttribute((undefined as TextBackgroundStyle | undefined)); + } + } + } + if (this._baselineOffset_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._baselineOffset_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.baselineOffsetAttribute((this._baselineOffset_0_0value as LengthMetrics | undefined)); + this._baselineOffset_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._baselineOffset_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._baselineOffset_0_flag = AttributeUpdaterFlag.INITIAL; + peer.baselineOffsetAttribute((undefined as LengthMetrics | undefined)); + } + } + } + } + mergeModifier(value: CommonMethodModifier): void { + super.mergeModifier(value) + if (!(value instanceof BaseSpanModifier)) { + return + } + const modifier = value as BaseSpanModifier; + if (modifier._textBackgroundStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._textBackgroundStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.textBackgroundStyle(modifier._textBackgroundStyle_0_0value); + break; + } + default: { + this.textBackgroundStyle((undefined as TextBackgroundStyle | undefined)); + } + } + } + if (modifier._baselineOffset_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._baselineOffset_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.baselineOffset(modifier._baselineOffset_0_0value); + break; + } + default: { + this.baselineOffset((undefined as LengthMetrics | undefined)); + } + } + } + } + textBackgroundStyle(value: TextBackgroundStyle | undefined): this { + if (((this._textBackgroundStyle_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._textBackgroundStyle_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.UPDATE + this._textBackgroundStyle_0_0value = value + } else + { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + baselineOffset(value: LengthMetrics | undefined): this { + if (((this._baselineOffset_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._baselineOffset_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._baselineOffset_0_flag = AttributeUpdaterFlag.UPDATE + this._baselineOffset_0_0value = value + } else + { + this._baselineOffset_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ContainerSpanModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ContainerSpanModifier.ts new file mode 100644 index 00000000000..eb6bc28a398 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ContainerSpanModifier.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { ArkContainerSpanPeer } from "./component/containerSpan" +import { AttributeModifier } from "./component/common" +import { AttributeUpdaterFlag } from './CommonMethodModifier' +import { TextBackgroundStyle } from "./component/span" +import { ContainerSpanAttribute } from "./component/containerSpan" +import { PeerNode } from "./PeerNode" + +export class ContainerSpanModifier implements ContainerSpanAttribute,AttributeModifier { + _instanceId: number = -1; + setInstanceId(instanceId: number): void { + this._instanceId = instanceId + } + applyNormalAttribute(instance: ContainerSpanAttribute): void { } + _textBackgroundStyle_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _textBackgroundStyle_0_0value?: TextBackgroundStyle | undefined + applyModifierPatch(value: PeerNode): void { + const peer: ArkContainerSpanPeer = value as ArkContainerSpanPeer + if (this._textBackgroundStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._textBackgroundStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.textBackgroundStyleAttribute((this._textBackgroundStyle_0_0value as TextBackgroundStyle | undefined)); + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.INITIAL; + peer.textBackgroundStyleAttribute((undefined as TextBackgroundStyle | undefined)); + } + } + } + } + mergeModifier(modifier: ContainerSpanModifier): void { + if (modifier._textBackgroundStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._textBackgroundStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.textBackgroundStyle(modifier._textBackgroundStyle_0_0value); + break; + } + default: { + this.textBackgroundStyle((undefined as TextBackgroundStyle | undefined)); + } + } + } + } + textBackgroundStyle(value: TextBackgroundStyle | undefined): this { + if (((this._textBackgroundStyle_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._textBackgroundStyle_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.UPDATE + this._textBackgroundStyle_0_0value = value + } else + { + this._textBackgroundStyle_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ImageSpanModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ImageSpanModifier.ts new file mode 100644 index 00000000000..1cfdcd92a10 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ImageSpanModifier.ts @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { ArkImageSpanPeer } from "./component/imageSpan" +import { AttributeModifier } from "./component/common" +import { AttributeUpdaterFlag, CommonMethodModifier } from './CommonMethodModifier' +import { BaseSpanModifier } from "./BaseSpanModifier" +import { ColorFilter } from "./component/units" +import { drawing } from "@ohos/graphics/drawing" +import { ImageCompleteCallback, ImageLoadResult, ImageSpanAttribute } from "./component/imageSpan" +import { ImageErrorCallback, ImageError } from "./component/image" +import { ImageSpanAlignment, ImageFit } from "./component/enums" +import image from "@ohos.multimedia.image" +import { PeerNode } from "./PeerNode"; + +export class ImageSpanModifier extends BaseSpanModifier implements ImageSpanAttribute,AttributeModifier { + _instanceId: number = -1; + setInstanceId(instanceId: number): void { + this._instanceId = instanceId + } + applyNormalAttribute(instance: ImageSpanAttribute): void { } + _verticalAlign_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _verticalAlign_0_0value?: ImageSpanAlignment | undefined + _colorFilter_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _colorFilter_0_0value?: ColorFilter | drawing.ColorFilter | undefined + _objectFit_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _objectFit_0_0value?: ImageFit | undefined + _onComplete_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _onComplete_0_0value?: ImageCompleteCallback | undefined + _onError_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _onError_0_0value?: ImageErrorCallback | undefined + _alt_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _alt_0_0value?: image.PixelMap | undefined + applyModifierPatch(value: PeerNode): void { + super.applyModifierPatch(value) + const peer: ArkImageSpanPeer = value as ArkImageSpanPeer + if (this._verticalAlign_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._verticalAlign_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.verticalAlignAttribute((this._verticalAlign_0_0value as ImageSpanAlignment | undefined)); + this._verticalAlign_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._verticalAlign_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._verticalAlign_0_flag = AttributeUpdaterFlag.INITIAL; + peer.verticalAlignAttribute((undefined as ImageSpanAlignment | undefined)); + } + } + } + if (this._colorFilter_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._colorFilter_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.colorFilterAttribute((this._colorFilter_0_0value as ColorFilter | drawing.ColorFilter | undefined)); + this._colorFilter_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._colorFilter_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._colorFilter_0_flag = AttributeUpdaterFlag.INITIAL; + peer.colorFilterAttribute((undefined as ColorFilter | drawing.ColorFilter | undefined)); + } + } + } + if (this._objectFit_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._objectFit_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.objectFitAttribute((this._objectFit_0_0value as ImageFit | undefined)); + this._objectFit_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._objectFit_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._objectFit_0_flag = AttributeUpdaterFlag.INITIAL; + peer.objectFitAttribute((undefined as ImageFit | undefined)); + } + } + } + if (this._onComplete_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._onComplete_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.onCompleteAttribute((this._onComplete_0_0value as ImageCompleteCallback | undefined)); + this._onComplete_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._onComplete_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._onComplete_0_flag = AttributeUpdaterFlag.INITIAL; + peer.onCompleteAttribute((undefined as ImageCompleteCallback | undefined)); + } + } + } + if (this._onError_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._onError_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.onErrorAttribute((this._onError_0_0value as ImageErrorCallback | undefined)); + this._onError_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._onError_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._onError_0_flag = AttributeUpdaterFlag.INITIAL; + peer.onErrorAttribute((undefined as ImageErrorCallback | undefined)); + } + } + } + if (this._alt_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._alt_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.altAttribute((this._alt_0_0value as image.PixelMap | undefined)); + this._alt_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._alt_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._alt_0_flag = AttributeUpdaterFlag.INITIAL; + peer.altAttribute((undefined as image.PixelMap | undefined)); + } + } + } + } + mergeModifier(value: CommonMethodModifier): void { + super.mergeModifier(value) + if (!(value instanceof ImageSpanModifier)) { + return + } + const modifier = value as ImageSpanModifier; + if (modifier._verticalAlign_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._verticalAlign_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.verticalAlign(modifier._verticalAlign_0_0value); + break; + } + default: { + this.verticalAlign((undefined as ImageSpanAlignment | undefined)); + } + } + } + if (modifier._colorFilter_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._colorFilter_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.colorFilter(modifier._colorFilter_0_0value); + break; + } + default: { + this.colorFilter((undefined as ColorFilter | drawing.ColorFilter | undefined)); + } + } + } + if (modifier._objectFit_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._objectFit_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.objectFit(modifier._objectFit_0_0value); + break; + } + default: { + this.objectFit((undefined as ImageFit | undefined)); + } + } + } + if (modifier._onComplete_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._onComplete_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.onComplete(modifier._onComplete_0_0value); + break; + } + default: { + this.onComplete((undefined as ImageCompleteCallback | undefined)); + } + } + } + if (modifier._onError_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._onError_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.onError(modifier._onError_0_0value); + break; + } + default: { + this.onError((undefined as ImageErrorCallback | undefined)); + } + } + } + if (modifier._alt_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._alt_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.alt(modifier._alt_0_0value); + break; + } + default: { + this.alt((undefined as image.PixelMap | undefined)); + } + } + } + } + verticalAlign(value: ImageSpanAlignment | undefined): this { + if (((this._verticalAlign_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._verticalAlign_0_0value !== value) + { + this._verticalAlign_0_flag = AttributeUpdaterFlag.UPDATE + this._verticalAlign_0_0value = value + } else + { + this._verticalAlign_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + colorFilter(value: ColorFilter | drawing.ColorFilter | undefined): this { + if (((this._colorFilter_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._colorFilter_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._colorFilter_0_flag = AttributeUpdaterFlag.UPDATE + this._colorFilter_0_0value = value + } else + { + this._colorFilter_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + objectFit(value: ImageFit | undefined): this { + if (((this._objectFit_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._objectFit_0_0value !== value) + { + this._objectFit_0_flag = AttributeUpdaterFlag.UPDATE + this._objectFit_0_0value = value + } else + { + this._objectFit_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + onComplete(value: ImageCompleteCallback | undefined): this { + if (((this._onComplete_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._onComplete_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._onComplete_0_flag = AttributeUpdaterFlag.UPDATE + this._onComplete_0_0value = value + } else + { + this._onComplete_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + onError(value: ImageErrorCallback | undefined): this { + if (((this._onError_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._onError_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._onError_0_flag = AttributeUpdaterFlag.UPDATE + this._onError_0_0value = value + } else + { + this._onError_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + alt(value: image.PixelMap | undefined): this { + if (((this._alt_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._alt_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._alt_0_flag = AttributeUpdaterFlag.UPDATE + this._alt_0_0value = value + } else + { + this._alt_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/MarqueeModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/MarqueeModifier.ts index 6fa08d2b5ce..99c03b69547 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/MarqueeModifier.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/MarqueeModifier.ts @@ -201,7 +201,6 @@ export class MarqueeModifier extends CommonMethodModifier implements MarqueeAttr } default: { this._setMarqueeOptions_0_flag = AttributeUpdaterFlag.INITIAL - // peer.setMarqueeOptionsAttribute(undefined) } } } diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SpanModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SpanModifier.ts new file mode 100644 index 00000000000..2b7e25aab27 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SpanModifier.ts @@ -0,0 +1,442 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { ArkSpanPeer, SpanAttribute } from "./component/span" +import { AttributeModifier, ShadowOptions, CommonMethod } from "./component/common" +import { AttributeUpdaterFlag, CommonMethodModifier } from "./CommonMethodModifier" +import { BaseSpanModifier } from "./BaseSpanModifier" +import { Font, ResourceColor, Length } from "./component/units" +import { FontStyle, TextCase } from "./component/enums" +import { Resource } from "global.resource" +import { DecorationStyleInterface } from "./component/styledString" +import { PeerNode } from "./PeerNode" + +export class SpanModifier extends BaseSpanModifier implements SpanAttribute,AttributeModifier { + _instanceId: number = -1; + setInstanceId(instanceId: number): void { + this._instanceId = instanceId + } + applyNormalAttribute(instance: SpanAttribute): void { } + _font_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _font_0_0value?: Font | undefined + _fontColor_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontColor_0_0value?: ResourceColor | undefined + _fontSize_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontSize_0_0value?: number | string | Resource | undefined + _fontStyle_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontStyle_0_0value?: FontStyle | undefined + _fontFamily_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontFamily_0_0value?: string | Resource | undefined + _decoration_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _decoration_0_0value?: DecorationStyleInterface | undefined + _textCase_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _textCase_0_0value?: TextCase | undefined + _lineHeight_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _lineHeight_0_0value?: Length | undefined + _textShadow_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _textShadow_0_0value?: ShadowOptions | Array | undefined + applyModifierPatch(value: PeerNode): void { + super.applyModifierPatch(value) + const peer: ArkSpanPeer = value as ArkSpanPeer + if (this._font_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._font_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontAttribute((this._font_0_0value as Font | undefined)); + this._font_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._font_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._font_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontAttribute((undefined as Font | undefined)); + } + } + } + if (this._fontColor_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontColor_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontColorAttribute((this._fontColor_0_0value as ResourceColor | undefined)); + this._fontColor_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontColor_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontColor_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontColorAttribute((undefined as ResourceColor | undefined)); + } + } + } + if (this._fontSize_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontSize_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontSizeAttribute((this._fontSize_0_0value as number | string | Resource | undefined)); + this._fontSize_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontSize_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontSize_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontSizeAttribute((undefined as number | string | Resource | undefined)); + } + } + } + if (this._fontStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontStyleAttribute((this._fontStyle_0_0value as FontStyle | undefined)); + this._fontStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontStyle_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontStyle_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontStyleAttribute((undefined as FontStyle | undefined)); + } + } + } + if (this._fontFamily_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontFamily_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontFamilyAttribute((this._fontFamily_0_0value as string | Resource | undefined)); + this._fontFamily_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontFamily_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontFamily_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontFamilyAttribute((undefined as string | Resource | undefined)); + } + } + } + if (this._decoration_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._decoration_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.decorationAttribute((this._decoration_0_0value as DecorationStyleInterface | undefined)); + this._decoration_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._decoration_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._decoration_0_flag = AttributeUpdaterFlag.INITIAL; + peer.decorationAttribute((undefined as DecorationStyleInterface | undefined)); + } + } + } + if (this._textCase_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._textCase_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.textCaseAttribute((this._textCase_0_0value as TextCase | undefined)); + this._textCase_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._textCase_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._textCase_0_flag = AttributeUpdaterFlag.INITIAL; + peer.textCaseAttribute((undefined as TextCase | undefined)); + } + } + } + if (this._lineHeight_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._lineHeight_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.lineHeightAttribute((this._lineHeight_0_0value as Length | undefined)); + this._lineHeight_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._lineHeight_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._lineHeight_0_flag = AttributeUpdaterFlag.INITIAL; + peer.lineHeightAttribute((undefined as Length | undefined)); + } + } + } + if (this._textShadow_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._textShadow_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.textShadowAttribute((this._textShadow_0_0value as ShadowOptions | Array | undefined)); + this._textShadow_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._textShadow_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._textShadow_0_flag = AttributeUpdaterFlag.INITIAL; + peer.textShadowAttribute((undefined as ShadowOptions | Array | undefined)); + } + } + } + } + mergeModifier(value: CommonMethodModifier): void { + super.mergeModifier(value) + if (!(value instanceof SpanModifier)) { + return + } + const modifier = value as SpanModifier; + if (modifier._font_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._font_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.font(modifier._font_0_0value); + break; + } + default: { + this.font((undefined as Font | undefined)); + } + } + } + if (modifier._fontColor_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontColor_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontColor(modifier._fontColor_0_0value); + break; + } + default: { + this.fontColor((undefined as ResourceColor | undefined)); + } + } + } + if (modifier._fontSize_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontSize_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontSize(modifier._fontSize_0_0value); + break; + } + default: { + this.fontSize((undefined as number | string | Resource | undefined)); + } + } + } + if (modifier._fontStyle_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontStyle_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontStyle(modifier._fontStyle_0_0value); + break; + } + default: { + this.fontStyle((undefined as FontStyle | undefined)); + } + } + } + if (modifier._fontFamily_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontFamily_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontFamily(modifier._fontFamily_0_0value); + break; + } + default: { + this.fontFamily((undefined as string | Resource | undefined)); + } + } + } + if (modifier._decoration_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._decoration_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.decoration(modifier._decoration_0_0value); + break; + } + default: { + this.decoration((undefined as DecorationStyleInterface | undefined)); + } + } + } + if (modifier._textCase_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._textCase_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.textCase(modifier._textCase_0_0value); + break; + } + default: { + this.textCase((undefined as TextCase | undefined)); + } + } + } + if (modifier._lineHeight_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._lineHeight_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.lineHeight(modifier._lineHeight_0_0value); + break; + } + default: { + this.lineHeight((undefined as Length | undefined)); + } + } + } + if (modifier._textShadow_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._textShadow_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.textShadow(modifier._textShadow_0_0value); + break; + } + default: { + this.textShadow((undefined as ShadowOptions | Array | undefined)); + } + } + } + } + font(value: Font | undefined): this { + if (((this._font_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._font_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._font_0_flag = AttributeUpdaterFlag.UPDATE + this._font_0_0value = value + } else + { + this._font_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontColor(value: ResourceColor | undefined): this { + if (((this._fontColor_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontColor_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._fontColor_0_flag = AttributeUpdaterFlag.UPDATE + this._fontColor_0_0value = value + } else + { + this._fontColor_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontSize(value: number | string | Resource | undefined): this { + if (((this._fontSize_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontSize_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._fontSize_0_flag = AttributeUpdaterFlag.UPDATE + this._fontSize_0_0value = value + } else + { + this._fontSize_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontStyle(value: FontStyle | undefined): this { + if (((this._fontStyle_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontStyle_0_0value !== value) + { + this._fontStyle_0_flag = AttributeUpdaterFlag.UPDATE + this._fontStyle_0_0value = value + } else + { + this._fontStyle_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontFamily(value: string | Resource | undefined): this { + if (((this._fontFamily_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontFamily_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._fontFamily_0_flag = AttributeUpdaterFlag.UPDATE + this._fontFamily_0_0value = value + } else + { + this._fontFamily_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + decoration(value: DecorationStyleInterface | undefined): this { + if (((this._decoration_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._decoration_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._decoration_0_flag = AttributeUpdaterFlag.UPDATE + this._decoration_0_0value = value + } else + { + this._decoration_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + textCase(value: TextCase | undefined): this { + if (((this._textCase_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._textCase_0_0value !== value) + { + this._textCase_0_flag = AttributeUpdaterFlag.UPDATE + this._textCase_0_0value = value + } else + { + this._textCase_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + lineHeight(value: Length | undefined): this { + if (((this._lineHeight_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._lineHeight_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._lineHeight_0_flag = AttributeUpdaterFlag.UPDATE + this._lineHeight_0_0value = value + } else + { + this._lineHeight_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + textShadow(value: ShadowOptions | Array | undefined): this { + if (((this._textShadow_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._textShadow_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._textShadow_0_flag = AttributeUpdaterFlag.UPDATE + this._textShadow_0_0value = value + } else + { + this._textShadow_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SymbolSpanModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SymbolSpanModifier.ts new file mode 100644 index 00000000000..c5b360332b0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/SymbolSpanModifier.ts @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2024-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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { int32, int64, float32 } from "@koalaui/common" +import { KPointer, RuntimeType, runtimeType } from "@koalaui/interop" +import { ArkSymbolSpanPeer } from "./component/symbolSpan" +import { AttributeModifier, CommonMethod } from "./component/common" +import { AttributeUpdaterFlag, CommonMethodModifier } from './CommonMethodModifier' +import { Resource } from "global.resource" +import { ResourceColor } from "./component/units" +import { FontWeight } from "./component/enums" +import { SymbolEffectStrategy, SymbolRenderingStrategy } from "./component/symbolglyph" +import { SymbolSpanAttribute } from "./component/symbolSpan" +import { PeerNode } from "./PeerNode" + +export class SymbolSpanModifier extends CommonMethodModifier implements SymbolSpanAttribute,AttributeModifier { + _instanceId: number = -1; + setInstanceId(instanceId: number): void { + this._instanceId = instanceId + } + constructor(src?: Resource) { + super() + let src_type: int32 = RuntimeType.UNDEFINED + src_type = runtimeType(src) + if (RuntimeType.UNDEFINED != src_type) { + this.setSymbolSpanOptions(src) + } + } + applyNormalAttribute(instance: SymbolSpanAttribute): void { } + _setSymbolSpanOptions_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _setSymbolSpanOptions0_value?: Resource | undefined + _fontSize_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontSize_0_0value?: number | string | Resource | undefined + _fontColor_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontColor_0_0value?: Array | undefined + _fontWeight_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _fontWeight_0_0value?: number | FontWeight | string | undefined + _effectStrategy_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _effectStrategy_0_0value?: SymbolEffectStrategy | undefined + _renderingStrategy_0_flag: AttributeUpdaterFlag = AttributeUpdaterFlag.INITIAL + _renderingStrategy_0_0value?: SymbolRenderingStrategy | undefined + applyModifierPatch(value: PeerNode): void { + super.applyModifierPatch(value) + const peer: ArkSymbolSpanPeer = value as ArkSymbolSpanPeer + if (this._setSymbolSpanOptions_flag !== AttributeUpdaterFlag.INITIAL) { + switch (this._setSymbolSpanOptions_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.setSymbolSpanOptionsAttribute((this._setSymbolSpanOptions0_value! as Resource)) + this._setSymbolSpanOptions_flag = AttributeUpdaterFlag.RESET + break + } + case AttributeUpdaterFlag.SKIP: { + this._setSymbolSpanOptions_flag = AttributeUpdaterFlag.RESET + break + } + default: { + this._setSymbolSpanOptions_flag = AttributeUpdaterFlag.INITIAL + } + } + } + if (this._fontSize_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontSize_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontSizeAttribute((this._fontSize_0_0value as number | string | Resource | undefined)); + this._fontSize_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontSize_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontSize_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontSizeAttribute((undefined as number | string | Resource | undefined)); + } + } + } + if (this._fontColor_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontColor_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontColorAttribute((this._fontColor_0_0value as Array | undefined)); + this._fontColor_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontColor_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontColor_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontColorAttribute((undefined as Array | undefined)); + } + } + } + if (this._fontWeight_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._fontWeight_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.fontWeightAttribute((this._fontWeight_0_0value as number | FontWeight | string | undefined)); + this._fontWeight_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._fontWeight_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._fontWeight_0_flag = AttributeUpdaterFlag.INITIAL; + peer.fontWeightAttribute((undefined as number | FontWeight | string | undefined)); + } + } + } + if (this._effectStrategy_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._effectStrategy_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.effectStrategyAttribute((this._effectStrategy_0_0value as SymbolEffectStrategy | undefined)); + this._effectStrategy_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._effectStrategy_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._effectStrategy_0_flag = AttributeUpdaterFlag.INITIAL; + peer.effectStrategyAttribute((undefined as SymbolEffectStrategy | undefined)); + } + } + } + if (this._renderingStrategy_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (this._renderingStrategy_0_flag) { + case AttributeUpdaterFlag.UPDATE: { + peer.renderingStrategyAttribute((this._renderingStrategy_0_0value as SymbolRenderingStrategy | undefined)); + this._renderingStrategy_0_flag = AttributeUpdaterFlag.RESET; + break; + } + case AttributeUpdaterFlag.SKIP: { + this._renderingStrategy_0_flag = AttributeUpdaterFlag.RESET; + break; + } + default: { + this._renderingStrategy_0_flag = AttributeUpdaterFlag.INITIAL; + peer.renderingStrategyAttribute((undefined as SymbolRenderingStrategy | undefined)); + } + } + } + } + mergeModifier(value: CommonMethodModifier): void { + super.mergeModifier(value) + if (!(value instanceof SymbolSpanModifier)) { + return + } + const modifier = value as SymbolSpanModifier; + if (modifier._setSymbolSpanOptions_flag !== AttributeUpdaterFlag.INITIAL) { + switch (modifier._setSymbolSpanOptions_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.setSymbolSpanOptions(modifier._setSymbolSpanOptions0_value!) + break + } + } + } + if (modifier._fontSize_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontSize_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontSize(modifier._fontSize_0_0value); + break; + } + default: { + this.fontSize((undefined as number | string | Resource | undefined)); + } + } + } + if (modifier._fontColor_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontColor_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontColor(modifier._fontColor_0_0value); + break; + } + default: { + this.fontColor((undefined as Array | undefined)); + } + } + } + if (modifier._fontWeight_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._fontWeight_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.fontWeight(modifier._fontWeight_0_0value); + break; + } + default: { + this.fontWeight((undefined as number | FontWeight | string | undefined)); + } + } + } + if (modifier._effectStrategy_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._effectStrategy_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.effectStrategy(modifier._effectStrategy_0_0value); + break; + } + default: { + this.effectStrategy((undefined as SymbolEffectStrategy | undefined)); + } + } + } + if (modifier._renderingStrategy_0_flag != AttributeUpdaterFlag.INITIAL) + { + switch (modifier._renderingStrategy_0_flag) { + case AttributeUpdaterFlag.UPDATE: + case AttributeUpdaterFlag.SKIP: { + this.renderingStrategy(modifier._renderingStrategy_0_0value); + break; + } + default: { + this.renderingStrategy((undefined as SymbolRenderingStrategy | undefined)); + } + } + } + } + public setSymbolSpanOptions(value: Resource | undefined): this { + if (this._setSymbolSpanOptions_flag === AttributeUpdaterFlag.INITIAL || + this._setSymbolSpanOptions0_value !== value || !Type.of(value).isPrimitive()) { + this._setSymbolSpanOptions0_value = value + this._setSymbolSpanOptions_flag = AttributeUpdaterFlag.UPDATE + } else { + this._setSymbolSpanOptions_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontSize(value: number | string | Resource | undefined): this { + if (((this._fontSize_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontSize_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._fontSize_0_flag = AttributeUpdaterFlag.UPDATE + this._fontSize_0_0value = value + } else + { + this._fontSize_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontColor(value: Array | undefined): this { + if (((this._fontColor_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontColor_0_0value !== value || !Type.of(value).isPrimitive()) + { + this._fontColor_0_flag = AttributeUpdaterFlag.UPDATE + this._fontColor_0_0value = value + } else + { + this._fontColor_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + fontWeight(value: number | FontWeight | string | undefined): this { + if (((this._fontWeight_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._fontWeight_0_0value !== value) + { + this._fontWeight_0_flag = AttributeUpdaterFlag.UPDATE + this._fontWeight_0_0value = value + } else + { + this._fontWeight_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + effectStrategy(value: SymbolEffectStrategy | undefined): this { + if (((this._effectStrategy_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._effectStrategy_0_0value !== value) + { + this._effectStrategy_0_flag = AttributeUpdaterFlag.UPDATE + this._effectStrategy_0_0value = value + } else + { + this._effectStrategy_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } + renderingStrategy(value: SymbolRenderingStrategy | undefined): this { + if (((this._renderingStrategy_0_flag) == (AttributeUpdaterFlag.INITIAL)) || this._renderingStrategy_0_0value !== value) + { + this._renderingStrategy_0_flag = AttributeUpdaterFlag.UPDATE + this._renderingStrategy_0_0value = value + } else + { + this._renderingStrategy_0_flag = AttributeUpdaterFlag.SKIP + } + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/TextModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/TextModifier.ts index 252b00422b0..ef051023410 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/TextModifier.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/TextModifier.ts @@ -912,8 +912,12 @@ export class TextModifier extends CommonMethodModifier implements TextAttribute, } } } - mergeModifier(modifier: TextModifier): void { - super.mergeModifier(modifier) + mergeModifier(value: CommonMethodModifier): void { + super.mergeModifier(value) + if (!(value instanceof TextModifier)) { + return + } + const modifier = value as TextModifier; if (modifier._fontColor_flag != AttributeUpdaterFlag.INITIAL) { switch (modifier._fontColor_flag) { diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/containerSpan.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/containerSpan.ts index 9a7cf9b409c..3a471690773 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/containerSpan.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/containerSpan.ts @@ -27,7 +27,12 @@ import { TextBackgroundStyle } from "./span" import { CallbackKind } from "./peers/CallbackKind" import { CallbackTransformer } from "./peers/CallbackTransformer" import { NodeAttach, remember } from "@koalaui/runtime" +import { AttributeModifier } from "./common" +import { ContainerSpanModifier } from "../ContainerSpanModifier" +import { hookContainerSpanAttributeModifier } from "../handwritten" + export class ArkContainerSpanPeer extends PeerNode { + _attributeSet?: ContainerSpanModifier; protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } @@ -59,7 +64,8 @@ export interface ContainerSpanAttribute { setContainerSpanOptions(): this { return this } - textBackgroundStyle(value: TextBackgroundStyle | undefined): this + textBackgroundStyle(value: TextBackgroundStyle | undefined): this { return this; } + attributeModifier(value: AttributeModifier | undefined): this { return this; } } export class ArkContainerSpanStyle implements ContainerSpanAttribute { textBackgroundStyle_value?: TextBackgroundStyle | undefined @@ -89,7 +95,10 @@ export class ArkContainerSpanComponent extends ComponentBase implements Containe } return this } - + public attributeModifier(modifier: AttributeModifier | undefined): this { + hookContainerSpanAttributeModifier(this, modifier); + return this + } public applyAttributesFinish(): void { // we call this function outside of class, so need to make it public super.applyAttributesFinish() diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/imageSpan.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/imageSpan.ts index 2a44c09bbfe..6c44dee2ed4 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/imageSpan.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/imageSpan.ts @@ -32,10 +32,13 @@ import { CallbackKind } from "./peers/CallbackKind" import { CallbackTransformer } from "./peers/CallbackTransformer" import { NodeAttach, remember } from "@koalaui/runtime" -import { ArkCommonMethodComponent, ArkCommonMethodStyle, CommonMethod } from "./common" +import { ArkCommonMethodComponent, ArkCommonMethodStyle, CommonMethod, AttributeModifier } from "./common" import { drawing } from "@ohos/graphics/drawing" +import { ImageSpanModifier } from "../ImageSpanModifier" +import { hookImageSpanAttributeModifier } from "../handwritten" export class ArkImageSpanPeer extends ArkBaseSpanPeer { + _attributeSet?: ImageSpanModifier; protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } @@ -158,12 +161,13 @@ export interface ImageSpanAttribute extends BaseSpan { setImageSpanOptions(value: ResourceStr | PixelMap): this { return this } - verticalAlign(value: ImageSpanAlignment | undefined): this - colorFilter(value: ColorFilter | drawing.ColorFilter | undefined): this - objectFit(value: ImageFit | undefined): this - onComplete(value: ImageCompleteCallback | undefined): this - onError(value: ImageErrorCallback | undefined): this - alt(value: PixelMap | undefined): this + verticalAlign(value: ImageSpanAlignment | undefined): this { return this; } + colorFilter(value: ColorFilter | drawing.ColorFilter | undefined): this { return this; } + objectFit(value: ImageFit | undefined): this { return this; } + onComplete(value: ImageCompleteCallback | undefined): this { return this; } + onError(value: ImageErrorCallback | undefined): this { return this; } + alt(value: PixelMap | undefined): this { return this; } + attributeModifier(value: AttributeModifier | AttributeModifier| undefined): this { return this; } } export class ArkImageSpanStyle extends ArkBaseSpanStyle implements ImageSpanAttribute { verticalAlign_value?: ImageSpanAlignment | undefined @@ -263,7 +267,10 @@ export class ArkImageSpanComponent extends ArkBaseSpanComponent implements Image } return this } - + public attributeModifier(modifier: AttributeModifier | AttributeModifier | undefined): this { + hookImageSpanAttributeModifier(this, modifier); + return this + } public applyAttributesFinish(): void { // we call this function outside of class, so need to make it public super.applyAttributesFinish() diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/span.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/span.ts index fafc83a2657..8f1deae7386 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/span.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/span.ts @@ -22,7 +22,7 @@ import { Serializer } from "./peers/Serializer" import { ComponentBase } from "./../ComponentBase" import { PeerNode } from "./../PeerNode" import { ArkUIGeneratedNativeModule, TypeChecker } from "#components" -import { ArkCommonMethodPeer, CommonMethod, ShadowOptions, ArkCommonMethodComponent, ArkCommonMethodStyle } from "./common" +import { ArkCommonMethodPeer, CommonMethod, ShadowOptions, ArkCommonMethodComponent, ArkCommonMethodStyle, AttributeModifier } from "./common" import { LengthMetrics } from "../Graphics" import { CallbackKind } from "./peers/CallbackKind" import { CallbackTransformer } from "./peers/CallbackTransformer" @@ -31,6 +31,8 @@ import { Resource } from "global.resource" import { FontStyle, FontWeight, TextCase, Color } from "./enums" import { DecorationStyleInterface } from "./styledString" import { NodeAttach, remember } from "@koalaui/runtime" +import { SpanModifier } from "../SpanModifier" +import { hookSpanAttributeModifier } from "../handwritten" export class ArkBaseSpanPeer extends ArkCommonMethodPeer { protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { @@ -69,6 +71,7 @@ export class ArkBaseSpanPeer extends ArkCommonMethodPeer { } } export class ArkSpanPeer extends ArkBaseSpanPeer { + _attributeSet?: SpanModifier; protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } @@ -324,8 +327,8 @@ export interface TextBackgroundStyle { radius?: Dimension | BorderRadiuses; } export interface BaseSpan extends CommonMethod { - textBackgroundStyle(value: TextBackgroundStyle | undefined): this - baselineOffset(value: LengthMetrics | undefined): this + textBackgroundStyle(value: TextBackgroundStyle | undefined): this { return this; } + baselineOffset(value: LengthMetrics | undefined): this { return this; } } export class ArkBaseSpanStyle extends ArkCommonMethodStyle implements BaseSpan { textBackgroundStyle_value?: TextBackgroundStyle | undefined @@ -342,17 +345,18 @@ export interface SpanAttribute extends BaseSpan { setSpanOptions(value: string | Resource): this { return this } - font(value: Font | undefined): this - fontColor(value: ResourceColor | undefined): this - fontSize(value: number | string | Resource | undefined): this - fontStyle(value: FontStyle | undefined): this - fontWeight(value: number | FontWeight | string | undefined): this - fontFamily(value: string | Resource | undefined): this - decoration(value: DecorationStyleInterface | undefined): this - letterSpacing(value: number | string | undefined): this - textCase(value: TextCase | undefined): this - lineHeight(value: Length | undefined): this - textShadow(value: ShadowOptions | Array | undefined): this + font(value: Font | undefined): this { return this; } + fontColor(value: ResourceColor | undefined): this { return this; } + fontSize(value: number | string | Resource | undefined): this { return this; } + fontStyle(value: FontStyle | undefined): this { return this; } + fontWeight(value: number | FontWeight | string | undefined): this { return this; } + fontFamily(value: string | Resource | undefined): this { return this; } + decoration(value: DecorationStyleInterface | undefined): this { return this; } + letterSpacing(value: number | string | undefined): this { return this; } + textCase(value: TextCase | undefined): this { return this; } + lineHeight(value: Length | undefined): this { return this; } + textShadow(value: ShadowOptions | Array | undefined): this { return this; } + attributeModifier(modifier: AttributeModifier | AttributeModifier | undefined): this { return this; } } export class ArkSpanStyle extends ArkBaseSpanStyle implements SpanAttribute { font_value?: Font | undefined @@ -423,7 +427,6 @@ export class ArkBaseSpanComponent extends ArkCommonMethodComponent implements Ba } return this } - public applyAttributesFinish(): void { // we call this function outside of class, so need to make it public super.applyAttributesFinish() @@ -529,7 +532,10 @@ export class ArkSpanComponent extends ArkBaseSpanComponent implements SpanAttrib } return this } - + public attributeModifier(modifier: AttributeModifier | AttributeModifier | undefined): this { + hookSpanAttributeModifier(this, modifier); + return this + } public applyAttributesFinish(): void { // we call this function outside of class, so need to make it public super.applyAttributesFinish() diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/symbolSpan.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/symbolSpan.ts index bfaae7c5e79..eb1c4af86eb 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/symbolSpan.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/symbolSpan.ts @@ -22,7 +22,7 @@ import { Serializer } from "./peers/Serializer" import { ComponentBase } from "./../ComponentBase" import { PeerNode } from "./../PeerNode" import { ArkUIGeneratedNativeModule, TypeChecker } from "#components" -import { ArkCommonMethodPeer, CommonMethod, ArkCommonMethodComponent, ArkCommonMethodStyle } from "./common" +import { ArkCommonMethodPeer, CommonMethod, ArkCommonMethodComponent, ArkCommonMethodStyle, AttributeModifier } from "./common" import { Resource } from "global.resource" import { ResourceColor } from "./units" import { FontWeight, Color } from "./enums" @@ -31,7 +31,11 @@ import { SymbolEffectStrategy, SymbolRenderingStrategy } from "./symbolglyph" import { CallbackKind } from "./peers/CallbackKind" import { CallbackTransformer } from "./peers/CallbackTransformer" import { NodeAttach, remember } from "@koalaui/runtime" +import { SymbolSpanModifier } from "../SymbolSpanModifier" +import { hookSymbolSpanAttributeModifier } from "../handwritten" + export class ArkSymbolSpanPeer extends ArkCommonMethodPeer { + _attributeSet?: SymbolSpanModifier; protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) { super(peerPtr, id, name, flags) } @@ -171,11 +175,12 @@ export interface SymbolSpanAttribute extends CommonMethod { setSymbolSpanOptions(value: Resource): this { return this } - fontSize(value: number | string | Resource | undefined): this - fontColor(value: Array | undefined): this - fontWeight(value: number | FontWeight | string | undefined): this - effectStrategy(value: SymbolEffectStrategy | undefined): this - renderingStrategy(value: SymbolRenderingStrategy | undefined): this + fontSize(value: number | string | Resource | undefined): this { return this; } + fontColor(value: Array | undefined): this { return this; } + fontWeight(value: number | FontWeight | string | undefined): this { return this; } + effectStrategy(value: SymbolEffectStrategy | undefined): this { return this; } + renderingStrategy(value: SymbolRenderingStrategy | undefined): this { return this; } + attributeModifier(value: AttributeModifier | AttributeModifier| undefined): this { return this; } } export class ArkSymbolSpanStyle extends ArkCommonMethodStyle implements SymbolSpanAttribute { fontSize_value?: number | string | Resource | undefined @@ -254,7 +259,10 @@ export class ArkSymbolSpanComponent extends ArkCommonMethodComponent implements } return this } - + public attributeModifier(modifier: AttributeModifier | AttributeModifier | undefined): this { + hookSymbolSpanAttributeModifier(this, modifier); + return this + } public applyAttributesFinish(): void { // we call this function outside of class, so need to make it public super.applyAttributesFinish() diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/AttributeModifierOpsHandWritten.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/AttributeModifierOpsHandWritten.ts index 36732bc2f76..6c156345991 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/AttributeModifierOpsHandWritten.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/AttributeModifierOpsHandWritten.ts @@ -36,10 +36,18 @@ import { ArkTextAreaComponent, TextAreaAttribute, ArkTextAreaPeer, TextAreaOptio import { ArkMarqueeComponent, MarqueeAttribute, ArkMarqueePeer, MarqueeOptions } from '../component/marquee'; import { ArkHyperlinkComponent, HyperlinkAttribute, ArkHyperlinkPeer } from '../component/hyperlink'; import { ArkRichEditorComponent, RichEditorAttribute, RichEditorOptions, RichEditorStyledStringOptions } from '../component/richEditor'; -import { applyAttributeModifierBase, applyCommonModifier } from "./modifiers/ArkCommonModifier"; +import { ArkSpanComponent, SpanAttribute, ArkSpanPeer } from '../component/span'; +import { ArkImageSpanComponent, ImageSpanAttribute, ArkImageSpanPeer } from '../component/imageSpan'; +import { ArkSymbolSpanComponent, SymbolSpanAttribute, ArkSymbolSpanPeer } from '../component/symbolSpan'; +import { ArkContainerSpanComponent, ContainerSpanAttribute, ArkContainerSpanPeer } from '../component/containerSpan'; +import { applyAttributeModifierBase, applyCommonModifier, applyAttributeModifierNoCommonMethod } from "./modifiers/ArkCommonModifier"; import { CommonModifier } from '../CommonModifier'; import { ButtonModifier } from "../ButtonModifier"; import { TextModifier } from '../TextModifier'; +import { SpanModifier } from '../SpanModifier'; +import { ImageSpanModifier } from '../ImageSpanModifier'; +import { SymbolSpanModifier } from '../SymbolSpanModifier'; +import { ContainerSpanModifier } from '../ContainerSpanModifier'; import { BlankModifier } from '../BlankModifier'; import { ColumnModifier } from '../ColumnModifier'; import { ColumnSplitModifier } from '../ColumnSplitModifier'; @@ -62,6 +70,8 @@ import { HyperlinkModifier } from '../HyperlinkModifier'; import { RichEditorModifier } from '../RichEditorModifier'; import { Resource } from 'global.resource'; import { runtimeType, RuntimeType } from '@koalaui/interop'; +import { ResourceStr } from "../component/units" +import { PixelMap } from "#external" import { ArkGridComponent, GridAttribute } from '../component/grid'; import { GridModifier } from '../GridModifier'; import { ArkGridItemComponent, GridItemAttribute } from '../component/gridItem'; @@ -112,6 +122,148 @@ export function hookButtonAttributeModifier(component: ArkButtonComponent, modif applyAttributeModifierBase(modifier as Object as AttributeModifier, attributeSet, constructParam, updaterReceiver, component.getPeer()); } +export function hookSpanAttributeModifier(component: ArkSpanComponent, modifier: AttributeModifier | AttributeModifier | undefined): void { + if (modifier === undefined) { + return ; + } + let isCommonModifier: boolean = modifier instanceof CommonModifier; + if (isCommonModifier) { + applyCommonModifier(component.getPeer(), modifier as Object as AttributeModifier); + return ; + } + let attributeSet = (): SpanModifier => { + let isSpanModifier: boolean = modifier instanceof SpanModifier; + let initModifier = component.getPeer()._attributeSet ? component.getPeer()._attributeSet! : new SpanModifier(); + if (isSpanModifier) { + let spanModifier = modifier as object as SpanModifier; + initModifier.mergeModifier(spanModifier); + component.getPeer()._attributeSet = initModifier; + return initModifier; + } else { + component.getPeer()._attributeSet = initModifier; + return initModifier; + } + } + let constructParam = (component: ArkCommonMethodComponent, ...params: FixedArray): void => { + if (params.length !== 1) { + throw new Error('must only 1 parameter') + } + let content_casted: string | Resource = params[0] as (string | Resource) + let spanPeer: ArkSpanPeer = component.getPeer() as Object as ArkSpanPeer; + spanPeer.setSpanOptionsAttribute(content_casted) + }; + let updaterReceiver = (): ArkSpanComponent => { + let initComponent: ArkSpanComponent = new ArkSpanComponent(); + initComponent.setPeer(component.getPeer()); + return initComponent; + }; + applyAttributeModifierBase(modifier as Object as AttributeModifier, attributeSet, constructParam, updaterReceiver, component.getPeer(), false); +} + +export function hookImageSpanAttributeModifier(component: ArkImageSpanComponent, modifier: AttributeModifier | AttributeModifier | undefined): void { + if (modifier === undefined) { + return ; + } + let isCommonModifier: boolean = modifier instanceof CommonModifier; + if (isCommonModifier) { + applyCommonModifier(component.getPeer(), modifier as Object as AttributeModifier); + return ; + } + let attributeSet = (): ImageSpanModifier => { + let isImageSpanModifier: boolean = modifier instanceof ImageSpanModifier; + let initModifier = component.getPeer()._attributeSet ? component.getPeer()._attributeSet! : new ImageSpanModifier(); + if (isImageSpanModifier) { + let imageSpanModifier = modifier as object as ImageSpanModifier; + initModifier.mergeModifier(imageSpanModifier); + component.getPeer()._attributeSet = initModifier; + return initModifier; + } else { + component.getPeer()._attributeSet = initModifier; + return initModifier; + } + } + let constructParam = (component: ArkCommonMethodComponent, ...params: FixedArray): void => { + if (params.length !== 1) { + throw new Error('must only 1 parameter') + } + let content_casted: ResourceStr | PixelMap = params[0] as ResourceStr | PixelMap + let imageSpanPeer: ArkImageSpanPeer = component.getPeer() as Object as ArkImageSpanPeer; + imageSpanPeer.setImageSpanOptionsAttribute(content_casted) + }; + let updaterReceiver = (): ArkImageSpanComponent => { + let initComponent: ArkImageSpanComponent = new ArkImageSpanComponent(); + initComponent.setPeer(component.getPeer()); + return initComponent; + }; + applyAttributeModifierBase(modifier as Object as AttributeModifier, attributeSet, constructParam, updaterReceiver, component.getPeer()); +} + +export function hookSymbolSpanAttributeModifier(component: ArkSymbolSpanComponent, modifier: AttributeModifier | AttributeModifier | undefined): void { + if (modifier === undefined) { + return ; + } + let isCommonModifier: boolean = modifier instanceof CommonModifier; + if (isCommonModifier) { + applyCommonModifier(component.getPeer(), modifier as Object as AttributeModifier); + return ; + } + let attributeSet = (): SymbolSpanModifier => { + let isSymbolSpanModifier: boolean = modifier instanceof SymbolSpanModifier; + let initModifier = component.getPeer()._attributeSet ? component.getPeer()._attributeSet! : new SymbolSpanModifier(); + if (isSymbolSpanModifier) { + let symbolSpanModifier = modifier as object as SymbolSpanModifier; + initModifier.mergeModifier(symbolSpanModifier); + component.getPeer()._attributeSet = initModifier; + return initModifier; + } else { + component.getPeer()._attributeSet = initModifier; + return initModifier; + } + } + let constructParam = (component: ArkCommonMethodComponent, ...params: FixedArray): void => { + if (params.length !== 1) { + throw new Error('must only 1 parameter') + } + let content_casted: Resource = params[0] as Resource + let symbolSpanPeer: ArkSymbolSpanPeer = component.getPeer() as Object as ArkSymbolSpanPeer; + symbolSpanPeer.setSymbolSpanOptionsAttribute(content_casted) + }; + let updaterReceiver = (): ArkSymbolSpanComponent => { + let initComponent: ArkSymbolSpanComponent = new ArkSymbolSpanComponent(); + initComponent.setPeer(component.getPeer()); + return initComponent; + }; + applyAttributeModifierBase(modifier as Object as AttributeModifier, attributeSet, constructParam, updaterReceiver, component.getPeer(), false); +} + +export function hookContainerSpanAttributeModifier(component: ArkContainerSpanComponent, modifier: AttributeModifier | AttributeModifier | undefined): void { + if (modifier === undefined) { + return ; + } + let attributeSet = (): ContainerSpanModifier => { + let isContainerSpanModifier: boolean = modifier instanceof ContainerSpanModifier; + let initModifier = component.getPeer()._attributeSet ? component.getPeer()._attributeSet! : new ContainerSpanModifier(); + if (isContainerSpanModifier) { + let containerSpanModifier = modifier as object as ContainerSpanModifier; + initModifier.mergeModifier(containerSpanModifier); + component.getPeer()._attributeSet = initModifier; + return initModifier; + } else { + component.getPeer()._attributeSet = initModifier; + return initModifier; + } + } + let constructParam = (component: ArkContainerSpanComponent, ...params: FixedArray): void => { + }; + let updaterReceiver = (): ArkContainerSpanComponent => { + let initComponent: ArkContainerSpanComponent = new ArkContainerSpanComponent(); + initComponent.setPeer(component.getPeer()); + return initComponent; + }; + let attributeSet_ = applyAttributeModifierNoCommonMethod(modifier as Object as AttributeModifier, attributeSet, constructParam, updaterReceiver, component.getPeer(), false); + attributeSet_!.applyModifierPatch(component.getPeer()); +} + export function hookTextAttributeModifier(component: ArkTextComponent, modifier: AttributeModifier | AttributeModifier | undefined): void { if (modifier === undefined) { return ; diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/modifiers/ArkCommonModifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/modifiers/ArkCommonModifier.ts index d51d23d887e..9e96e0081a5 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/modifiers/ArkCommonModifier.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/modifiers/ArkCommonModifier.ts @@ -34,6 +34,8 @@ import { int32} from "@koalaui/common" import { PeerNode } from '../../PeerNode'; import { InteropNativeModule } from '@koalaui/interop'; import { CommonMethodModifier } from '../../CommonMethodModifier'; +import { ComponentBase } from '../../ComponentBase'; + export enum ModifierType { ORIGIN = 0, STATE = 1, @@ -106,7 +108,7 @@ const UI_STATE_FOCUSED = 1 << 1; const UI_STATE_DISABLED = 1 << 2; const UI_STATE_SELECTED = 1 << 3; -export function applyUIAttributes(modifier: AttributeModifier, attributeSet: CommonMethodModifier, state: int32 = 0): void { +export function applyUIAttributes(modifier: AttributeModifier, attributeSet: MethodSet, state: int32 = 0): void { modifier.applyNormalAttribute(attributeSet as T); if (state & UI_STATE_PRESSED) { modifier.applyPressedAttribute(attributeSet as T); @@ -122,7 +124,7 @@ export function applyUIAttributes(modifier: AttributeModifier, attributeSe } } -export function applyUIAttributesUpdate(modifier: AttributeModifier, attributeSet: CommonMethodModifier, state: int32 = 0, isInit:boolean = true): void { +export function applyUIAttributesUpdate(modifier: AttributeModifier, attributeSet: MethodSet, state: int32 = 0, isInit:boolean = true): void { if (state == UI_STATE_NORMAL && !isInit) { modifier.applyNormalAttribute(attributeSet as T); } @@ -2009,8 +2011,9 @@ export class ArkCommonAttributeSet implements CommonAttribute { } } -export function applyAttributeModifierBase - (modifier: AttributeModifier, attributeSet: () => MethodSet, func: (component: MethodComponent, ...params: FixedArray) => void, updaterReceiver: () => MethodComponent, node: ArkCommonMethodPeer): void { +export function applyAttributeModifierNoCommonMethod + (modifier: AttributeModifier, attributeSet: () => MethodSet, func: (component: MethodComponent, ...params: FixedArray) => void, updaterReceiver: () => MethodComponent, node: PeerNode, + isStateStyle: boolean = true): MethodSet { let attributeSet_ = attributeSet(); let isAttributeUpdater: boolean = (modifier instanceof AttributeUpdater); if (isAttributeUpdater) { @@ -2036,18 +2039,32 @@ export function applyAttributeModifierBase + (modifier: AttributeModifier, attributeSet: () => MethodSet, func: (component: MethodComponent, ...params: FixedArray) => void, updaterReceiver: () => MethodComponent, node: ArkCommonMethodPeer, + isStateStyle: boolean = true): void { + let attributeSet_ = applyAttributeModifierNoCommonMethod(modifier, attributeSet, func, updaterReceiver, node, isStateStyle) as CommonMethodModifier; + attributeSet_!.applyModifierPatch(node); } export function applyCommonModifier(peerNode: ArkCommonMethodPeer, modifier: AttributeModifier) { diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ohos.arkui.modifier.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ohos.arkui.modifier.ts index bdf2f8b36e6..5035224a081 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ohos.arkui.modifier.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ohos.arkui.modifier.ts @@ -21,6 +21,14 @@ export { TabsModifier } from './TabsModifier'; export { TabContentModifier } from './TabContentModifier'; +export { SpanModifier } from './SpanModifier'; + +export { ContainerSpanModifier } from './ContainerSpanModifier'; + +export { ImageSpanModifier } from './ImageSpanModifier'; + +export { SymbolSpanModifier } from './SymbolSpanModifier'; + export { CommonModifier } from './CommonModifier' export { DividerModifier } from './DividerModifier'; -- Gitee