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' /> 17/// <reference path="./ArkComponent.ts" /> 18const FontWeightMap = { 19 0: 'lighter', 20 1: 'normal', 21 2: 'regular', 22 3: 'medium', 23 4: 'bold', 24 5: 'bolder', 25 100: '100', 26 200: '200', 27 300: '300', 28 400: '400', 29 500: '500', 30 600: '600', 31 700: '700', 32 800: '800', 33 900: '900', 34}; 35 36class ArkButtonComponent extends ArkComponent implements ButtonAttribute { 37 builder: WrappedBuilder<Object[]> | null = null; 38 buttonNode: BuilderNode<[ButtonConfiguration]> | null = null; 39 modifier: ContentModifier<ButtonConfiguration>; 40 needRebuild: boolean = false; 41 applyContent: WrappedBuilder<[ButtonConfiguration]>; 42 constructor(nativePtr: KNode, classType?: ModifierType) { 43 super(nativePtr, classType); 44 } 45 allowChildCount(): number { 46 return 1; 47 } 48 initialize(value: Object[]): this { 49 if (value.length >= 1 && (isResource(value[0]) || isString(value[0]))) { 50 modifierWithKey(this._modifiersWithKeys, ButtonCreateTypeModifier.identity, ButtonCreateTypeModifier, true); 51 } else { 52 modifierWithKey(this._modifiersWithKeys, ButtonCreateTypeModifier.identity, ButtonCreateTypeModifier, false); 53 } 54 if (value.length === 1) { 55 if (!isNull(value[0]) && isObject(value[0])) { 56 modifierWithKey(this._modifiersWithKeys, ButtonOptionsModifier.identity, ButtonOptionsModifier, value[0]); 57 } else if (isResource(value[0]) || isString(value[0])) { 58 modifierWithKey(this._modifiersWithKeys, ButtonLabelModifier.identity, ButtonLabelModifier, value[0]); 59 } else { 60 modifierWithKey(this._modifiersWithKeys, ButtonLabelModifier.identity, ButtonLabelModifier, undefined); 61 modifierWithKey(this._modifiersWithKeys, ButtonOptionsModifier.identity, ButtonOptionsModifier, undefined); 62 } 63 } else if (value.length === 2) { 64 modifierWithKey(this._modifiersWithKeys, ButtonLabelModifier.identity, ButtonLabelModifier, value[0]); 65 modifierWithKey(this._modifiersWithKeys, ButtonOptionsModifier.identity, ButtonOptionsModifier, value[1]); 66 } else { 67 modifierWithKey(this._modifiersWithKeys, ButtonLabelModifier.identity, ButtonLabelModifier, undefined); 68 modifierWithKey(this._modifiersWithKeys, ButtonOptionsModifier.identity, ButtonOptionsModifier, undefined); 69 } 70 return this; 71 } 72 backgroundColor(value: ResourceColor): this { 73 modifierWithKey(this._modifiersWithKeys, ButtonBackgroundColorModifier.identity, ButtonBackgroundColorModifier, value); 74 return this; 75 } 76 type(value: ButtonType): this { 77 modifierWithKey(this._modifiersWithKeys, ButtonTypeModifier.identity, ButtonTypeModifier, value); 78 return this; 79 } 80 stateEffect(value: boolean): this { 81 modifierWithKey(this._modifiersWithKeys, ButtonStateEffectModifier.identity, ButtonStateEffectModifier, value); 82 return this; 83 } 84 fontColor(value: ResourceColor): this { 85 modifierWithKey(this._modifiersWithKeys, ButtonFontColorModifier.identity, ButtonFontColorModifier, value); 86 return this; 87 } 88 fontSize(value: Length): this { 89 modifierWithKey(this._modifiersWithKeys, ButtonFontSizeModifier.identity, ButtonFontSizeModifier, value); 90 return this; 91 } 92 fontWeight(value: string | number | FontWeight): this { 93 modifierWithKey(this._modifiersWithKeys, ButtonFontWeightModifier.identity, ButtonFontWeightModifier, value); 94 return this; 95 } 96 fontStyle(value: FontStyle): this { 97 modifierWithKey(this._modifiersWithKeys, ButtonFontStyleModifier.identity, ButtonFontStyleModifier, value); 98 return this; 99 } 100 fontFamily(value: string | Resource): this { 101 modifierWithKey(this._modifiersWithKeys, ButtonFontFamilyModifier.identity, ButtonFontFamilyModifier, value); 102 return this; 103 } 104 labelStyle(value: LabelStyle): this { 105 modifierWithKey(this._modifiersWithKeys, ButtonLabelStyleModifier.identity, ButtonLabelStyleModifier, value); 106 return this; 107 } 108 borderRadius(value: Length | BorderRadiuses): this { 109 modifierWithKey(this._modifiersWithKeys, ButtonBorderRadiusModifier.identity, ButtonBorderRadiusModifier, value); 110 return this; 111 } 112 border(value: BorderOptions): this { 113 modifierWithKey(this._modifiersWithKeys, ButtonBorderModifier.identity, ButtonBorderModifier, value); 114 return this; 115 } 116 size(value: SizeOptions): this { 117 modifierWithKey(this._modifiersWithKeys, ButtonSizeModifier.identity, ButtonSizeModifier, value); 118 return this; 119 } 120 contentModifier(value: ContentModifier<ButtonConfiguration>): this { 121 modifierWithKey(this._modifiersWithKeys, ButtonContentModifier.identity, ButtonContentModifier, value); 122 return this; 123 } 124 setContentModifier(modifier: ContentModifier<ButtonConfiguration>): this { 125 if (modifier === undefined || modifier === null) { 126 getUINativeModule().button.setContentModifierBuilder(this.nativePtr, false); 127 return; 128 } 129 this.needRebuild = false; 130 this.applyContent = modifier.applyContent(); 131 if (this.builder !== this.applyContent) { 132 this.needRebuild = true; 133 } 134 this.builder = this.applyContent; 135 this.modifier = modifier; 136 getUINativeModule().button.setContentModifierBuilder(this.nativePtr, this); 137 } 138 makeContentModifierNode(context: UIContext, buttonConfiguration: ButtonConfiguration): FrameNode | null { 139 buttonConfiguration.contentModifier = this.modifier; 140 if (isUndefined(this.buttonNode) || this.needRebuild) { 141 const xNode = globalThis.requireNapi('arkui.node'); 142 this.buttonNode = new xNode.BuilderNode(context); 143 this.buttonNode.build(this.builder, buttonConfiguration); 144 this.needRebuild = false; 145 } else { 146 this.buttonNode.update(buttonConfiguration); 147 } 148 return this.buttonNode.getFrameNode(); 149 } 150 role(value: ButtonRole): this { 151 modifierWithKey(this._modifiersWithKeys, ButtonRoleModifier.identity, ButtonRoleModifier, value); 152 return this; 153 } 154 buttonStyle(value: ButtonStyleMode): this { 155 modifierWithKey(this._modifiersWithKeys, ButtonStyleModifier.identity, ButtonStyleModifier, value); 156 return this; 157 } 158 controlSize(value: ControlSize): this { 159 modifierWithKey(this._modifiersWithKeys, ButtonControlSizeModifier.identity, ButtonControlSizeModifier, value); 160 return this; 161 } 162} 163class ButtonBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 164 constructor(value: ResourceColor) { 165 super(value); 166 } 167 static identity: Symbol = Symbol('buttonBackgroundColor'); 168 applyPeer(node: KNode, reset: boolean): void { 169 if (reset) { 170 getUINativeModule().button.resetBackgroundColor(node); 171 } else { 172 getUINativeModule().button.setBackgroundColor(node, this.value); 173 } 174 } 175 176 checkObjectDiff(): boolean { 177 return !isBaseOrResourceEqual(this.stageValue, this.value); 178 } 179} 180class ButtonStateEffectModifier extends ModifierWithKey<boolean> { 181 constructor(value: boolean) { 182 super(value); 183 } 184 static identity: Symbol = Symbol('buttonStateEffect'); 185 applyPeer(node: KNode, reset: boolean): void { 186 if (reset) { 187 getUINativeModule().button.resetStateEffect(node); 188 } else { 189 getUINativeModule().button.setStateEffect(node, this.value); 190 } 191 } 192} 193class ButtonFontStyleModifier extends ModifierWithKey<number> { 194 constructor(value: number) { 195 super(value); 196 } 197 static identity: Symbol = Symbol('buttonFontStyle'); 198 applyPeer(node: KNode, reset: boolean): void { 199 if (reset) { 200 getUINativeModule().button.resetFontStyle(node); 201 } else { 202 getUINativeModule().button.setFontStyle(node, this.value); 203 } 204 } 205} 206class ButtonFontFamilyModifier extends ModifierWithKey<string | Resource> { 207 static identity: Symbol = Symbol('buttonFontFamily'); 208 applyPeer(node: KNode, reset: boolean): void { 209 if (reset) { 210 getUINativeModule().button.resetFontFamily(node); 211 } else { 212 getUINativeModule().button.setFontFamily(node, this.value); 213 } 214 } 215 checkObjectDiff(): boolean { 216 return !isBaseOrResourceEqual(this.stageValue, this.value); 217 } 218} 219class ButtonLabelStyleModifier extends ModifierWithKey<LabelStyle> { 220 static identity: Symbol = Symbol('buttonLabelStyle'); 221 applyPeer(node: KNode, reset: boolean): void { 222 if (reset) { 223 getUINativeModule().button.resetLabelStyle(node); 224 } else { 225 let textOverflow = this.value.overflow; // number(enum) -> Ace::TextOverflow 226 let maxLines = this.value.maxLines; // number -> uint32_t 227 let minFontSize = this.value.minFontSize; // number | string | Resource -> Dimension 228 let maxFontSize = this.value.maxFontSize; // number | string | Resource -> Dimension 229 let heightAdaptivePolicy = this.value.heightAdaptivePolicy; // number(enum) -> Ace::TextHeightAdaptivePolicy 230 let fontSize; // number | string | Resource -> Dimension 231 let fontWeight; // number | string | Ace::FontWeight -> string -> Ace::FontWeight 232 let fontStyle; // number(enum) -> Ace::FontStyle 233 let fontFamily; // string -> std::vector<std::string> 234 if (isObject(this.value.font)) { 235 fontSize = this.value.font.size; 236 fontStyle = this.value.font.style; 237 fontFamily = this.value.font.family; 238 fontWeight = this.value.font.weight; 239 } 240 getUINativeModule().button.setLabelStyle(node, textOverflow, maxLines, minFontSize, maxFontSize, 241 heightAdaptivePolicy, fontSize, fontWeight, fontStyle, fontFamily); 242 } 243 } 244 checkObjectDiff(): boolean { 245 if (isResource(this.stageValue) && isResource(this.value)) { 246 return !isResourceEqual(this.stageValue, this.value); 247 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 248 return !(this.value.overflow === this.stageValue.overflow && 249 this.value.maxLines === this.stageValue.maxLines && 250 this.value.minFontSize === this.stageValue.minFontSize && 251 this.value.maxFontSize === this.stageValue.maxFontSize && 252 this.value.heightAdaptivePolicy === this.stageValue.heightAdaptivePolicy && 253 this.value.font === this.stageValue.font); 254 } else { 255 return true; 256 } 257 } 258} 259class ButtonTypeModifier extends ModifierWithKey<number> { 260 constructor(value: number) { 261 super(value); 262 } 263 static identity: Symbol = Symbol('buttonType'); 264 applyStage(node: KNode, component?: ArkComponent): boolean { 265 if (this.stageValue === undefined || this.stageValue === null) { 266 this.value = this.stageValue; 267 this.applyPeer(node, true, component); 268 return true; 269 } 270 this.value = this.stageValue; 271 this.applyPeer(node, false, component); 272 return false; 273 } 274 applyPeer(node: KNode, reset: boolean): void { 275 if (reset) { 276 getUINativeModule().button.resetType(node); 277 } else { 278 getUINativeModule().button.setType(node, this.value); 279 } 280 } 281} 282class ButtonFontColorModifier extends ModifierWithKey<ResourceColor> { 283 static identity: Symbol = Symbol('buttonFontColor'); 284 applyPeer(node: KNode, reset: boolean): void { 285 if (reset) { 286 getUINativeModule().button.resetFontColor(node); 287 } else { 288 getUINativeModule().button.setFontColor(node, this.value); 289 } 290 } 291 292 checkObjectDiff(): boolean { 293 return !isBaseOrResourceEqual(this.stageValue, this.value); 294 } 295} 296class ButtonFontSizeModifier extends ModifierWithKey<Length> { 297 static identity: Symbol = Symbol('buttonFontSize'); 298 applyPeer(node: KNode, reset: boolean): void { 299 if (reset) { 300 getUINativeModule().button.resetFontSize(node); 301 } else { 302 getUINativeModule().button.setFontSize(node, this.value); 303 } 304 } 305 306 checkObjectDiff(): boolean { 307 return !isBaseOrResourceEqual(this.stageValue, this.value); 308 } 309} 310class ButtonFontWeightModifier extends ModifierWithKey<string | number | FontWeight> { 311 constructor(value: string | number | FontWeight) { 312 super(value); 313 } 314 static identity: Symbol = Symbol('buttonFontWeight'); 315 applyPeer(node: KNode, reset: boolean): void { 316 if (reset) { 317 getUINativeModule().button.resetFontWeight(node); 318 } else { 319 getUINativeModule().button.setFontWeight(node, this.value); 320 } 321 } 322} 323 324class ButtonBorderRadiusModifier extends ModifierWithKey<Length | BorderRadiuses> { 325 constructor(value: Length | BorderRadiuses) { 326 super(value); 327 } 328 static identity: Symbol = Symbol('buttonBorderRadius'); 329 applyPeer(node: KNode, reset: boolean): void { 330 if (reset) { 331 getUINativeModule().button.resetButtonBorderRadius(node); 332 } else { 333 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 334 getUINativeModule().button.setButtonBorderRadius(node, this.value, this.value, this.value, this.value); 335 } else { 336 getUINativeModule().button.setButtonBorderRadius(node, 337 (this.value as BorderRadiuses).topLeft, 338 (this.value as BorderRadiuses).topRight, 339 (this.value as BorderRadiuses).bottomLeft, 340 (this.value as BorderRadiuses).bottomRight); 341 } 342 } 343 } 344 345 checkObjectDiff(): boolean { 346 if (isResource(this.stageValue) && isResource(this.value)) { 347 return !isResourceEqual(this.stageValue, this.value); 348 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 349 return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft && 350 (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight && 351 (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft && 352 (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight); 353 } else { 354 return true; 355 } 356 } 357} 358 359class ButtonBorderModifier extends ModifierWithKey<BorderOptions> { 360 constructor(value: BorderOptions) { 361 super(value); 362 } 363 static identity: Symbol = Symbol('buttonBorder'); 364 applyPeer(node: KNode, reset: boolean): void { 365 if (reset) { 366 getUINativeModule().button.resetButtonBorder(node); 367 } else { 368 let widthLeft; 369 let widthRight; 370 let widthTop; 371 let widthBottom; 372 if (!isUndefined(this.value.width) && this.value.width !== null) { 373 if (isNumber(this.value.width) || isString(this.value.width) || isResource(this.value.width)) { 374 widthLeft = this.value.width; 375 widthRight = this.value.width; 376 widthTop = this.value.width; 377 widthBottom = this.value.width; 378 } else { 379 widthLeft = (this.value.width as EdgeWidths).left; 380 widthRight = (this.value.width as EdgeWidths).right; 381 widthTop = (this.value.width as EdgeWidths).top; 382 widthBottom = (this.value.width as EdgeWidths).bottom; 383 } 384 } 385 let leftColor; 386 let rightColor; 387 let topColor; 388 let bottomColor; 389 if (!isUndefined(this.value.color) && this.value.color !== null) { 390 if (isNumber(this.value.color) || isString(this.value.color) || isResource(this.value.color)) { 391 leftColor = this.value.color; 392 rightColor = this.value.color; 393 topColor = this.value.color; 394 bottomColor = this.value.color; 395 } else { 396 leftColor = (this.value.color as EdgeColors).left; 397 rightColor = (this.value.color as EdgeColors).right; 398 topColor = (this.value.color as EdgeColors).top; 399 bottomColor = (this.value.color as EdgeColors).bottom; 400 } 401 } 402 let topLeft; 403 let topRight; 404 let bottomLeft; 405 let bottomRight; 406 if (!isUndefined(this.value.radius) && this.value.radius !== null) { 407 if (isNumber(this.value.radius) || isString(this.value.radius) || isResource(this.value.radius)) { 408 topLeft = this.value.radius; 409 topRight = this.value.radius; 410 bottomLeft = this.value.radius; 411 bottomRight = this.value.radius; 412 } else { 413 topLeft = (this.value.radius as BorderRadiuses).topLeft; 414 topRight = (this.value.radius as BorderRadiuses).topRight; 415 bottomLeft = (this.value.radius as BorderRadiuses).bottomLeft; 416 bottomRight = (this.value.radius as BorderRadiuses).bottomRight; 417 } 418 } 419 let styleTop; 420 let styleRight; 421 let styleBottom; 422 let styleLeft; 423 if (!isUndefined(this.value.style) && this.value.style !== null) { 424 if (isNumber(this.value.style) || isString(this.value.style) || isResource(this.value.style)) { 425 styleTop = this.value.style; 426 styleRight = this.value.style; 427 styleBottom = this.value.style; 428 styleLeft = this.value.style; 429 } else { 430 styleTop = (this.value.style as EdgeStyles).top; 431 styleRight = (this.value.style as EdgeStyles).right; 432 styleBottom = (this.value.style as EdgeStyles).bottom; 433 styleLeft = (this.value.style as EdgeStyles).left; 434 } 435 } 436 getUINativeModule().button.setButtonBorder( 437 node, 438 widthLeft, 439 widthRight, 440 widthTop, 441 widthBottom, 442 leftColor, 443 rightColor, 444 topColor, 445 bottomColor, 446 topLeft, 447 topRight, 448 bottomLeft, 449 bottomRight, 450 styleTop, 451 styleRight, 452 styleBottom, 453 styleLeft 454 ); 455 } 456 } 457 458 checkObjectDiff(): boolean { 459 return !isBaseOrResourceEqual(this.stageValue.width, this.value.width) || 460 !isBaseOrResourceEqual(this.stageValue.color, this.value.color) || 461 !isBaseOrResourceEqual(this.stageValue.radius, this.value.radius) || 462 !isBaseOrResourceEqual(this.stageValue.style, this.value.style); 463 } 464} 465 466class ButtonSizeModifier extends ModifierWithKey<SizeOptions> { 467 constructor(value: SizeOptions) { 468 super(value); 469 } 470 static identity: Symbol = Symbol('buttonSize'); 471 applyPeer(node: KNode, reset: boolean): void { 472 if (reset) { 473 getUINativeModule().button.resetButtonSize(node); 474 } else { 475 getUINativeModule().button.setButtonSize(node, this.value.width, this.value.height); 476 } 477 } 478 479 checkObjectDiff(): boolean { 480 return ( 481 !isBaseOrResourceEqual(this.stageValue.width, this.value.width) || 482 !isBaseOrResourceEqual(this.stageValue.height, this.value.height) 483 ); 484 } 485} 486 487class ButtonRoleModifier extends ModifierWithKey<ButtonRole> { 488 constructor(value: ButtonRole) { 489 super(value); 490 } 491 static identity: Symbol = Symbol('buttonRole'); 492 applyPeer(node: KNode, reset: boolean): void { 493 if (reset) { 494 getUINativeModule().button.resetButtonRole(node); 495 } else { 496 getUINativeModule().button.setButtonRole(node, this.value); 497 } 498 } 499 500 checkObjectDiff(): boolean { 501 return ( 502 !isBaseOrResourceEqual(this.stageValue, this.value) 503 ); 504 } 505} 506 507class ButtonStyleModifier extends ModifierWithKey<ButtonStyleMode> { 508 constructor(value: ButtonStyleMode) { 509 super(value); 510 } 511 static identity: Symbol = Symbol('buttonStyle'); 512 applyPeer(node: KNode, reset: boolean): void { 513 if (reset) { 514 getUINativeModule().button.resetButtonStyle(node); 515 } else { 516 getUINativeModule().button.setButtonStyle(node, this.value); 517 } 518 } 519 520 checkObjectDiff(): boolean { 521 return ( 522 !isBaseOrResourceEqual(this.stageValue, this.value) 523 ); 524 } 525} 526 527class ButtonControlSizeModifier extends ModifierWithKey<ControlSize> { 528 constructor(value: ControlSize) { 529 super(value); 530 } 531 static identity: Symbol = Symbol('buttonControlSize'); 532 applyPeer(node: KNode, reset: boolean): void { 533 if (reset) { 534 getUINativeModule().button.resetControlSize(node); 535 } else { 536 getUINativeModule().button.setControlSize(node, this.value); 537 } 538 } 539 540 checkObjectDiff(): boolean { 541 return ( 542 !isBaseOrResourceEqual(this.stageValue, this.value) 543 ); 544 } 545} 546 547class ButtonLabelModifier extends ModifierWithKey<ResourceStr> { 548 constructor(value: ResourceStr) { 549 super(value); 550 } 551 static identity: Symbol = Symbol('buttonLabel'); 552 applyPeer(node: KNode, reset: boolean): void { 553 if (reset) { 554 getUINativeModule().button.resetLabel(node); 555 } else { 556 getUINativeModule().button.setLabel(node, this.value); 557 } 558 } 559 checkObjectDiff(): boolean { 560 return !isBaseOrResourceEqual(this.stageValue, this.value); 561 } 562} 563 564class ButtonOptionsModifier extends ModifierWithKey<ButtonOptions> { 565 static identity: Symbol = Symbol('buttonOptions'); 566 applyPeer(node: KNode, reset: boolean): void { 567 if (reset) { 568 getUINativeModule().button.resetOptions(node); 569 } else { 570 getUINativeModule().button.setOptions(node, this.value.type, this.value.stateEffect, 571 this.value.buttonStyle, this.value.controlSize, this.value.role); 572 } 573 } 574 checkObjectDiff(): boolean { 575 return ( 576 !isBaseOrResourceEqual(this.stageValue.type, this.value.type) || 577 !isBaseOrResourceEqual(this.stageValue.stateEffect, this.value.stateEffect) || 578 !isBaseOrResourceEqual(this.stageValue.buttonStyle, this.value.buttonStyle) || 579 !isBaseOrResourceEqual(this.stageValue.controlSize, this.value.controlSize) || 580 !isBaseOrResourceEqual(this.stageValue.role, this.value.role) 581 ); 582 } 583} 584 585class ButtonCreateTypeModifier extends ModifierWithKey<boolean> { 586 static identity: Symbol = Symbol('buttonCreateType'); 587 applyPeer(node: KNode, reset: boolean): void { 588 if (!reset) { 589 getUINativeModule().button.setCreateWithLabel(node, this.value); 590 } 591 } 592 checkObjectDiff(): boolean { 593 return !isBaseOrResourceEqual(this.stageValue, this.value); 594 } 595} 596class ButtonContentModifier extends ModifierWithKey<ContentModifier<ButtonConfiguration>> { 597 constructor(value: ContentModifier<ButtonConfiguration>) { 598 super(value); 599 } 600 static identity: Symbol = Symbol('buttonContentModifier'); 601 applyPeer(node: KNode, reset: boolean, component: ArkComponent) { 602 let buttonComponent = component as ArkButtonComponent; 603 buttonComponent.setContentModifier(this.value); 604 } 605} 606 607// @ts-ignore 608globalThis.Button.attributeModifier = function (modifier: ArkComponent): void { 609 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 610 return new ArkButtonComponent(nativePtr); 611 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 612 return new modifierJS.ButtonModifier(nativePtr, classType); 613 }); 614}; 615 616// @ts-ignore 617globalThis.Button.contentModifier = function (modifier: ContentModifier<ButtonConfiguration>): void { 618 const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); 619 let nativeNode = getUINativeModule().getFrameNodeById(elmtId); 620 let component = this.createOrGetNode(elmtId, () => { 621 return new ArkButtonComponent(nativeNode); 622 }); 623 component.setContentModifier(modifier); 624}; 625