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' /> 17class ImageColorFilterModifier extends ModifierWithKey<ColorFilter | DrawingColorFilter> { 18 constructor(value: ColorFilter) { 19 super(value); 20 } 21 static identity: Symbol = Symbol('imageColorFilter'); 22 applyPeer(node: KNode, reset: boolean): void { 23 if (reset) { 24 getUINativeModule().image.resetColorFilter(node); 25 } else { 26 getUINativeModule().image.setColorFilter(node, this.value!); 27 } 28 } 29 checkObjectDiff(): boolean { 30 return true; 31 } 32} 33 34class ImageFillColorModifier extends ModifierWithKey<ResourceColor> { 35 constructor(value: ResourceColor) { 36 super(value); 37 } 38 static identity: Symbol = Symbol('imageFillColor'); 39 applyPeer(node: KNode, reset: boolean): void { 40 if (reset) { 41 getUINativeModule().image.resetFillColor(node); 42 } else { 43 getUINativeModule().image.setFillColor(node, this.value!); 44 } 45 } 46 checkObjectDiff(): boolean { 47 return !isBaseOrResourceEqual(this.stageValue, this.value); 48 } 49} 50 51class ImageAltModifier extends ModifierWithKey<ResourceStr> { 52 constructor(value: ResourceStr) { 53 super(value); 54 } 55 static identity: Symbol = Symbol('imageAlt'); 56 applyPeer(node: KNode, reset: boolean): void { 57 if (reset) { 58 getUINativeModule().image.resetAlt(node); 59 } else { 60 getUINativeModule().image.setAlt(node, this.value!); 61 } 62 } 63 checkObjectDiff(): boolean { 64 return !isBaseOrResourceEqual(this.stageValue, this.value); 65 } 66} 67 68class ImageCopyOptionModifier extends ModifierWithKey<CopyOptions> { 69 constructor(value: CopyOptions) { 70 super(value); 71 } 72 static identity: Symbol = Symbol('imageCopyOption'); 73 applyPeer(node: KNode, reset: boolean): void { 74 if (reset) { 75 getUINativeModule().image.resetCopyOption(node); 76 } else { 77 getUINativeModule().image.setCopyOption(node, this.value!); 78 } 79 } 80 checkObjectDiff(): boolean { 81 return this.stageValue !== this.value; 82 } 83} 84 85class ImageAutoResizeModifier extends ModifierWithKey<boolean> { 86 constructor(value: boolean) { 87 super(value); 88 } 89 static identity: Symbol = Symbol('imageAutoResize'); 90 applyPeer(node: KNode, reset: boolean): void { 91 if (reset) { 92 getUINativeModule().image.resetAutoResize(node); 93 } else { 94 getUINativeModule().image.setAutoResize(node, this.value!); 95 } 96 } 97 checkObjectDiff(): boolean { 98 return this.stageValue !== this.value; 99 } 100} 101 102class ImageFitOriginalSizeModifier extends ModifierWithKey<boolean> { 103 constructor(value: boolean) { 104 super(value); 105 } 106 static identity: Symbol = Symbol('imageFitOriginalSize'); 107 applyPeer(node: KNode, reset: boolean): void { 108 if (reset) { 109 getUINativeModule().image.resetFitOriginalSize(node); 110 } else { 111 getUINativeModule().image.setFitOriginalSize(node, this.value!); 112 } 113 } 114 checkObjectDiff(): boolean { 115 return this.stageValue !== this.value; 116 } 117} 118 119class ImageDraggableModifier extends ModifierWithKey<boolean> { 120 constructor(value: boolean) { 121 super(value); 122 } 123 static identity: Symbol = Symbol('imageDraggable'); 124 applyPeer(node: KNode, reset: boolean): void { 125 if (reset) { 126 getUINativeModule().image.resetDraggable(node); 127 } else { 128 getUINativeModule().image.setDraggable(node, this.value!); 129 } 130 } 131 checkObjectDiff(): boolean { 132 return this.stageValue !== this.value; 133 } 134} 135 136class ImageEdgeAntialiasingModifier extends ModifierWithKey<number> { 137 constructor(value: number) { 138 super(value); 139 } 140 static identity: Symbol = Symbol('edgeAntialiasing'); 141 applyPeer(node: KNode, reset: boolean): void { 142 if (reset) { 143 getUINativeModule().image.resetSourceSize(node); 144 } else { 145 getUINativeModule().image.setSourceSize(node, this.value); 146 } 147 } 148 checkObjectDiff(): boolean { 149 return this.stageValue !== this.value; 150 } 151} 152 153class ImageResizableModifier extends ModifierWithKey<ResizableOptions> { 154 constructor(value: ResizableOptions) { 155 super(value); 156 } 157 static identity: Symbol = Symbol('resizable'); 158 applyPeer(node: KNode, reset: boolean): void { 159 if (reset) { 160 getUINativeModule().image.resetResizable(node); 161 } else { 162 if (!isUndefined(this.value.lattice) && !isNull(this.value.lattice)) { 163 getUINativeModule().image.setResizableLattice(node, this.value.lattice); 164 } 165 if (!isUndefined(this.value.slice) && !isNull(this.value.slice)) { 166 let sliceTop: Length | undefined; 167 let sliceRight: Length | undefined; 168 let sliceBottom: Length | undefined; 169 let sliceLeft: Length | undefined; 170 let tmpSlice = this.value.slice as EdgeWidths; 171 sliceTop = tmpSlice.top; 172 sliceRight = tmpSlice.right; 173 sliceBottom = tmpSlice.bottom; 174 sliceLeft = tmpSlice.left; 175 getUINativeModule().image.setResizable(node, sliceTop, sliceRight, sliceBottom, sliceLeft); 176 } 177 } 178 } 179} 180 181class ImageDynamicRangeModeModifier extends ModifierWithKey<DynamicRangeMode> { 182 constructor(value: DynamicRangeMode) { 183 super(value); 184 } 185 static identity: Symbol = Symbol('dynamicRangeMode'); 186 applyPeer(node: KNode, reset: boolean): void { 187 if (reset) { 188 getUINativeModule().image.resetDynamicRangeMode(node); 189 } else { 190 getUINativeModule().image.setDynamicRangeMode(node, this.value!); 191 } 192 } 193 checkObjectDiff(): boolean { 194 return this.stageValue !== this.value; 195 } 196} 197 198class ImageEnhancedImageQualityModifier extends ModifierWithKey<AIImageQuality> { 199 constructor(value: ResolutionQuality) { 200 super(value); 201 } 202 static identity: Symbol = Symbol('enhancedImageQuality'); 203 applyPeer(node: KNode, reset: boolean): void { 204 if (reset) { 205 getUINativeModule().image.resetEnhancedImageQuality(node); 206 } else { 207 getUINativeModule().image.setEnhancedImageQuality(node, this.value!); 208 } 209 } 210 checkObjectDiff(): boolean { 211 return this.stageValue !== this.value; 212 } 213} 214 215class ImageInterpolationModifier extends ModifierWithKey<ImageInterpolation> { 216 constructor(value: ImageInterpolation) { 217 super(value); 218 } 219 static identity: Symbol = Symbol('imageInterpolation'); 220 applyPeer(node: KNode, reset: boolean): void { 221 if (reset) { 222 getUINativeModule().image.resetImageInterpolation(node); 223 } else { 224 getUINativeModule().image.setImageInterpolation(node, this.value!); 225 } 226 } 227 checkObjectDiff(): boolean { 228 return this.stageValue !== this.value; 229 } 230} 231 232class ImageSourceSizeModifier extends ModifierWithKey<{ width: number; height: number }> { 233 constructor(value: { width: number; height: number }) { 234 super(value); 235 } 236 static identity: Symbol = Symbol('imageSourceSize'); 237 applyPeer(node: KNode, reset: boolean): void { 238 if (reset) { 239 getUINativeModule().image.resetSourceSize(node); 240 } else { 241 getUINativeModule().image.setSourceSize(node, this.value.width, this.value.height); 242 } 243 } 244 checkObjectDiff(): boolean { 245 return this.stageValue.width !== this.value.width || 246 this.stageValue.height !== this.value.height; 247 } 248} 249 250class ImageMatchTextDirectionModifier extends ModifierWithKey<boolean> { 251 constructor(value: boolean) { 252 super(value); 253 } 254 static identity: Symbol = Symbol('imageMatchTextDirection'); 255 applyPeer(node: KNode, reset: boolean): void { 256 if (reset) { 257 getUINativeModule().image.resetMatchTextDirection(node); 258 } else { 259 getUINativeModule().image.setMatchTextDirection(node, this.value!); 260 } 261 } 262 checkObjectDiff(): boolean { 263 return this.stageValue !== this.value; 264 } 265} 266 267class ImageObjectRepeatModifier extends ModifierWithKey<ImageRepeat> { 268 constructor(value: ImageRepeat) { 269 super(value); 270 } 271 static identity: Symbol = Symbol('imageObjectRepeat'); 272 applyPeer(node: KNode, reset: boolean): void { 273 if (reset) { 274 getUINativeModule().image.resetObjectRepeat(node); 275 } else { 276 getUINativeModule().image.setObjectRepeat(node, this.value!); 277 } 278 } 279 checkObjectDiff(): boolean { 280 return this.stageValue !== this.value; 281 } 282} 283 284class ImageRenderModeModifier extends ModifierWithKey<ImageRenderMode> { 285 constructor(value: ImageRenderMode) { 286 super(value); 287 } 288 static identity: Symbol = Symbol('imageRenderMode'); 289 applyPeer(node: KNode, reset: boolean): void { 290 if (reset) { 291 getUINativeModule().image.resetRenderMode(node); 292 } else { 293 getUINativeModule().image.setRenderMode(node, this.value!); 294 } 295 } 296 checkObjectDiff(): boolean { 297 return this.stageValue !== this.value; 298 } 299} 300 301class ImageSyncLoadModifier extends ModifierWithKey<boolean> { 302 constructor(value: boolean) { 303 super(value); 304 } 305 static identity: Symbol = Symbol('imageSyncLoad'); 306 applyPeer(node: KNode, reset: boolean): void { 307 if (reset) { 308 getUINativeModule().image.resetSyncLoad(node); 309 } else { 310 getUINativeModule().image.setSyncLoad(node, this.value!); 311 } 312 } 313 checkObjectDiff(): boolean { 314 return this.stageValue !== this.value; 315 } 316} 317 318class ImageObjectFitModifier extends ModifierWithKey<ImageFit> { 319 constructor(value: ImageFit) { 320 super(value); 321 } 322 static identity: Symbol = Symbol('imageObjectFit'); 323 applyPeer(node: KNode, reset: boolean): void { 324 if (reset) { 325 getUINativeModule().image.resetObjectFit(node); 326 } else { 327 getUINativeModule().image.setObjectFit(node, this.value!); 328 } 329 } 330 checkObjectDiff(): boolean { 331 return this.stageValue !== this.value; 332 } 333} 334class ImageMatrixModifier extends ModifierWithKey<object> { 335 constructor(value: object) { 336 super(value); 337 } 338 static identity: Symbol = Symbol('imageMatrix'); 339 applyPeer(node: KNode, reset: boolean): void { 340 if (reset) { 341 getUINativeModule().image.resetImageMatrix(node); 342 } else { 343 getUINativeModule().image.setImageMatrix(node, (this.value as Matrix).matrix4x4); 344 } 345 } 346 checkObjectDiff(): boolean { 347 return !deepCompareArrays((this.stageValue as Matrix).matrix4x4, (this.value as Matrix).matrix4x4); 348 } 349} 350class ImageBorderRadiusModifier extends ModifierWithKey<Length | BorderRadiuses> { 351 constructor(value: Length | BorderRadiuses) { 352 super(value); 353 } 354 static identity: Symbol = Symbol('imageBorderRadius'); 355 applyPeer(node: KNode, reset: boolean): void { 356 if (reset) { 357 getUINativeModule().image.resetBorderRadius(node); 358 } else { 359 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 360 getUINativeModule().image.setBorderRadius(node, this.value, this.value, this.value, this.value); 361 } else { 362 let keys = Object.keys(this.value); 363 if (keys.indexOf('topStart') >= 0 || keys.indexOf('topEnd') >= 0 || 364 keys.indexOf('bottomStart') >= 0 || keys.indexOf('bottomEnd') >= 0) { 365 let localizedBorderRadius = this.value as LocalizedBorderRadiuses; 366 getUINativeModule().image.setBorderRadius(node, localizedBorderRadius.topStart, 367 localizedBorderRadius.topEnd, localizedBorderRadius.bottomStart, 368 localizedBorderRadius.bottomEnd); 369 } else { 370 let borderRadius = this.value as BorderRadiuses; 371 getUINativeModule().image.setBorderRadius(node, 372 borderRadius.topLeft, borderRadius.topRight, 373 borderRadius.bottomLeft, borderRadius.bottomRight); 374 } 375 } 376 } 377 } 378 379 checkObjectDiff(): boolean { 380 if (isResource(this.stageValue) && isResource(this.value)) { 381 return !isResourceEqual(this.stageValue, this.value); 382 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 383 return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft && 384 (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight && 385 (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft && 386 (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight); 387 } else { 388 return true; 389 } 390 } 391} 392class ImageBorderModifier extends ModifierWithKey<BorderOptions> { 393 constructor(value: BorderOptions) { 394 super(value); 395 } 396 static identity: Symbol = Symbol('imageBorder'); 397 applyPeer(node: KNode, reset: boolean): void { 398 if (reset) { 399 getUINativeModule().image.resetImageBorder(node); 400 } else { 401 let widthLeft; 402 let widthRight; 403 let widthTop; 404 let widthBottom; 405 if (!isUndefined(this.value.width) && this.value.width !== null) { 406 if (isNumber(this.value.width) || isString(this.value.width) || isResource(this.value.width)) { 407 widthLeft = this.value.width; 408 widthRight = this.value.width; 409 widthTop = this.value.width; 410 widthBottom = this.value.width; 411 } else { 412 widthLeft = (this.value.width as EdgeWidths).left; 413 widthRight = (this.value.width as EdgeWidths).right; 414 widthTop = (this.value.width as EdgeWidths).top; 415 widthBottom = (this.value.width as EdgeWidths).bottom; 416 } 417 } 418 let leftColor; 419 let rightColor; 420 let topColor; 421 let bottomColor; 422 if (!isUndefined(this.value.color) && this.value.color !== null) { 423 if (isNumber(this.value.color) || isString(this.value.color) || isResource(this.value.color)) { 424 leftColor = this.value.color; 425 rightColor = this.value.color; 426 topColor = this.value.color; 427 bottomColor = this.value.color; 428 } else { 429 leftColor = (this.value.color as EdgeColors).left; 430 rightColor = (this.value.color as EdgeColors).right; 431 topColor = (this.value.color as EdgeColors).top; 432 bottomColor = (this.value.color as EdgeColors).bottom; 433 } 434 } 435 let topLeft; 436 let topRight; 437 let bottomLeft; 438 let bottomRight; 439 if (!isUndefined(this.value.radius) && this.value.radius !== null) { 440 if (isNumber(this.value.radius) || isString(this.value.radius) || isResource(this.value.radius)) { 441 topLeft = this.value.radius; 442 topRight = this.value.radius; 443 bottomLeft = this.value.radius; 444 bottomRight = this.value.radius; 445 } else { 446 topLeft = (this.value.radius as BorderRadiuses).topLeft; 447 topRight = (this.value.radius as BorderRadiuses).topRight; 448 bottomLeft = (this.value.radius as BorderRadiuses).bottomLeft; 449 bottomRight = (this.value.radius as BorderRadiuses).bottomRight; 450 } 451 } 452 let styleTop; 453 let styleRight; 454 let styleBottom; 455 let styleLeft; 456 if (!isUndefined(this.value.style) && this.value.style != null) { 457 if (isNumber(this.value.style) || isString(this.value.style) || isResource(this.value.style)) { 458 styleTop = this.value.style; 459 styleRight = this.value.style; 460 styleBottom = this.value.style; 461 styleLeft = this.value.style; 462 } else { 463 styleTop = (this.value.style as EdgeStyles).top; 464 styleRight = (this.value.style as EdgeStyles).right; 465 styleBottom = (this.value.style as EdgeStyles).bottom; 466 styleLeft = (this.value.style as EdgeStyles).left; 467 } 468 } 469 getUINativeModule().image.setImageBorder( 470 node, 471 widthLeft, 472 widthRight, 473 widthTop, 474 widthBottom, 475 leftColor, 476 rightColor, 477 topColor, 478 bottomColor, 479 topLeft, 480 topRight, 481 bottomLeft, 482 bottomRight, 483 styleTop, 484 styleRight, 485 styleBottom, 486 styleLeft 487 ); 488 } 489 } 490 491 checkObjectDiff(): boolean { 492 return ( 493 !isBaseOrResourceEqual(this.stageValue.width, this.value.width) || 494 !isBaseOrResourceEqual(this.stageValue.color, this.value.color) || 495 !isBaseOrResourceEqual(this.stageValue.radius, this.value.radius) || 496 !isBaseOrResourceEqual(this.stageValue.style, this.value.style) 497 ); 498 } 499} 500 501class ImageOpacityModifier extends ModifierWithKey<number | Resource> { 502 constructor(value: number | Resource) { 503 super(value); 504 } 505 static identity: Symbol = Symbol('imageOpacity'); 506 applyPeer(node: KNode, reset: boolean): void { 507 if (reset) { 508 getUINativeModule().image.resetImageOpacity(node); 509 } else { 510 getUINativeModule().image.setImageOpacity(node, this.value); 511 } 512 } 513 514 checkObjectDiff(): boolean { 515 return !isBaseOrResourceEqual(this.stageValue, this.value); 516 } 517} 518 519class ImageTransitionModifier extends ModifierWithKey<object> { 520 constructor(value: object) { 521 super(value); 522 } 523 static identity: Symbol = Symbol('imageTransition'); 524 applyPeer(node: KNode, reset: boolean): void { 525 if (reset) { 526 getUINativeModule().image.resetImageTransition(node); 527 } else { 528 getUINativeModule().image.setImageTransition(node, this.value); 529 } 530 } 531} 532 533class ImageSrcModifier extends ModifierWithKey<ResourceStr | PixelMap | DrawableDescriptor | ImageContent> { 534 constructor(value: ResourceStr | PixelMap | DrawableDescriptor | ImageContent) { 535 super(value); 536 } 537 static identity: Symbol = Symbol('imageShowSrc'); 538 applyPeer(node: KNode, reset: boolean): void { 539 if (reset) { 540 getUINativeModule().image.setImageShowSrc(node, ""); 541 } 542 else { 543 getUINativeModule().image.setImageShowSrc(node, this.value); 544 } 545 } 546} 547 548class ImageEnableAnalyzerModifier extends ModifierWithKey<boolean> { 549 constructor(value: boolean) { 550 super(value); 551 } 552 static identity: Symbol = Symbol('enableAnalyzer'); 553 applyPeer(node: KNode, reset: boolean): void { 554 if (reset) { 555 getUINativeModule().image.enableAnalyzer(node); 556 } else { 557 getUINativeModule().image.enableAnalyzer(node, this.value!); 558 } 559 } 560} 561 562class ImagePrivacySensitiveModifier extends ModifierWithKey<boolean> { 563 constructor(value: boolean) { 564 super(value); 565 } 566 static identity: Symbol = Symbol('imagePrivacySensitive'); 567 applyPeer(node: KNode, reset: boolean): void { 568 if (reset) { 569 getUINativeModule().image.resetPrivacySensitive(node); 570 } else { 571 getUINativeModule().image.setPrivacySensitive(node, this.value!); 572 } 573 } 574 checkObjectDiff(): boolean { 575 return !isBaseOrResourceEqual(this.stageValue, this.value); 576 } 577} 578 579class ImageAnalyzerConfigModifier extends ModifierWithKey<object> { 580 constructor(value: object) { 581 super(value); 582 } 583 static identity: Symbol = Symbol('analyzerConfig'); 584 applyPeer(node: KNode, reset: boolean): void { 585 if (reset) { 586 getUINativeModule().image.analyzerConfig(node, ''); 587 } else { 588 getUINativeModule().image.analyzerConfig(node, this.value!); 589 } 590 } 591} 592 593class ImageOnErrorModifier extends ModifierWithKey<(result: {componentWidth: number; componentHeight: number; message: string}) => void> { 594 constructor(value: (event: {componentWidth: number; componentHeight: number; message: string}) => void) { 595 super(value); 596 } 597 static identity = Symbol('imageOnError'); 598 applyPeer(node: KNode, reset: boolean): void { 599 if (reset) { 600 getUINativeModule().image.resetOnError(node); 601 } else { 602 getUINativeModule().image.setOnError(node, this.value); 603 } 604 } 605} 606 607class ImageOnFinishModifier extends ModifierWithKey<VoidCallback> { 608 constructor(value: VoidCallback) { 609 super(value); 610 } 611 static identity: Symbol = Symbol('imageOnFinish'); 612 applyPeer(node: KNode, reset: boolean): void { 613 if (reset) { 614 getUINativeModule().image.resetOnFinish(node); 615 } else { 616 getUINativeModule().image.setOnFinish(node, this.value); 617 } 618 } 619} 620 621class ImageRotateOrientationModifier extends ModifierWithKey<ImageRotateOrientation> { 622 static identity: Symbol = Symbol('imageOrientation'); 623 applyPeer(node: KNode, reset: boolean): void { 624 if (reset) { 625 getUINativeModule().image.resetOrientation(node); 626 } else { 627 getUINativeModule().image.setOrientation(node); 628 } 629 } 630} 631 632class ImagePointLightModifier extends ModifierWithKey<PointLightStyle> { 633 constructor(value: PointLightStyle) { 634 super(value); 635 } 636 static identity: Symbol = Symbol('imagePointLight'); 637 applyPeer(node: KNode, reset: boolean): void { 638 if (reset) { 639 getUINativeModule().common.resetPointLightStyle(node); 640 } else { 641 let positionX: Dimension | undefined; 642 let positionY: Dimension | undefined; 643 let positionZ: Dimension | undefined; 644 let intensity: number | undefined; 645 let color: ResourceColor | undefined; 646 let illuminated: number | undefined; 647 let bloom: number | undefined; 648 if (!isUndefined(this.value.lightSource) && this.value.lightSource != null) { 649 positionX = this.value.lightSource.positionX; 650 positionY = this.value.lightSource.positionY; 651 positionZ = this.value.lightSource.positionZ; 652 intensity = this.value.lightSource.intensity; 653 color = this.value.lightSource.color; 654 } 655 illuminated = this.value.illuminated; 656 bloom = this.value.bloom; 657 getUINativeModule().common.setPointLightStyle(node, positionX, positionY, positionZ, intensity, color, 658 illuminated, bloom); 659 } 660 } 661 checkObjectDiff(): boolean { 662 return !isBaseOrResourceEqual(this.stageValue.lightSource?.positionX, this.value.lightSource?.positionX) || 663 !isBaseOrResourceEqual(this.stageValue.lightSource?.positionY, this.value.lightSource?.positionY) || 664 !isBaseOrResourceEqual(this.stageValue.lightSource?.positionZ, this.value.lightSource?.positionZ) || 665 !isBaseOrResourceEqual(this.stageValue.lightSource?.intensity, this.value.lightSource?.intensity) || 666 !isBaseOrResourceEqual(this.stageValue.lightSource?.color, this.value.lightSource?.color) || 667 !isBaseOrResourceEqual(this.stageValue.illuminated, this.value.illuminated) || 668 !isBaseOrResourceEqual(this.stageValue.bloom, this.value.bloom); 669 } 670} 671class ImageOnCompleteModifier extends ModifierWithKey<(event?: { 672 width: number; 673 height: number; 674 componentWidth: number; 675 componentHeight: number; 676 loadingStatus: number; 677 contentWidth: number; 678 contentHeight: number; 679 contentOffsetX: number; 680 contentOffsetY: number; 681}) => void> { 682 constructor(value: (event?: { 683 width: number; 684 height: number; 685 componentWidth: number; 686 componentHeight: number; 687 loadingStatus: number; 688 contentWidth: number; 689 contentHeight: number; 690 contentOffsetX: number; 691 contentOffsetY: number; 692 }) => void) { 693 super(value); 694 } 695 static identity = Symbol('imageOnComplete'); 696 applyPeer(node: KNode, reset: boolean): void { 697 if (reset) { 698 getUINativeModule().image.resetOnComplete(node); 699 } else { 700 getUINativeModule().image.setOnComplete(node, this.value); 701 } 702 } 703} 704class ArkImageComponent extends ArkComponent implements ImageAttribute { 705 constructor(nativePtr: KNode, classType?: ModifierType) { 706 super(nativePtr, classType); 707 } 708 initialize(value: Object[]): this { 709 modifierWithKey(this._modifiersWithKeys, ImageSrcModifier.identity, ImageSrcModifier, value[0]); 710 return this; 711 } 712 allowChildCount(): number { 713 return 0; 714 } 715 draggable(value: boolean): this { 716 modifierWithKey(this._modifiersWithKeys, ImageDraggableModifier.identity, ImageDraggableModifier, value); 717 return this; 718 } 719 edgeAntialiasing(value: number): this { 720 modifierWithKey(this._modifiersWithKeys, ImageEdgeAntialiasingModifier.identity, ImageEdgeAntialiasingModifier, value); 721 return this; 722 } 723 alt(value: ResourceStr): this { 724 modifierWithKey(this._modifiersWithKeys, ImageAltModifier.identity, ImageAltModifier, value); 725 return this; 726 } 727 matchTextDirection(value: boolean): this { 728 modifierWithKey(this._modifiersWithKeys, ImageMatchTextDirectionModifier.identity, ImageMatchTextDirectionModifier, value); 729 return this; 730 } 731 fitOriginalSize(value: boolean): this { 732 modifierWithKey(this._modifiersWithKeys, ImageFitOriginalSizeModifier.identity, ImageFitOriginalSizeModifier, value); 733 return this; 734 } 735 pointLight(value: PointLightStyle): this { 736 modifierWithKey(this._modifiersWithKeys, ImagePointLightModifier.identity, ImagePointLightModifier, value); 737 return this; 738 } 739 fillColor(value: ResourceColor): this { 740 modifierWithKey(this._modifiersWithKeys, ImageFillColorModifier.identity, 741 ImageFillColorModifier, value); 742 return this; 743 } 744 objectFit(value: ImageFit): this { 745 modifierWithKey(this._modifiersWithKeys, ImageObjectFitModifier.identity, 746 ImageObjectFitModifier, value); 747 return this; 748 } 749 imageMatrix(value: object): this { 750 modifierWithKey(this._modifiersWithKeys, ImageMatrixModifier.identity, ImageMatrixModifier, value); 751 return this; 752 } 753 objectRepeat(value: ImageRepeat): this { 754 modifierWithKey(this._modifiersWithKeys, ImageObjectRepeatModifier.identity, 755 ImageObjectRepeatModifier, value); 756 return this; 757 } 758 autoResize(value: boolean): this { 759 modifierWithKey(this._modifiersWithKeys, ImageAutoResizeModifier.identity, 760 ImageAutoResizeModifier, value); 761 return this; 762 } 763 renderMode(value: ImageRenderMode): this { 764 modifierWithKey(this._modifiersWithKeys, ImageRenderModeModifier.identity, 765 ImageRenderModeModifier, value); 766 return this; 767 } 768 interpolation(value: ImageInterpolation): this { 769 modifierWithKey(this._modifiersWithKeys, ImageInterpolationModifier.identity, 770 ImageInterpolationModifier, value); 771 return this; 772 } 773 sourceSize(value: { width: number; height: number }): this { 774 modifierWithKey(this._modifiersWithKeys, ImageSourceSizeModifier.identity, 775 ImageSourceSizeModifier, value); 776 return this; 777 } 778 syncLoad(value: boolean): this { 779 modifierWithKey(this._modifiersWithKeys, ImageSyncLoadModifier.identity, 780 ImageSyncLoadModifier, value); 781 return this; 782 } 783 784 colorFilter(value: ColorFilter | DrawingColorFilter): this { 785 modifierWithKey(this._modifiersWithKeys, ImageColorFilterModifier.identity, 786 ImageColorFilterModifier, value); 787 return this; 788 } 789 copyOption(value: CopyOptions): this { 790 modifierWithKey(this._modifiersWithKeys, ImageCopyOptionModifier.identity, 791 ImageCopyOptionModifier, value); 792 return this; 793 } 794 borderRadius(value: Length | BorderRadiuses): this { 795 modifierWithKey(this._modifiersWithKeys, ImageBorderRadiusModifier.identity, ImageBorderRadiusModifier, value); 796 return this; 797 } 798 onComplete( 799 callback: (event?: { 800 width: number; 801 height: number; 802 componentWidth: number; 803 componentHeight: number; 804 loadingStatus: number; 805 contentWidth: number; 806 contentHeight: number; 807 contentOffsetX: number; 808 contentOffsetY: number; 809 }) => void, 810 ): this { 811 modifierWithKey(this._modifiersWithKeys, ImageOnCompleteModifier.identity, ImageOnCompleteModifier, value); 812 return this; 813 } 814 onError(callback: (event: { 815 componentWidth: number; 816 componentHeight: number; 817 message: string 818 }) => void): this { 819 modifierWithKey(this._modifiersWithKeys, ImageOnErrorModifier.identity, ImageOnErrorModifier, callback); 820 return this; 821 } 822 onFinish(event: () => void): this { 823 modifierWithKey(this._modifiersWithKeys, ImageOnFinishModifier.identity, ImageOnFinishModifier, event); 824 return this; 825 } 826 border(value: BorderOptions): this { 827 modifierWithKey(this._modifiersWithKeys, ImageBorderModifier.identity, ImageBorderModifier, value); 828 return this; 829 } 830 opacity(value: number | Resource): this { 831 modifierWithKey(this._modifiersWithKeys, ImageOpacityModifier.identity, ImageOpacityModifier, value); 832 return this; 833 } 834 transition(value: TransitionOptions | TransitionEffect): this { 835 modifierWithKey(this._modifiersWithKeys, ImageTransitionModifier.identity, ImageTransitionModifier, value); 836 return this; 837 } 838 dynamicRangeMode(value: DynamicRangeMode): this { 839 modifierWithKey( 840 this._modifiersWithKeys, ImageDynamicRangeModeModifier.identity, ImageDynamicRangeModeModifier, value); 841 return this; 842 } 843 orientation(value: ImageRotateOrientaion): this { 844 modifierWithKey( 845 this._modifiersWithKeys, ImageRotateOrientationModifier.identity, ImageRotateOrientationModifier, value); 846 return this; 847 } 848 enhancedImageQuality(value: ResolutionQuality): this { 849 modifierWithKey( 850 this._modifiersWithKeys, ImageDynamicRangeModeModifier.identity, ImageDynamicRangeModeModifier, value); 851 return this; 852 } 853 enableAnalyzer(value: boolean): this { 854 modifierWithKey(this._modifiersWithKeys, ImageEnableAnalyzerModifier.identity, ImageEnableAnalyzerModifier, value); 855 return this; 856 } 857 privacySensitive(value: boolean): this { 858 modifierWithKey(this._modifiersWithKeys, ImageEnableAnalyzerModifier.identity, ImageEnableAnalyzerModifier, value); 859 return this; 860 } 861 analyzerConfig(value: object): this { 862 modifierWithKey(this._modifiersWithKeys, ImageAnalyzerConfigModifier.identity, ImageAnalyzerConfigModifier, value); 863 return this; 864 } 865 resizable(value: ResizableOptions): this { 866 modifierWithKey(this._modifiersWithKeys, ImageResizableModifier.identity, ImageResizableModifier, value); 867 return this; 868 } 869} 870// @ts-ignore 871globalThis.Image.attributeModifier = function (modifier: ArkComponent): void { 872 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 873 return new ArkImageComponent(nativePtr); 874 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 875 return new modifierJS.ImageModifier(nativePtr, classType); 876 }); 877}; 878