1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/// <reference path='./import.ts' /> 17interface XComponentParam { 18 id: string; 19 type: string | XComponentType; 20 imageAIOptions: ImageAIOptions; 21 libraryname?: string; 22 controller?: XComponentController; 23} 24class ArkXComponentComponent extends ArkComponent implements XComponentAttribute { 25 _modifiersWithKeys: Map<Symbol, AttributeModifierWithKey>; 26 nativePtr: KNode; 27 28 constructor(nativePtr: KNode, classType?: ModifierType) { 29 super(nativePtr, classType); 30 } 31 allowChildCount(): number { 32 return 0; 33 } 34 applyModifierPatch(): void { 35 let expiringItemsWithKeys = []; 36 this._modifiersWithKeys.forEach((value, key) => { 37 if (value.applyStage(this.nativePtr)) { 38 expiringItemsWithKeys.push(key); 39 } 40 }); 41 expiringItemsWithKeys.forEach(key => { 42 this._modifiersWithKeys.delete(key); 43 }); 44 } 45 initialize(value: Object[]): this { 46 if (value[0]) { 47 modifierWithKey(this._modifiersWithKeys, XComponentInitializeModifier.identity, 48 XComponentInitializeModifier, value[0] as XComponentParam); 49 } 50 return this; 51 } 52 outline(value: OutlineOptions): this { 53 throw new Error('Method not implemented.'); 54 } 55 outlineColor(value: ResourceColor | EdgeColors): this { 56 throw new Error('Method not implemented.'); 57 } 58 outlineRadius(value: Dimension | OutlineRadiuses): this { 59 throw new Error('Method not implemented.'); 60 } 61 outlineStyle(value: OutlineStyle | EdgeOutlineStyles): this { 62 throw new Error('Method not implemented.'); 63 } 64 outlineWidth(value: Dimension | EdgeOutlineWidths): this { 65 throw new Error('Method not implemented.'); 66 } 67 expandSafeArea(types?: SafeAreaType[], edges?: SafeAreaEdge[]): this { 68 throw new Error('Method not implemented.'); 69 } 70 responseRegion(value: Rectangle | Rectangle[]): this { 71 throw new Error('Method not implemented.'); 72 } 73 mouseResponseRegion(value: Rectangle | Rectangle[]): this { 74 throw new Error('Method not implemented.'); 75 } 76 size(value: SizeOptions): this { 77 throw new Error('Method not implemented.'); 78 } 79 constraintSize(value: ConstraintSizeOptions): this { 80 throw new Error('Method not implemented.'); 81 } 82 touchable(value: boolean): this { 83 throw new Error('Method not implemented.'); 84 } 85 hitTestBehavior(value: HitTestMode): this { 86 throw new Error('Method not implemented.'); 87 } 88 layoutWeight(value: string | number): this { 89 throw new Error('Method not implemented.'); 90 } 91 padding(value: Length | Padding): this { 92 throw new Error('Method not implemented.'); 93 } 94 margin(value: Length | Padding): this { 95 throw new Error('Method not implemented.'); 96 } 97 background(builder: CustomBuilder, options?: { align?: Alignment; }): this { 98 throw new Error('Method not implemented.'); 99 } 100 backgroundColor(value: ResourceColor): this { 101 modifierWithKey(this._modifiersWithKeys, XComponentBackgroundColorModifier.identity, 102 XComponentBackgroundColorModifier, value); 103 return this; 104 } 105 backgroundImage(src: ResourceStr, repeat?: ImageRepeat): this { 106 let arkBackgroundImage = new ArkBackgroundImage(); 107 arkBackgroundImage.src = src; 108 arkBackgroundImage.repeat = repeat; 109 modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImageModifier.identity, XComponentBackgroundImageModifier, arkBackgroundImage); 110 return this; 111 } 112 backgroundImageSize(value: SizeOptions | ImageSize): this { 113 modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImageSizeModifier.identity, XComponentBackgroundImageSizeModifier, value); 114 return this; 115 } 116 backgroundImagePosition(value: Alignment | Position): this { 117 modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImagePositionModifier.identity, XComponentBackgroundImagePositionModifier, value); 118 return this; 119 } 120 backgroundBlurStyle(value: BlurStyle, options?: BackgroundBlurStyleOptions): this { 121 throw new Error('Method not implemented.'); 122 } 123 foregroundBlurStyle(value: BlurStyle, options?: ForegroundBlurStyleOptions): this { 124 throw new Error('Method not implemented.'); 125 } 126 opacity(value: number | Resource): this { 127 modifierWithKey(this._modifiersWithKeys, XComponentOpacityModifier.identity, XComponentOpacityModifier, value); 128 return this; 129 } 130 border(value: BorderOptions): this { 131 throw new Error('Method not implemented.'); 132 } 133 borderStyle(value: BorderStyle | EdgeStyles): this { 134 throw new Error('Method not implemented.'); 135 } 136 borderWidth(value: Length | EdgeWidths): this { 137 throw new Error('Method not implemented.'); 138 } 139 borderColor(value: ResourceColor | EdgeColors): this { 140 throw new Error('Method not implemented.'); 141 } 142 borderRadius(value: Length | BorderRadiuses): this { 143 throw new Error('Method not implemented.'); 144 } 145 borderImage(value: BorderImageOption): this { 146 throw new Error('Method not implemented.'); 147 } 148 foregroundColor(value: string | number | Resource | Color): this { 149 throw new Error('Method not implemented.'); 150 } 151 onClick(event: (event: ClickEvent) => void): this { 152 throw new Error('Method not implemented.'); 153 } 154 onHover(event: (isHover: boolean, event: HoverEvent) => void): this { 155 throw new Error('Method not implemented.'); 156 } 157 hoverEffect(value: HoverEffect): this { 158 throw new Error('Method not implemented.'); 159 } 160 onMouse(event: (event: MouseEvent) => void): this { 161 throw new Error('Method not implemented.'); 162 } 163 onTouch(event: (event: TouchEvent) => void): this { 164 throw new Error('Method not implemented.'); 165 } 166 onKeyEvent(event: (event: KeyEvent) => void): this { 167 throw new Error('Method not implemented.'); 168 } 169 focusable(value: boolean): this { 170 throw new Error('Method not implemented.'); 171 } 172 onFocus(event: () => void): this { 173 throw new Error('Method not implemented.'); 174 } 175 onBlur(event: () => void): this { 176 throw new Error('Method not implemented.'); 177 } 178 tabIndex(index: number): this { 179 throw new Error('Method not implemented.'); 180 } 181 defaultFocus(value: boolean): this { 182 throw new Error('Method not implemented.'); 183 } 184 groupDefaultFocus(value: boolean): this { 185 throw new Error('Method not implemented.'); 186 } 187 focusOnTouch(value: boolean): this { 188 throw new Error('Method not implemented.'); 189 } 190 animation(value: AnimateParam): this { 191 throw new Error('Method not implemented.'); 192 } 193 transition(value: TransitionOptions | TransitionEffect): this { 194 throw new Error('Method not implemented.'); 195 } 196 gesture(gesture: GestureType, mask?: GestureMask): this { 197 throw new Error('Method not implemented.'); 198 } 199 priorityGesture(gesture: GestureType, mask?: GestureMask): this { 200 throw new Error('Method not implemented.'); 201 } 202 parallelGesture(gesture: GestureType, mask?: GestureMask): this { 203 throw new Error('Method not implemented.'); 204 } 205 blur(value: number): this { 206 modifierWithKey(this._modifiersWithKeys, XComponentBlurModifier.identity, XComponentBlurModifier, value); 207 return this; 208 } 209 linearGradientBlur(value: number, options: LinearGradientBlurOptions): this { 210 if (isUndefined(value) || isNull(value) || isUndefined(options) || isNull(options)) { 211 modifierWithKey(this._modifiersWithKeys, XComponentLinearGradientBlurModifier.identity, XComponentLinearGradientBlurModifier, 212 undefined); 213 return this; 214 } 215 let arkLinearGradientBlur = new ArkLinearGradientBlur(); 216 arkLinearGradientBlur.blurRadius = value; 217 arkLinearGradientBlur.fractionStops = options.fractionStops; 218 arkLinearGradientBlur.direction = options.direction; 219 modifierWithKey(this._modifiersWithKeys, XComponentLinearGradientBlurModifier.identity, XComponentLinearGradientBlurModifier, 220 arkLinearGradientBlur); 221 return this; 222 } 223 brightness(value: number): this { 224 modifierWithKey(this._modifiersWithKeys, XComponentBrightnessModifier.identity, XComponentBrightnessModifier, value); 225 return this; 226 } 227 contrast(value: number): this { 228 modifierWithKey(this._modifiersWithKeys, XComponentContrastModifier.identity, XComponentContrastModifier, value); 229 return this; 230 } 231 grayscale(value: number): this { 232 modifierWithKey(this._modifiersWithKeys, XComponentGrayscaleModifier.identity, XComponentGrayscaleModifier, value); 233 return this; 234 } 235 colorBlend(value: string | Resource | Color): this { 236 modifierWithKey(this._modifiersWithKeys, XComponentColorBlendModifier.identity, XComponentColorBlendModifier, value); 237 return this; 238 } 239 saturate(value: number): this { 240 modifierWithKey(this._modifiersWithKeys, XComponentSaturateModifier.identity, XComponentSaturateModifier, value); 241 return this; 242 } 243 sepia(value: number): this { 244 modifierWithKey(this._modifiersWithKeys, XComponentSepiaModifier.identity, XComponentSepiaModifier, value); 245 return this; 246 } 247 invert(value: number): this { 248 modifierWithKey(this._modifiersWithKeys, XComponentInvertModifier.identity, XComponentInvertModifier, value); 249 return this; 250 } 251 hueRotate(value: string | number): this { 252 modifierWithKey(this._modifiersWithKeys, XComponentHueRotateModifier.identity, XComponentHueRotateModifier, value); 253 return this; 254 } 255 useEffect(value: boolean): this { 256 throw new Error('Method not implemented.'); 257 } 258 backdropBlur(value: number): this { 259 modifierWithKey(this._modifiersWithKeys, XComponentBackdropBlurModifier.identity, XComponentBackdropBlurModifier, value); 260 return this; 261 } 262 renderGroup(value: boolean): this { 263 throw new Error('Method not implemented.'); 264 } 265 translate(value: TranslateOptions): this { 266 throw new Error('Method not implemented.'); 267 } 268 scale(value: ScaleOptions): this { 269 throw new Error('Method not implemented.'); 270 } 271 gridSpan(value: number): this { 272 throw new Error('Method not implemented.'); 273 } 274 gridOffset(value: number): this { 275 throw new Error('Method not implemented.'); 276 } 277 rotate(value: RotateOptions): this { 278 throw new Error('Method not implemented.'); 279 } 280 transform(value: object): this { 281 throw new Error('Method not implemented.'); 282 } 283 onAppear(event: () => void): this { 284 throw new Error('Method not implemented.'); 285 } 286 onDisAppear(event: () => void): this { 287 throw new Error('Method not implemented.'); 288 } 289 onAttach(event: () => void): this { 290 throw new Error('Method not implemented.'); 291 } 292 onDetach(event: () => void): this { 293 throw new Error('Method not implemented.'); 294 } 295 onAreaChange(event: (oldValue: Area, newValue: Area) => void): this { 296 throw new Error('Method not implemented.'); 297 } 298 visibility(value: Visibility): this { 299 throw new Error('Method not implemented.'); 300 } 301 flexGrow(value: number): this { 302 throw new Error('Method not implemented.'); 303 } 304 flexShrink(value: number): this { 305 throw new Error('Method not implemented.'); 306 } 307 flexBasis(value: string | number): this { 308 throw new Error('Method not implemented.'); 309 } 310 alignSelf(value: ItemAlign): this { 311 throw new Error('Method not implemented.'); 312 } 313 displayPriority(value: number): this { 314 throw new Error('Method not implemented.'); 315 } 316 zIndex(value: number): this { 317 throw new Error('Method not implemented.'); 318 } 319 sharedTransition(id: string, options?: sharedTransitionOptions): this { 320 throw new Error('Method not implemented.'); 321 } 322 direction(value: Direction): this { 323 throw new Error('Method not implemented.'); 324 } 325 align(value: Alignment): this { 326 throw new Error('Method not implemented.'); 327 } 328 position(value: Position): this { 329 throw new Error('Method not implemented.'); 330 } 331 markAnchor(value: Position): this { 332 throw new Error('Method not implemented.'); 333 } 334 offset(value: Position): this { 335 throw new Error('Method not implemented.'); 336 } 337 enabled(value: boolean): this { 338 throw new Error('Method not implemented.'); 339 } 340 useSizeType(value: { 341 xs?: number | { span: number; offset: number }; 342 sm?: number | { span: number; offset: number }; 343 md?: number | { span: number; offset: number }; 344 lg?: number | { span: number; offset: number }; 345 }): this { 346 throw new Error('Method not implemented.'); 347 } 348 alignRules(value: AlignRuleOption): this { 349 throw new Error('Method not implemented.'); 350 } 351 aspectRatio(value: number): this { 352 throw new Error('Method not implemented.'); 353 } 354 clickEffect(value: ClickEffect): this { 355 throw new Error('Method not implemented.'); 356 } 357 onDragStart(event: (event: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo): this { 358 throw new Error('Method not implemented.'); 359 } 360 onDragEnter(event: (event: DragEvent, extraParams?: string) => void): this { 361 throw new Error('Method not implemented.'); 362 } 363 onDragMove(event: (event: DragEvent, extraParams?: string) => void): this { 364 throw new Error('Method not implemented.'); 365 } 366 onDragLeave(event: (event: DragEvent, extraParams?: string) => void): this { 367 throw new Error('Method not implemented.'); 368 } 369 onDrop(event: (event: DragEvent, extraParams?: string) => void): this { 370 throw new Error('Method not implemented.'); 371 } 372 onDragEnd(event: (event: DragEvent, extraParams?: string) => void): this { 373 throw new Error('Method not implemented.'); 374 } 375 allowDrop(value: Array<UniformDataType>): this { 376 throw new Error('Method not implemented.'); 377 } 378 draggable(value: boolean): this { 379 throw new Error('Method not implemented.'); 380 } 381 overlay(value: string | CustomBuilder, options?: { align?: Alignment; offset?: { x?: number; y?: number; }; }): this { 382 throw new Error('Method not implemented.'); 383 } 384 linearGradient(value: { 385 angle?: number | string; 386 direction?: GradientDirection; 387 colors: Array<any>; 388 repeating?: boolean; 389 }): this { 390 throw new Error('Method not implemented.'); 391 } 392 sweepGradient(value: { 393 center: Array<any>; 394 start?: number | string; 395 end?: number | string; 396 rotation?: number | string; 397 colors: Array<any>; 398 repeating?: boolean; 399 }): this { 400 throw new Error('Method not implemented.'); 401 } 402 radialGradient(value: { center: Array<any>; radius: number | string; colors: Array<any>; repeating?: boolean }): this { 403 throw new Error('Method not implemented.'); 404 } 405 motionPath(value: MotionPathOptions): this { 406 throw new Error('Method not implemented.'); 407 } 408 shadow(value: ShadowOptions | ShadowStyle): this { 409 modifierWithKey(this._modifiersWithKeys, ShadowModifier.identity, ShadowModifier, value); 410 return this; 411 } 412 blendMode(value: BlendMode): this { 413 throw new Error('Method not implemented.'); 414 } 415 clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this { 416 throw new Error('Method not implemented.'); 417 } 418 mask(value: CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute | ProgressMask): this { 419 throw new Error('Method not implemented.'); 420 } 421 key(value: string): this { 422 throw new Error('Method not implemented.'); 423 } 424 id(value: string): this { 425 throw new Error('Method not implemented.'); 426 } 427 geometryTransition(id: string): this { 428 throw new Error('Method not implemented.'); 429 } 430 bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): this { 431 throw new Error('Method not implemented.'); 432 } 433 bindMenu(content: CustomBuilder | MenuElement[], options?: MenuOptions): this { 434 throw new Error('Method not implemented.'); 435 } 436 bindContextMenu(content: CustomBuilder, responseType: ResponseType, options?: ContextMenuOptions): this { 437 throw new Error('Method not implemented.'); 438 } 439 bindContentCover(isShow: unknown, builder: unknown, options?: unknown): this { 440 throw new Error('Method not implemented.'); 441 } 442 bindSheet(isShow: boolean, builder: CustomBuilder, options?: SheetOptions): this { 443 throw new Error('Method not implemented.'); 444 } 445 stateStyles(value: StateStyles): this { 446 throw new Error('Method not implemented.'); 447 } 448 restoreId(value: number): this { 449 throw new Error('Method not implemented.'); 450 } 451 onVisibleAreaChange(ratios: number[], event: (isVisible: boolean, currentRatio: number) => void): this { 452 throw new Error('Method not implemented.'); 453 } 454 sphericalEffect(value: number): this { 455 modifierWithKey(this._modifiersWithKeys, XComponentSphericalEffectModifier.identity, XComponentSphericalEffectModifier, value); 456 return this; 457 } 458 lightUpEffect(value: number): this { 459 modifierWithKey(this._modifiersWithKeys, XComponentLightUpEffectModifier.identity, XComponentLightUpEffectModifier, value); 460 return this; 461 } 462 pixelStretchEffect(options: PixelStretchEffectOptions): this { 463 modifierWithKey(this._modifiersWithKeys, XComponentPixelStretchEffectModifier.identity, XComponentPixelStretchEffectModifier, options); 464 return this; 465 } 466 keyboardShortcut(value: string | FunctionKey, keys: ModifierKey[], action?: () => void): this { 467 throw new Error('Method not implemented.'); 468 } 469 accessibilityGroup(value: boolean): this { 470 throw new Error('Method not implemented.'); 471 } 472 accessibilityText(value: string): this { 473 throw new Error('Method not implemented.'); 474 } 475 accessibilityDescription(value: string): this { 476 throw new Error('Method not implemented.'); 477 } 478 accessibilityLevel(value: string): this { 479 throw new Error('Method not implemented.'); 480 } 481 obscured(reasons: ObscuredReasons[]): this { 482 throw new Error('Method not implemented.'); 483 } 484 reuseId(id: string): this { 485 throw new Error('Method not implemented.'); 486 } 487 renderFit(fitMode: RenderFit): this { 488 throw new Error('Method not implemented.'); 489 } 490 attributeModifier(modifier: AttributeModifier<CommonAttribute>): this { 491 return this; 492 } 493 onGestureJudgeBegin(callback: (gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult): this { 494 throw new Error('Method not implemented.'); 495 } 496 onLoad(callback: (event?: object) => void): this { 497 modifierWithKey(this._modifiersWithKeys, XComponentOnLoadModifier.identity, XComponentOnLoadModifier, callback); 498 return this; 499 } 500 onDestroy(event: () => void): this { 501 modifierWithKey(this._modifiersWithKeys, XComponentOnDestroyModifier.identity, XComponentOnDestroyModifier, event); 502 return this; 503 } 504 enableAnalyzer(value: boolean): this { 505 modifierWithKey(this._modifiersWithKeys, XComponentEnableAnalyzerModifier.identity, XComponentEnableAnalyzerModifier, value); 506 return this; 507 } 508 enableSecure(value: boolean): this { 509 modifierWithKey(this._modifiersWithKeys, XComponentEnableSecureModifier.identity, XComponentEnableSecureModifier, value); 510 return this; 511 } 512} 513 514// @ts-ignore 515globalThis.XComponent.attributeModifier = function (modifier) { 516 const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); 517 let nativeNode = getUINativeModule().getFrameNodeById(elmtId); 518 let component = this.createOrGetNode(elmtId, () => { 519 return new ArkXComponentComponent(nativeNode); 520 }); 521 applyUIAttributes(modifier, nativeNode, component); 522 component.applyModifierPatch(); 523}; 524 525class XComponentInitializeModifier extends ModifierWithKey<XComponentParam> { 526 constructor(value: XComponentParam) { 527 super(value); 528 } 529 static identity: Symbol = Symbol('xComponentInitialize'); 530 applyPeer(node: KNode, reset: boolean): void { 531 if (reset) { 532 getUINativeModule().xComponent.resetXComponentInitialize(node); 533 } else { 534 getUINativeModule().xComponent.setXComponentInitialize(node, this.value?.id, 535 this.value?.type, this.value?.imageAIOptions, this.value?.libraryname, this.value?.controller); 536 } 537 } 538} 539 540class XComponentOpacityModifier extends ModifierWithKey<number | Resource> { 541 constructor(value: number | Resource) { 542 super(value); 543 } 544 static identity: Symbol = Symbol('xComponentOpacity'); 545 applyPeer(node: KNode, reset: boolean): void { 546 if (reset) { 547 getUINativeModule().xComponent.resetOpacity(node); 548 } else { 549 getUINativeModule().xComponent.setOpacity(node, this.value); 550 } 551 } 552 553 checkObjectDiff(): boolean { 554 return !isBaseOrResourceEqual(this.stageValue, this.value); 555 } 556} 557 558class XComponentBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 559 constructor(value: ResourceColor) { 560 super(value); 561 } 562 static identity: Symbol = Symbol('xComponentBackgroundColor'); 563 applyPeer(node: KNode, reset: boolean): void { 564 if (reset) { 565 getUINativeModule().xComponent.resetBackgroundColor(node); 566 } else { 567 getUINativeModule().xComponent.setBackgroundColor(node, this.value); 568 } 569 } 570 571 checkObjectDiff(): boolean { 572 return !isBaseOrResourceEqual(this.stageValue, this.value); 573 } 574} 575 576class XComponentBackgroundImageModifier extends ModifierWithKey<ArkBackgroundImage> { 577 constructor(value: ArkBackgroundImage) { 578 super(value); 579 } 580 static identity: Symbol = Symbol('xComponentBackgroundImage'); 581 applyPeer(node: KNode, reset: boolean): void { 582 if (reset) { 583 getUINativeModule().xComponent.resetBackgroundImage(node); 584 } else { 585 getUINativeModule().xComponent.setBackgroundImage(node, this.value.src, this.value.repeat); 586 } 587 } 588 589 checkObjectDiff(): boolean { 590 return !((this.stageValue as ArkBackgroundImage).src === (this.value as ArkBackgroundImage).src && 591 (this.stageValue as ArkBackgroundImage).repeat === (this.value as ArkBackgroundImage).repeat); 592 } 593} 594 595class XComponentBackgroundImageSizeModifier extends ModifierWithKey<SizeOptions | ImageSize> { 596 constructor(value: SizeOptions | ImageSize) { 597 super(value); 598 } 599 static identity: Symbol = Symbol('xComponentBackgroundImageSize'); 600 applyPeer(node: KNode, reset: boolean): void { 601 if (reset) { 602 getUINativeModule().xComponent.resetBackgroundImageSize(node); 603 } else { 604 if (isNumber(this.value)) { 605 getUINativeModule().xComponent.setBackgroundImageSize(node, this.value, undefined, undefined); 606 } else { 607 getUINativeModule().xComponent.setBackgroundImageSize(node, undefined, (this.value as SizeOptions)?.width, (this.value as SizeOptions)?.height); 608 } 609 } 610 } 611 checkObjectDiff(): boolean { 612 return !((this.value as SizeOptions).width === (this.stageValue as SizeOptions).width && 613 (this.value as SizeOptions).height === (this.stageValue as SizeOptions).height); 614 } 615} 616 617class XComponentBackgroundImagePositionModifier extends ModifierWithKey<Position | Alignment> { 618 constructor(value: Position | Alignment) { 619 super(value); 620 } 621 static identity: Symbol = Symbol('xComponentBackgroundImagePosition'); 622 applyPeer(node: KNode, reset: boolean): void { 623 if (reset) { 624 getUINativeModule().xComponent.resetBackgroundImagePosition(node); 625 } else { 626 if (isNumber(this.value)) { 627 getUINativeModule().xComponent.setBackgroundImagePosition(node, this.value, undefined, undefined); 628 } else { 629 getUINativeModule().xComponent.setBackgroundImagePosition(node, undefined, (this.value as Position)?.x, (this.value as Position)?.y); 630 } 631 } 632 } 633 checkObjectDiff(): boolean { 634 return !((this.value as Position)?.x === (this.stageValue as Position)?.x && 635 (this.value as Position)?.y === (this.stageValue as Position)?.y); 636 } 637} 638 639class XComponentBlurModifier extends ModifierWithKey<number> { 640 constructor(value: number) { 641 super(value); 642 } 643 static identity: Symbol = Symbol('xComponentBlur'); 644 applyPeer(node: KNode, reset: boolean): void { 645 if (reset) { 646 getUINativeModule().xComponent.resetBlur(node); 647 } else { 648 getUINativeModule().xComponent.setBlur(node, this.value); 649 } 650 } 651} 652 653class XComponentBackdropBlurModifier extends ModifierWithKey<number> { 654 constructor(value: number) { 655 super(value); 656 } 657 static identity: Symbol = Symbol('xComponentBackdropBlur'); 658 applyPeer(node: KNode, reset: boolean): void { 659 if (reset) { 660 getUINativeModule().xComponent.resetBackdropBlur(node); 661 } else { 662 getUINativeModule().xComponent.setBackdropBlur(node, this.value); 663 } 664 } 665} 666 667class XComponentGrayscaleModifier extends ModifierWithKey<number> { 668 constructor(value: number) { 669 super(value); 670 } 671 static identity: Symbol = Symbol('xComponentGrayscale'); 672 applyPeer(node: KNode, reset: boolean): void { 673 if (reset) { 674 getUINativeModule().xComponent.resetGrayscale(node); 675 } else { 676 getUINativeModule().xComponent.setGrayscale(node, this.value); 677 } 678 } 679} 680 681class XComponentBrightnessModifier extends ModifierWithKey<number> { 682 constructor(value: number) { 683 super(value); 684 } 685 static identity: Symbol = Symbol('xComponentBrightness'); 686 applyPeer(node: KNode, reset: boolean): void { 687 if (reset) { 688 getUINativeModule().xComponent.resetBrightness(node); 689 } else { 690 getUINativeModule().xComponent.setBrightness(node, this.value); 691 } 692 } 693} 694 695class XComponentSaturateModifier extends ModifierWithKey<number> { 696 constructor(value: number) { 697 super(value); 698 } 699 static identity: Symbol = Symbol('xComponentSaturate'); 700 applyPeer(node: KNode, reset: boolean): void { 701 if (reset) { 702 getUINativeModule().xComponent.resetSaturate(node); 703 } else { 704 getUINativeModule().xComponent.setSaturate(node, this.value); 705 } 706 } 707} 708 709class XComponentContrastModifier extends ModifierWithKey<number> { 710 constructor(value: number) { 711 super(value); 712 } 713 static identity: Symbol = Symbol('xComponentContrast'); 714 applyPeer(node: KNode, reset: boolean): void { 715 if (reset) { 716 getUINativeModule().xComponent.resetContrast(node); 717 } else { 718 getUINativeModule().xComponent.setContrast(node, this.value); 719 } 720 } 721} 722 723class XComponentInvertModifier extends ModifierWithKey<number> { 724 constructor(value: number) { 725 super(value); 726 } 727 static identity: Symbol = Symbol('xComponentInvert'); 728 applyPeer(node: KNode, reset: boolean): void { 729 if (reset) { 730 getUINativeModule().xComponent.resetInvert(node); 731 } else { 732 getUINativeModule().xComponent.setInvert(node, this.value); 733 } 734 } 735} 736 737class XComponentSepiaModifier extends ModifierWithKey<number> { 738 constructor(value: number) { 739 super(value); 740 } 741 static identity: Symbol = Symbol('xComponentSepia'); 742 applyPeer(node: KNode, reset: boolean): void { 743 if (reset) { 744 getUINativeModule().xComponent.resetSepia(node); 745 } else { 746 getUINativeModule().xComponent.setSepia(node, this.value); 747 } 748 } 749} 750 751class XComponentHueRotateModifier extends ModifierWithKey<number | string> { 752 constructor(value: number | string) { 753 super(value); 754 } 755 static identity: Symbol = Symbol('xComponentHueRotate'); 756 applyPeer(node: KNode, reset: boolean): void { 757 if (reset) { 758 getUINativeModule().xComponent.resetHueRotate(node); 759 } else { 760 getUINativeModule().xComponent.setHueRotate(node, this.value); 761 } 762 } 763} 764 765class XComponentColorBlendModifier extends ModifierWithKey<Color | string | Resource> { 766 constructor(value: Color | string | Resource) { 767 super(value); 768 } 769 static identity: Symbol = Symbol('xComponentColorBlend'); 770 applyPeer(node: KNode, reset: boolean): void { 771 if (reset) { 772 getUINativeModule().xComponent.resetColorBlend(node); 773 } else { 774 getUINativeModule().xComponent.setColorBlend(node, this.value); 775 } 776 } 777 778 checkObjectDiff(): boolean { 779 return !isBaseOrResourceEqual(this.stageValue, this.value); 780 } 781} 782 783class XComponentSphericalEffectModifier extends ModifierWithKey<number> { 784 constructor(value: number) { 785 super(value); 786 } 787 static identity: Symbol = Symbol('xComponentSphericalEffect'); 788 applyPeer(node: KNode, reset: boolean): void { 789 if (reset) { 790 getUINativeModule().xComponent.resetSphericalEffect(node); 791 } else { 792 getUINativeModule().xComponent.setSphericalEffect(node, this.value); 793 } 794 } 795} 796 797class XComponentLightUpEffectModifier extends ModifierWithKey<number> { 798 constructor(value: number) { 799 super(value); 800 } 801 static identity: Symbol = Symbol('xComponentLightUpEffect'); 802 applyPeer(node: KNode, reset: boolean): void { 803 if (reset) { 804 getUINativeModule().xComponent.resetLightUpEffect(node); 805 } else { 806 getUINativeModule().xComponent.setLightUpEffect(node, this.value); 807 } 808 } 809} 810 811class XComponentPixelStretchEffectModifier extends ModifierWithKey<PixelStretchEffectOptions> { 812 constructor(value: PixelStretchEffectOptions) { 813 super(value); 814 } 815 static identity: Symbol = Symbol('xComponentPixelStretchEffect'); 816 applyPeer(node: KNode, reset: boolean): void { 817 if (reset) { 818 getUINativeModule().xComponent.resetPixelStretchEffect(node); 819 } else { 820 getUINativeModule().xComponent.setPixelStretchEffect(node, 821 this.value.top, this.value.right, this.value.bottom, this.value.left); 822 } 823 } 824 825 checkObjectDiff(): boolean { 826 return !((this.stageValue as PixelStretchEffectOptions).left === (this.value as PixelStretchEffectOptions).left && 827 (this.stageValue as PixelStretchEffectOptions).right === (this.value as PixelStretchEffectOptions).right && 828 (this.stageValue as PixelStretchEffectOptions).top === (this.value as PixelStretchEffectOptions).top && 829 (this.stageValue as PixelStretchEffectOptions).bottom === (this.value as PixelStretchEffectOptions).bottom); 830 } 831} 832 833class XComponentLinearGradientBlurModifier extends ModifierWithKey<ArkLinearGradientBlur> { 834 constructor(value: ArkLinearGradientBlur) { 835 super(value); 836 } 837 static identity: Symbol = Symbol('xComponentlinearGradientBlur'); 838 applyPeer(node: KNode, reset: boolean): void { 839 if (reset) { 840 getUINativeModule().xComponent.resetLinearGradientBlur(node); 841 } else { 842 getUINativeModule().xComponent.setLinearGradientBlur(node, 843 this.value.blurRadius, this.value.fractionStops, this.value.direction); 844 } 845 } 846 checkObjectDiff(): boolean { 847 return !this.value.isEqual(this.stageValue); 848 } 849} 850 851class XComponentOnLoadModifier extends ModifierWithKey<(event?: object) => void> { 852 constructor(value: (event?: object) => void) { 853 super(value); 854 } 855 static identity: Symbol = Symbol('xComponentOnLoad'); 856 applyPeer(node: KNode, reset: boolean): void { 857 if (reset) { 858 getUINativeModule().xComponent.resetOnLoad(node); 859 } else { 860 getUINativeModule().xComponent.setOnLoad(node, this.value); 861 } 862 } 863} 864 865class XComponentOnDestroyModifier extends ModifierWithKey<() => void> { 866 constructor(value: () => void) { 867 super(value); 868 } 869 static identity: Symbol = Symbol('xComponentOnDestroy'); 870 applyPeer(node: KNode, reset: boolean): void { 871 if (reset) { 872 getUINativeModule().xComponent.resetOnDestroy(node); 873 } else { 874 getUINativeModule().xComponent.setOnDestroy(node, this.value); 875 } 876 } 877} 878 879class XComponentEnableAnalyzerModifier extends ModifierWithKey<boolean> { 880 constructor(value: boolean) { 881 super(value); 882 } 883 static identity: Symbol = Symbol('xComponentEnableAnalyzer'); 884 applyPeer(node: KNode, reset: boolean): void { 885 if (reset) { 886 getUINativeModule().xComponent.resetEnableAnalyzer(node); 887 } else { 888 getUINativeModule().xComponent.setEnableAnalyzer(node, this.value); 889 } 890 } 891 892 checkObjectDiff(): boolean { 893 return !isBaseOrResourceEqual(this.stageValue, this.value); 894 } 895} 896 897class XComponentEnableSecureModifier extends ModifierWithKey<boolean> { 898 constructor(value: boolean) { 899 super(value); 900 } 901 static identity: Symbol = Symbol('xComponentEnableSecure'); 902 applyPeer(node: KNode, reset: boolean): void { 903 if (reset) { 904 getUINativeModule().xComponent.resetEnableSecure(node); 905 } else { 906 getUINativeModule().xComponent.setEnableSecure(node, this.value); 907 } 908 } 909 910 checkObjectDiff(): boolean { 911 return !isBaseOrResourceEqual(this.stageValue, this.value); 912 } 913}