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 16var j = (this && this.j) || function (t3, target, key, desc) { 17 var c = arguments.length, 18 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 19 if (typeof Reflect === "object" && typeof Reflect.o1 === "function") { 20 r = Reflect.o1(t3, target, key, desc); 21 } else { 22 for (var u3 = t3.length - 1; u3 >= 0; u3--) { 23 if (d = t3[u3]) { 24 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 25 } 26 } 27 } 28 return c > 3 && r && Object.defineProperty(target, key, r), r; 29}; 30var m, o; 31if (!("finalizeConstruction" in ViewPU.prototype)) { 32 Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { 33 }); 34} 35const curves = globalThis.requireNativeModule('ohos.curves'); 36const KeyCode = globalThis.requireNapi('multimodalInput.keyCode').KeyCode; 37const util = globalThis.requireNapi('util'); 38const LengthMetrics = requireNapi('arkui.node').LengthMetrics; 39const t = requireNapi('i18n'); 40 41const u = 2; 42const a1 = 5; 43const b1 = 1; 44const c1 = 2; 45const d1 = 1; 46const e1 = { 47 q1: { 48 "id": -1, 49 "type": 10001, 50 params: ['sys.color.ohos_id_color_text_secondary'], 51 "bundleName": "__harDefaultBundleName__", 52 "moduleName": "__harDefaultModuleName__" 53 }, 54 s1: { 55 "id": -1, 56 "type": 10001, 57 params: ['sys.color.ohos_id_color_text_primary'], 58 "bundleName": "__harDefaultBundleName__", 59 "moduleName": "__harDefaultModuleName__" 60 }, 61 t1: { 62 "id": -1, 63 "type": 10001, 64 params: ['sys.color.ohos_id_color_foreground_contrary'], 65 "bundleName": "__harDefaultBundleName__", 66 "moduleName": "__harDefaultModuleName__" 67 }, 68 u1: { 69 "id": -1, 70 "type": 10002, 71 params: ['sys.float.ohos_id_text_size_body2'], 72 "bundleName": "__harDefaultBundleName__", 73 "moduleName": "__harDefaultModuleName__" 74 }, 75 v1: { 76 "id": -1, 77 "type": 10002, 78 params: ['sys.float.ohos_id_text_size_body2'], 79 "bundleName": "__harDefaultBundleName__", 80 "moduleName": "__harDefaultModuleName__" 81 }, 82 BACKGROUND_COLOR: { 83 "id": -1, 84 "type": 10001, 85 params: ['sys.color.ohos_id_color_button_normal'], 86 "bundleName": "__harDefaultBundleName__", 87 "moduleName": "__harDefaultModuleName__" 88 }, 89 w1: { 90 "id": -1, 91 "type": 10001, 92 params: ['sys.color.ohos_id_color_foreground_contrary'], 93 "bundleName": "__harDefaultBundleName__", 94 "moduleName": "__harDefaultModuleName__" 95 }, 96 z1: { 97 "id": -1, 98 "type": 10001, 99 params: ['sys.color.ohos_id_color_emphasize'], 100 "bundleName": "__harDefaultBundleName__", 101 "moduleName": "__harDefaultModuleName__" 102 }, 103 a2: { 104 "id": -1, 105 "type": 10001, 106 params: ['sys.color.ohos_id_color_focused_outline'], 107 "bundleName": "__harDefaultBundleName__", 108 "moduleName": "__harDefaultModuleName__" 109 }, 110 b2: { 111 "id": -1, 112 "type": 10001, 113 params: ['sys.color.ohos_id_color_hover'], 114 "bundleName": "__harDefaultBundleName__", 115 "moduleName": "__harDefaultModuleName__" 116 }, 117 c2: { 118 "id": -1, 119 "type": 10001, 120 params: ['sys.color.ohos_id_color_click_effect'], 121 "bundleName": "__harDefaultBundleName__", 122 "moduleName": "__harDefaultModuleName__" 123 }, 124 d2: BlurStyle.NONE 125}; 126 127function i(first, second) { 128 return Math.abs(first - second) < 0.001; 129} 130 131let SegmentButtonItemOptions = class SegmentButtonItemOptions { 132 constructor(options) { 133 this.icon = options.icon; 134 this.selectedIcon = options.selectedIcon; 135 this.text = options.text; 136 this.iconAccessibilityText = options.iconAccessibilityText; 137 this.selectedIconAccessibilityText = options.selectedIconAccessibilityText; 138 this.accessibilityLevel = options.accessibilityLevel; 139 this.accessibilityDescription = options.accessibilityDescription; 140 } 141}; 142SegmentButtonItemOptions = j([ 143 Observed 144], SegmentButtonItemOptions); 145let SegmentButtonItemOptionsArray = m = class SegmentButtonItemOptionsArray extends Array { 146 constructor(s3) { 147 super(typeof s3 === 'number' ? s3 : 0); 148 this.e2 = void 0; 149 this.deleteCount = void 0; 150 this.f2 = void 0; 151 if (typeof s3 !== 'number' && s3 !== void 0) { 152 super.push(...s3.map((element) => new SegmentButtonItemOptions(element))); 153 } 154 } 155 156 push(...items) { 157 if (this.length + items.length > a1) { 158 console.warn('Exceeded the maximum number of elements (5).'); 159 return this.length; 160 } 161 this.e2 = this.length; 162 this.deleteCount = 0; 163 this.f2 = items.length; 164 return super.push(...items.map((element) => new SegmentButtonItemOptions(element))); 165 } 166 167 pop() { 168 if (this.length <= u) { 169 console.warn('Below the minimum number of elements (2).'); 170 return void 0; 171 } 172 this.e2 = this.length - 1; 173 this.deleteCount = 1; 174 this.f2 = 0; 175 return super.pop(); 176 } 177 178 shift() { 179 if (this.length <= u) { 180 console.warn('Below the minimum number of elements (2).'); 181 return void 0; 182 } 183 this.e2 = 0; 184 this.deleteCount = 1; 185 this.f2 = 0; 186 return super.shift(); 187 } 188 189 unshift(...items) { 190 if (this.length + items.length > a1) { 191 console.warn('Exceeded the maximum number of elements (5).'); 192 return this.length; 193 } 194 if (items.length > 0) { 195 this.e2 = 0; 196 this.deleteCount = 0; 197 this.f2 = items.length; 198 } 199 return super.unshift(...items.map((element) => new SegmentButtonItemOptions(element))); 200 } 201 202 splice(start, deleteCount, ...items) { 203 let length = (this.length - deleteCount) < 0 ? 0 : (this.length - deleteCount); 204 length += items.length; 205 if (length < u) { 206 console.warn('Below the minimum number of elements (2).'); 207 return []; 208 } 209 if (length > a1) { 210 console.warn('Exceeded the maximum number of elements (5).'); 211 return []; 212 } 213 this.e2 = start; 214 this.deleteCount = deleteCount; 215 this.f2 = items.length; 216 return super.splice(start, deleteCount, ...items); 217 } 218 219 static create(elements) { 220 return new m(elements); 221 } 222}; 223SegmentButtonItemOptionsArray = m = j([ 224 Observed 225], SegmentButtonItemOptionsArray); 226 227export { SegmentButtonItemOptionsArray }; 228let SegmentButtonOptions = o = class SegmentButtonOptions { 229 get buttons() { 230 return this.g2; 231 } 232 233 set buttons(val) { 234 if (this.g2 !== void 0 && this.g2 !== val) { 235 this.h2?.(); 236 } 237 this.g2 = val; 238 } 239 240 constructor(options) { 241 this.multiply = false; 242 this.i2 = false; 243 this.showIcon = false; 244 this.g2 = void 0; 245 this.fontColor = options.fontColor ?? e1.q1; 246 this.selectedFontColor = options.selectedFontColor ?? e1.s1; 247 this.fontSize = options.fontSize ?? e1.u1; 248 this.selectedFontSize = options.selectedFontSize ?? e1.v1; 249 this.fontWeight = options.fontWeight ?? FontWeight.Regular; 250 this.selectedFontWeight = options.selectedFontWeight ?? FontWeight.Medium; 251 this.backgroundColor = options.backgroundColor ?? e1.BACKGROUND_COLOR; 252 this.selectedBackgroundColor = options.selectedBackgroundColor ?? e1.w1; 253 this.imageSize = options.imageSize ?? { width: 24, height: 24 }; 254 this.buttonPadding = options.buttonPadding; 255 this.textPadding = options.textPadding; 256 this.type = options.type; 257 this.backgroundBlurStyle = options.backgroundBlurStyle ?? e1.d2; 258 this.localizedTextPadding = options.localizedTextPadding; 259 this.localizedButtonPadding = options.localizedButtonPadding; 260 this.direction = options.direction ?? Direction.Auto; 261 this.buttons = new SegmentButtonItemOptionsArray(options.buttons); 262 if (this.type === 'capsule') { 263 this.multiply = options.multiply ?? false; 264 this.w3(); 265 this.selectedFontColor = options.selectedFontColor ?? e1.t1; 266 this.selectedBackgroundColor = options.selectedBackgroundColor ?? 267 e1.z1; 268 } else { 269 this.i2 = true; 270 } 271 this.m2 = this.multiply ? 0 : 2; 272 } 273 274 w3() { 275 this.buttons?.forEach(button => { 276 this.i2 ||= button.text !== void 0; 277 this.showIcon ||= button.icon !== void 0 || button.selectedIcon !== void 0; 278 }); 279 if (this.i2 && this.showIcon) { 280 this.j2 = 12; 281 this.l2 = 14; 282 } 283 } 284 285 static tab(options) { 286 return new o({ 287 type: 'tab', 288 buttons: options.buttons, 289 fontColor: options.fontColor, 290 selectedFontColor: options.selectedFontColor, 291 fontSize: options.fontSize, 292 selectedFontSize: options.selectedFontSize, 293 fontWeight: options.fontWeight, 294 selectedFontWeight: options.selectedFontWeight, 295 backgroundColor: options.backgroundColor, 296 selectedBackgroundColor: options.selectedBackgroundColor, 297 imageSize: options.imageSize, 298 buttonPadding: options.buttonPadding, 299 textPadding: options.textPadding, 300 localizedTextPadding: options.localizedTextPadding, 301 localizedButtonPadding: options.localizedButtonPadding, 302 backgroundBlurStyle: options.backgroundBlurStyle, 303 direction: options.direction 304 }); 305 } 306 307 static capsule(options) { 308 return new o({ 309 type: 'capsule', 310 buttons: options.buttons, 311 multiply: options.multiply, 312 fontColor: options.fontColor, 313 selectedFontColor: options.selectedFontColor, 314 fontSize: options.fontSize, 315 selectedFontSize: options.selectedFontSize, 316 fontWeight: options.fontWeight, 317 selectedFontWeight: options.selectedFontWeight, 318 backgroundColor: options.backgroundColor, 319 selectedBackgroundColor: options.selectedBackgroundColor, 320 imageSize: options.imageSize, 321 buttonPadding: options.buttonPadding, 322 textPadding: options.textPadding, 323 localizedTextPadding: options.localizedTextPadding, 324 localizedButtonPadding: options.localizedButtonPadding, 325 backgroundBlurStyle: options.backgroundBlurStyle, 326 direction: options.direction 327 }); 328 } 329}; 330SegmentButtonOptions = o = j([ 331 Observed 332], SegmentButtonOptions); 333 334export { SegmentButtonOptions }; 335 336class f1 extends ViewPU { 337 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 338 super(parent, __localStorage, elmtId, extraInfo); 339 if (typeof paramsLambda === "function") { 340 this.paramsGenerator_ = paramsLambda; 341 } 342 this.__optionsArray = new SynchedPropertyNesedObjectPU(params.optionsArray, this, "optionsArray"); 343 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 344 this.__buttonBorderRadius = this.initializeConsume("buttonBorderRadius", "buttonBorderRadius"); 345 this.__buttonItemsSize = this.initializeConsume("buttonItemsSize", "buttonItemsSize"); 346 this.setInitiallyProvidedValue(params); 347 this.finalizeConstruction(); 348 } 349 350 setInitiallyProvidedValue(params) { 351 this.__optionsArray.set(params.optionsArray); 352 this.__options.set(params.options); 353 } 354 355 updateStateVars(params) { 356 this.__optionsArray.set(params.optionsArray); 357 this.__options.set(params.options); 358 } 359 360 purgeVariableDependenciesOnElmtId(rmElmtId) { 361 this.__optionsArray.purgeDependencyOnElmtId(rmElmtId); 362 this.__options.purgeDependencyOnElmtId(rmElmtId); 363 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 364 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 365 } 366 367 aboutToBeDeleted() { 368 this.__optionsArray.aboutToBeDeleted(); 369 this.__options.aboutToBeDeleted(); 370 this.__buttonBorderRadius.aboutToBeDeleted(); 371 this.__buttonItemsSize.aboutToBeDeleted(); 372 SubscriberManager.Get().delete(this.id__()); 373 this.aboutToBeDeletedInternal(); 374 } 375 376 get optionsArray() { 377 return this.__optionsArray.get(); 378 } 379 380 get options() { 381 return this.__options.get(); 382 } 383 384 get buttonBorderRadius() { 385 return this.__buttonBorderRadius.get(); 386 } 387 388 set buttonBorderRadius(newValue) { 389 this.__buttonBorderRadius.set(newValue); 390 } 391 392 get buttonItemsSize() { 393 return this.__buttonItemsSize.get(); 394 } 395 396 set buttonItemsSize(newValue) { 397 this.__buttonItemsSize.set(newValue); 398 } 399 400 initialRender() { 401 this.observeComponentCreation2((elmtId, isInitialRender) => { 402 Row.create({ space: 1 }); 403 Row.direction(this.options.direction); 404 Row.padding(this.options.m2); 405 }, Row); 406 this.observeComponentCreation2((elmtId, isInitialRender) => { 407 ForEach.create(); 408 const forEachItemGenFunction = (_item, index) => { 409 const r3 = _item; 410 this.observeComponentCreation2((elmtId, isInitialRender) => { 411 If.create(); 412 if (index < a1) { 413 this.ifElseBranchUpdateFunction(0, () => { 414 this.observeComponentCreation2((elmtId, isInitialRender) => { 415 Stack.create(); 416 Stack.direction(this.options.direction); 417 Stack.layoutWeight(1); 418 Stack.height(this.buttonItemsSize[index].height); 419 Stack.backgroundColor(this.options.backgroundColor ?? e1.BACKGROUND_COLOR); 420 Stack.borderRadius(this.buttonBorderRadius[index]); 421 Stack.backgroundBlurStyle(this.options.backgroundBlurStyle); 422 }, Stack); 423 Stack.pop(); 424 }); 425 } else { 426 this.ifElseBranchUpdateFunction(1, () => { 427 }); 428 } 429 }, If); 430 If.pop(); 431 }; 432 this.forEachUpdateFunction(elmtId, this.optionsArray, forEachItemGenFunction, undefined, true, false); 433 }, ForEach); 434 ForEach.pop(); 435 Row.pop(); 436 } 437 438 rerender() { 439 this.updateDirtyElements(); 440 } 441} 442 443class g1 extends ViewPU { 444 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 445 super(parent, __localStorage, elmtId, extraInfo); 446 if (typeof paramsLambda === "function") { 447 this.paramsGenerator_ = paramsLambda; 448 } 449 this.__optionsArray = new SynchedPropertyNesedObjectPU(params.optionsArray, this, "optionsArray"); 450 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 451 this.__selectedIndexes = new SynchedPropertyObjectTwoWayPU(params.selectedIndexes, this, "selectedIndexes"); 452 this.__buttonItemsSize = this.initializeConsume("buttonItemsSize", "buttonItemsSize"); 453 this.__selectedItemPosition = this.initializeConsume("selectedItemPosition", "selectedItemPosition"); 454 this.__zoomScaleArray = this.initializeConsume("zoomScaleArray", "zoomScaleArray"); 455 this.__buttonBorderRadius = this.initializeConsume("buttonBorderRadius", "buttonBorderRadius"); 456 this.setInitiallyProvidedValue(params); 457 this.finalizeConstruction(); 458 } 459 460 setInitiallyProvidedValue(params) { 461 this.__optionsArray.set(params.optionsArray); 462 this.__options.set(params.options); 463 } 464 465 updateStateVars(params) { 466 this.__optionsArray.set(params.optionsArray); 467 this.__options.set(params.options); 468 } 469 470 purgeVariableDependenciesOnElmtId(rmElmtId) { 471 this.__optionsArray.purgeDependencyOnElmtId(rmElmtId); 472 this.__options.purgeDependencyOnElmtId(rmElmtId); 473 this.__selectedIndexes.purgeDependencyOnElmtId(rmElmtId); 474 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 475 this.__selectedItemPosition.purgeDependencyOnElmtId(rmElmtId); 476 this.__zoomScaleArray.purgeDependencyOnElmtId(rmElmtId); 477 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 478 } 479 480 aboutToBeDeleted() { 481 this.__optionsArray.aboutToBeDeleted(); 482 this.__options.aboutToBeDeleted(); 483 this.__selectedIndexes.aboutToBeDeleted(); 484 this.__buttonItemsSize.aboutToBeDeleted(); 485 this.__selectedItemPosition.aboutToBeDeleted(); 486 this.__zoomScaleArray.aboutToBeDeleted(); 487 this.__buttonBorderRadius.aboutToBeDeleted(); 488 SubscriberManager.Get().delete(this.id__()); 489 this.aboutToBeDeletedInternal(); 490 } 491 492 get optionsArray() { 493 return this.__optionsArray.get(); 494 } 495 496 get options() { 497 return this.__options.get(); 498 } 499 500 get selectedIndexes() { 501 return this.__selectedIndexes.get(); 502 } 503 504 set selectedIndexes(newValue) { 505 this.__selectedIndexes.set(newValue); 506 } 507 508 get buttonItemsSize() { 509 return this.__buttonItemsSize.get(); 510 } 511 512 set buttonItemsSize(newValue) { 513 this.__buttonItemsSize.set(newValue); 514 } 515 516 get selectedItemPosition() { 517 return this.__selectedItemPosition.get(); 518 } 519 520 set selectedItemPosition(newValue) { 521 this.__selectedItemPosition.set(newValue); 522 } 523 524 get zoomScaleArray() { 525 return this.__zoomScaleArray.get(); 526 } 527 528 set zoomScaleArray(newValue) { 529 this.__zoomScaleArray.set(newValue); 530 } 531 532 get buttonBorderRadius() { 533 return this.__buttonBorderRadius.get(); 534 } 535 536 set buttonBorderRadius(newValue) { 537 this.__buttonBorderRadius.set(newValue); 538 } 539 540 initialRender() { 541 this.observeComponentCreation2((elmtId, isInitialRender) => { 542 If.create(); 543 if (this.selectedIndexes !== void 0 && this.selectedIndexes.length !== 0) { 544 this.ifElseBranchUpdateFunction(0, () => { 545 this.observeComponentCreation2((elmtId, isInitialRender) => { 546 Stack.create(); 547 Stack.direction(this.options.direction); 548 Stack.borderRadius(this.buttonBorderRadius[this.selectedIndexes[0]]); 549 Stack.size(this.buttonItemsSize[this.selectedIndexes[0]]); 550 Stack.backgroundColor(this.options.selectedBackgroundColor ?? 551 (this.options.type === 'tab' ? e1.w1 : 552 e1.z1)); 553 Stack.position(ObservedObject.GetRawObject(this.selectedItemPosition)); 554 Stack.scale({ 555 x: this.zoomScaleArray[this.selectedIndexes[0]], 556 y: this.zoomScaleArray[this.selectedIndexes[0]] 557 }); 558 Stack.shadow(ShadowStyle.OUTER_DEFAULT_XS); 559 }, Stack); 560 Stack.pop(); 561 }); 562 } else { 563 this.ifElseBranchUpdateFunction(1, () => { 564 }); 565 } 566 }, If); 567 If.pop(); 568 } 569 570 rerender() { 571 this.updateDirtyElements(); 572 } 573} 574 575class h1 extends ViewPU { 576 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 577 super(parent, __localStorage, elmtId, extraInfo); 578 if (typeof paramsLambda === "function") { 579 this.paramsGenerator_ = paramsLambda; 580 } 581 this.__optionsArray = new SynchedPropertyNesedObjectPU(params.optionsArray, this, "optionsArray"); 582 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 583 this.__selectedIndexes = new SynchedPropertyObjectTwoWayPU(params.selectedIndexes, this, "selectedIndexes"); 584 this.__buttonItemsSize = this.initializeConsume("buttonItemsSize", "buttonItemsSize"); 585 this.__zoomScaleArray = this.initializeConsume("zoomScaleArray", "zoomScaleArray"); 586 this.__buttonBorderRadius = this.initializeConsume("buttonBorderRadius", "buttonBorderRadius"); 587 this.__multiColor = 588 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (q3, index) => Color.Transparent), this, 589 "multiColor"); 590 this.setInitiallyProvidedValue(params); 591 this.declareWatch("options", this.onOptionsChange); 592 this.declareWatch("selectedIndexes", this.onSelectedChange); 593 this.finalizeConstruction(); 594 } 595 596 setInitiallyProvidedValue(params) { 597 this.__optionsArray.set(params.optionsArray); 598 this.__options.set(params.options); 599 if (params.multiColor !== undefined) { 600 this.multiColor = params.multiColor; 601 } 602 } 603 604 updateStateVars(params) { 605 this.__optionsArray.set(params.optionsArray); 606 this.__options.set(params.options); 607 } 608 609 purgeVariableDependenciesOnElmtId(rmElmtId) { 610 this.__optionsArray.purgeDependencyOnElmtId(rmElmtId); 611 this.__options.purgeDependencyOnElmtId(rmElmtId); 612 this.__selectedIndexes.purgeDependencyOnElmtId(rmElmtId); 613 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 614 this.__zoomScaleArray.purgeDependencyOnElmtId(rmElmtId); 615 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 616 this.__multiColor.purgeDependencyOnElmtId(rmElmtId); 617 } 618 619 aboutToBeDeleted() { 620 this.__optionsArray.aboutToBeDeleted(); 621 this.__options.aboutToBeDeleted(); 622 this.__selectedIndexes.aboutToBeDeleted(); 623 this.__buttonItemsSize.aboutToBeDeleted(); 624 this.__zoomScaleArray.aboutToBeDeleted(); 625 this.__buttonBorderRadius.aboutToBeDeleted(); 626 this.__multiColor.aboutToBeDeleted(); 627 SubscriberManager.Get().delete(this.id__()); 628 this.aboutToBeDeletedInternal(); 629 } 630 631 get optionsArray() { 632 return this.__optionsArray.get(); 633 } 634 635 get options() { 636 return this.__options.get(); 637 } 638 639 get selectedIndexes() { 640 return this.__selectedIndexes.get(); 641 } 642 643 set selectedIndexes(newValue) { 644 this.__selectedIndexes.set(newValue); 645 } 646 647 get buttonItemsSize() { 648 return this.__buttonItemsSize.get(); 649 } 650 651 set buttonItemsSize(newValue) { 652 this.__buttonItemsSize.set(newValue); 653 } 654 655 get zoomScaleArray() { 656 return this.__zoomScaleArray.get(); 657 } 658 659 set zoomScaleArray(newValue) { 660 this.__zoomScaleArray.set(newValue); 661 } 662 663 get buttonBorderRadius() { 664 return this.__buttonBorderRadius.get(); 665 } 666 667 set buttonBorderRadius(newValue) { 668 this.__buttonBorderRadius.set(newValue); 669 } 670 671 get multiColor() { 672 return this.__multiColor.get(); 673 } 674 675 set multiColor(newValue) { 676 this.__multiColor.set(newValue); 677 } 678 679 onOptionsChange() { 680 for (let p3 = 0; p3 < this.selectedIndexes.length; p3++) { 681 this.multiColor[this.selectedIndexes[p3]] = this.options.selectedBackgroundColor ?? 682 e1.z1; 683 } 684 } 685 686 onSelectedChange() { 687 for (let n3 = 0; n3 < a1; n3++) { 688 this.multiColor[n3] = Color.Transparent; 689 } 690 for (let m3 = 0; m3 < this.selectedIndexes.length; m3++) { 691 this.multiColor[this.selectedIndexes[m3]] = this.options.selectedBackgroundColor ?? 692 e1.z1; 693 } 694 } 695 696 aboutToAppear() { 697 for (let l3 = 0; l3 < this.selectedIndexes.length; l3++) { 698 this.multiColor[this.selectedIndexes[l3]] = this.options.selectedBackgroundColor ?? 699 e1.z1; 700 } 701 } 702 703 initialRender() { 704 this.observeComponentCreation2((elmtId, isInitialRender) => { 705 Row.create({ space: 1 }); 706 Row.direction(this.options.direction); 707 Row.padding(this.options.m2); 708 }, Row); 709 this.observeComponentCreation2((elmtId, isInitialRender) => { 710 ForEach.create(); 711 const forEachItemGenFunction = (_item, index) => { 712 const k3 = _item; 713 this.observeComponentCreation2((elmtId, isInitialRender) => { 714 If.create(); 715 if (index < a1) { 716 this.ifElseBranchUpdateFunction(0, () => { 717 this.observeComponentCreation2((elmtId, isInitialRender) => { 718 Stack.create(); 719 Stack.direction(this.options.direction); 720 Stack.width(this.buttonItemsSize[index].width); 721 Stack.height(this.buttonItemsSize[index].height); 722 Stack.backgroundColor(this.multiColor[index]); 723 Stack.borderRadius(this.buttonBorderRadius[index]); 724 }, Stack); 725 Stack.pop(); 726 }); 727 } else { 728 this.ifElseBranchUpdateFunction(1, () => { 729 }); 730 } 731 }, If); 732 If.pop(); 733 }; 734 this.forEachUpdateFunction(elmtId, this.optionsArray, forEachItemGenFunction, undefined, true, false); 735 }, ForEach); 736 ForEach.pop(); 737 Row.pop(); 738 } 739 740 rerender() { 741 this.updateDirtyElements(); 742 } 743} 744 745class i1 extends ViewPU { 746 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 747 super(parent, __localStorage, elmtId, extraInfo); 748 if (typeof paramsLambda === "function") { 749 this.paramsGenerator_ = paramsLambda; 750 } 751 this.__selectedIndexes = new SynchedPropertyObjectTwoWayPU(params.selectedIndexes, this, "selectedIndexes"); 752 this.__focusIndex = new SynchedPropertySimpleTwoWayPU(params.focusIndex, this, "focusIndex"); 753 this.__maxFontScale = new SynchedPropertyObjectOneWayPU(params.maxFontScale, this, "maxFontScale"); 754 this.__itemOptions = new SynchedPropertyNesedObjectPU(params.itemOptions, this, "itemOptions"); 755 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 756 this.__property = new SynchedPropertyNesedObjectPU(params.property, this, "property"); 757 this.__index = new SynchedPropertySimpleOneWayPU(params.index, this, "index"); 758 this.groupId = ''; 759 this.setInitiallyProvidedValue(params); 760 this.finalizeConstruction(); 761 } 762 763 setInitiallyProvidedValue(params) { 764 this.__itemOptions.set(params.itemOptions); 765 this.__options.set(params.options); 766 this.__property.set(params.property); 767 if (params.groupId !== undefined) { 768 this.groupId = params.groupId; 769 } 770 } 771 772 updateStateVars(params) { 773 this.__maxFontScale.reset(params.maxFontScale); 774 this.__itemOptions.set(params.itemOptions); 775 this.__options.set(params.options); 776 this.__property.set(params.property); 777 this.__index.reset(params.index); 778 } 779 780 purgeVariableDependenciesOnElmtId(rmElmtId) { 781 this.__selectedIndexes.purgeDependencyOnElmtId(rmElmtId); 782 this.__focusIndex.purgeDependencyOnElmtId(rmElmtId); 783 this.__maxFontScale.purgeDependencyOnElmtId(rmElmtId); 784 this.__itemOptions.purgeDependencyOnElmtId(rmElmtId); 785 this.__options.purgeDependencyOnElmtId(rmElmtId); 786 this.__property.purgeDependencyOnElmtId(rmElmtId); 787 this.__index.purgeDependencyOnElmtId(rmElmtId); 788 } 789 790 aboutToBeDeleted() { 791 this.__selectedIndexes.aboutToBeDeleted(); 792 this.__focusIndex.aboutToBeDeleted(); 793 this.__maxFontScale.aboutToBeDeleted(); 794 this.__itemOptions.aboutToBeDeleted(); 795 this.__options.aboutToBeDeleted(); 796 this.__property.aboutToBeDeleted(); 797 this.__index.aboutToBeDeleted(); 798 SubscriberManager.Get().delete(this.id__()); 799 this.aboutToBeDeletedInternal(); 800 } 801 802 get selectedIndexes() { 803 return this.__selectedIndexes.get(); 804 } 805 806 set selectedIndexes(newValue) { 807 this.__selectedIndexes.set(newValue); 808 } 809 810 get focusIndex() { 811 return this.__focusIndex.get(); 812 } 813 814 set focusIndex(newValue) { 815 this.__focusIndex.set(newValue); 816 } 817 818 get maxFontScale() { 819 return this.__maxFontScale.get(); 820 } 821 822 set maxFontScale(newValue) { 823 this.__maxFontScale.set(newValue); 824 } 825 826 get itemOptions() { 827 return this.__itemOptions.get(); 828 } 829 830 get options() { 831 return this.__options.get(); 832 } 833 834 get property() { 835 return this.__property.get(); 836 } 837 838 get index() { 839 return this.__index.get(); 840 } 841 842 set index(newValue) { 843 this.__index.set(newValue); 844 } 845 846 getTextPadding() { 847 if (this.options.localizedTextPadding) { 848 return this.options.localizedTextPadding; 849 } 850 if (this.options.textPadding !== void (0)) { 851 return this.options.textPadding; 852 } 853 return 0; 854 } 855 856 getButtonPadding() { 857 if (this.options.localizedButtonPadding) { 858 return this.options.localizedButtonPadding; 859 } 860 if (this.options.buttonPadding !== void (0)) { 861 return this.options.buttonPadding; 862 } 863 if (this.options.type === 'capsule' && this.options.i2 && this.options.showIcon) { 864 return { 865 top: LengthMetrics.vp(6), 866 bottom: LengthMetrics.vp(6), 867 start: LengthMetrics.vp(8), 868 end: LengthMetrics.vp(8) 869 }; 870 } 871 return { 872 top: LengthMetrics.vp(4), 873 bottom: LengthMetrics.vp(4), 874 start: LengthMetrics.vp(8), 875 end: LengthMetrics.vp(8) 876 }; 877 } 878 879 getAccessibilityText() { 880 try { 881 if (this.selectedIndexes.includes(this.index) && this.itemOptions.selectedIconAccessibilityText) { 882 return (typeof this.itemOptions.selectedIconAccessibilityText === 'string') ? 883 this.itemOptions.selectedIconAccessibilityText : 884 getContext(this).resourceManager.getStringSync(this.itemOptions.selectedIconAccessibilityText.id); 885 } else if (this.itemOptions.iconAccessibilityText) { 886 return (typeof this.itemOptions.iconAccessibilityText === 'string') ? 887 this.itemOptions.iconAccessibilityText : 888 getContext(this).resourceManager.getStringSync(this.itemOptions.iconAccessibilityText.id); 889 } 890 } catch (error) { 891 console.error(`Ace SegmentButton getAccessibilityText, error: ${error.toString()}`); 892 } 893 return ''; 894 } 895 896 initialRender() { 897 this.observeComponentCreation2((elmtId, isInitialRender) => { 898 Column.create({ space: 2 }); 899 Column.direction(this.options.direction); 900 Column.focusScopePriority(this.groupId, 901 Math.min(...this.selectedIndexes) === this.index ? FocusPriority.PREVIOUS : FocusPriority.AUTO); 902 Column.justifyContent(FlexAlign.Center); 903 Column.padding(this.getButtonPadding()); 904 Column.constraintSize({ minHeight: 28 }); 905 }, Column); 906 this.observeComponentCreation2((elmtId, isInitialRender) => { 907 If.create(); 908 if (this.options.showIcon) { 909 this.ifElseBranchUpdateFunction(0, () => { 910 this.observeComponentCreation2((elmtId, isInitialRender) => { 911 Image.create(this.property.isSelected ? this.itemOptions.selectedIcon : this.itemOptions.icon); 912 Image.direction(this.options.direction); 913 Image.size(this.options.imageSize ?? { width: 24, height: 24 }); 914 Image.focusable(!this.options.i2); 915 Image.draggable(false); 916 Image.fillColor(this.property.isSelected ? (this.options.selectedFontColor ?? 917 e1.t1) : (this.options.fontColor ?? 918 e1.q1)); 919 Image.accessibilityText(this.getAccessibilityText()); 920 }, Image); 921 }); 922 } else { 923 this.ifElseBranchUpdateFunction(1, () => { 924 }); 925 } 926 }, If); 927 If.pop(); 928 this.observeComponentCreation2((elmtId, isInitialRender) => { 929 If.create(); 930 if (this.options.i2) { 931 this.ifElseBranchUpdateFunction(0, () => { 932 this.observeComponentCreation2((elmtId, isInitialRender) => { 933 Text.create(this.itemOptions.text); 934 Text.direction(this.options.direction); 935 Text.fontColor(this.property.fontColor); 936 Text.fontWeight(this.property.fontWeight); 937 Text.fontSize(this.property.fontSize); 938 Text.minFontSize(9); 939 Text.maxFontSize(this.property.fontSize); 940 Text.maxFontScale(ObservedObject.GetRawObject(this.maxFontScale)); 941 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 942 Text.maxLines(1); 943 Text.textAlign(TextAlign.Center); 944 Text.focusable(true); 945 Text.padding(this.getTextPadding()); 946 }, Text); 947 Text.pop(); 948 }); 949 } else { 950 this.ifElseBranchUpdateFunction(1, () => { 951 }); 952 } 953 }, If); 954 If.pop(); 955 Column.pop(); 956 } 957 958 rerender() { 959 this.updateDirtyElements(); 960 } 961} 962 963let j1 = class HoverColorProperty { 964 constructor() { 965 this.e3 = Color.Transparent; 966 } 967}; 968j1 = j([ 969 Observed 970], j1); 971 972class l1 extends ViewPU { 973 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 974 super(parent, __localStorage, elmtId, extraInfo); 975 if (typeof paramsLambda === "function") { 976 this.paramsGenerator_ = paramsLambda; 977 } 978 this.__buttonItemsSize = this.initializeConsume("buttonItemsSize", "buttonItemsSize"); 979 this.__press = new SynchedPropertySimpleOneWayPU(params.press, this, "press"); 980 this.__hover = new SynchedPropertySimpleOneWayPU(params.hover, this, "hover"); 981 this.__colorProperty = new SynchedPropertyNesedObjectPU(params.colorProperty, this, "colorProperty"); 982 this.__buttonBorderRadius = this.initializeConsume("buttonBorderRadius", "buttonBorderRadius"); 983 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 984 this.pressIndex = 0; 985 this.pressColor = e1.c2; 986 this.setInitiallyProvidedValue(params); 987 this.finalizeConstruction(); 988 } 989 990 setInitiallyProvidedValue(params) { 991 this.__colorProperty.set(params.colorProperty); 992 this.__options.set(params.options); 993 if (params.pressIndex !== undefined) { 994 this.pressIndex = params.pressIndex; 995 } 996 if (params.pressColor !== undefined) { 997 this.pressColor = params.pressColor; 998 } 999 } 1000 1001 updateStateVars(params) { 1002 this.__press.reset(params.press); 1003 this.__hover.reset(params.hover); 1004 this.__colorProperty.set(params.colorProperty); 1005 this.__options.set(params.options); 1006 } 1007 1008 purgeVariableDependenciesOnElmtId(rmElmtId) { 1009 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 1010 this.__press.purgeDependencyOnElmtId(rmElmtId); 1011 this.__hover.purgeDependencyOnElmtId(rmElmtId); 1012 this.__colorProperty.purgeDependencyOnElmtId(rmElmtId); 1013 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 1014 this.__options.purgeDependencyOnElmtId(rmElmtId); 1015 } 1016 1017 aboutToBeDeleted() { 1018 this.__buttonItemsSize.aboutToBeDeleted(); 1019 this.__press.aboutToBeDeleted(); 1020 this.__hover.aboutToBeDeleted(); 1021 this.__colorProperty.aboutToBeDeleted(); 1022 this.__buttonBorderRadius.aboutToBeDeleted(); 1023 this.__options.aboutToBeDeleted(); 1024 SubscriberManager.Get().delete(this.id__()); 1025 this.aboutToBeDeletedInternal(); 1026 } 1027 1028 get buttonItemsSize() { 1029 return this.__buttonItemsSize.get(); 1030 } 1031 1032 set buttonItemsSize(newValue) { 1033 this.__buttonItemsSize.set(newValue); 1034 } 1035 1036 get press() { 1037 return this.__press.get(); 1038 } 1039 1040 set press(newValue) { 1041 this.__press.set(newValue); 1042 } 1043 1044 get hover() { 1045 return this.__hover.get(); 1046 } 1047 1048 set hover(newValue) { 1049 this.__hover.set(newValue); 1050 } 1051 1052 get colorProperty() { 1053 return this.__colorProperty.get(); 1054 } 1055 1056 get buttonBorderRadius() { 1057 return this.__buttonBorderRadius.get(); 1058 } 1059 1060 set buttonBorderRadius(newValue) { 1061 this.__buttonBorderRadius.set(newValue); 1062 } 1063 1064 get options() { 1065 return this.__options.get(); 1066 } 1067 1068 initialRender() { 1069 this.observeComponentCreation2((elmtId, isInitialRender) => { 1070 Stack.create(); 1071 Stack.direction(this.options.direction); 1072 Stack.size(this.buttonItemsSize[this.pressIndex]); 1073 Stack.backgroundColor(this.press && this.hover ? this.pressColor : this.colorProperty.e3); 1074 Stack.borderRadius(this.buttonBorderRadius[this.pressIndex]); 1075 }, Stack); 1076 Stack.pop(); 1077 } 1078 1079 rerender() { 1080 this.updateDirtyElements(); 1081 } 1082} 1083 1084class m1 extends ViewPU { 1085 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 1086 super(parent, __localStorage, elmtId, extraInfo); 1087 if (typeof paramsLambda === "function") { 1088 this.paramsGenerator_ = paramsLambda; 1089 } 1090 this.__optionsArray = new SynchedPropertyNesedObjectPU(params.optionsArray, this, "optionsArray"); 1091 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 1092 this.__selectedIndexes = new SynchedPropertyObjectTwoWayPU(params.selectedIndexes, this, "selectedIndexes"); 1093 this.__componentSize = this.initializeConsume("componentSize", "componentSize"); 1094 this.__buttonBorderRadius = this.initializeConsume("buttonBorderRadius", "buttonBorderRadius"); 1095 this.__buttonItemsSize = this.initializeConsume("buttonItemsSize", "buttonItemsSize"); 1096 this.__buttonItemsPosition = this.initializeConsume("buttonItemsPosition", "buttonItemsPosition"); 1097 this.__focusIndex = this.initializeConsume("focusIndex", "focusIndex"); 1098 this.__zoomScaleArray = this.initializeConsume("zoomScaleArray", "zoomScaleArray"); 1099 this.__buttonItemProperty = this.initializeConsume("buttonItemProperty", "buttonItemProperty"); 1100 this.__buttonItemsSelected = this.initializeConsume("buttonItemsSelected", "buttonItemsSelected"); 1101 this.__pressArray = new SynchedPropertyObjectTwoWayPU(params.pressArray, this, "pressArray"); 1102 this.__hoverArray = new SynchedPropertyObjectTwoWayPU(params.hoverArray, this, "hoverArray"); 1103 this.__hoverColorArray = new SynchedPropertyObjectTwoWayPU(params.hoverColorArray, this, "hoverColorArray"); 1104 this.__maxFontScale = new SynchedPropertyObjectOneWayPU(params.maxFontScale, this, "maxFontScale"); 1105 this.__buttonWidth = 1106 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (j3, index) => 0), this, "buttonWidth"); 1107 this.__buttonHeight = 1108 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (i3, index) => 0), this, "buttonHeight"); 1109 this.buttonItemsRealHeight = Array.from({ length: a1 }, (h3, index) => 0); 1110 this.groupId = util.generateRandomUUID(true); 1111 this.setInitiallyProvidedValue(params); 1112 this.declareWatch("optionsArray", this.onOptionsArrayChange); 1113 this.declareWatch("options", this.onOptionsChange); 1114 this.declareWatch("buttonItemsSize", this.onButtonItemsSizeChange); 1115 this.finalizeConstruction(); 1116 } 1117 1118 setInitiallyProvidedValue(params) { 1119 this.__optionsArray.set(params.optionsArray); 1120 this.__options.set(params.options); 1121 if (params.buttonWidth !== undefined) { 1122 this.buttonWidth = params.buttonWidth; 1123 } 1124 if (params.buttonHeight !== undefined) { 1125 this.buttonHeight = params.buttonHeight; 1126 } 1127 if (params.buttonItemsRealHeight !== undefined) { 1128 this.buttonItemsRealHeight = params.buttonItemsRealHeight; 1129 } 1130 if (params.groupId !== undefined) { 1131 this.groupId = params.groupId; 1132 } 1133 } 1134 1135 updateStateVars(params) { 1136 this.__optionsArray.set(params.optionsArray); 1137 this.__options.set(params.options); 1138 this.__maxFontScale.reset(params.maxFontScale); 1139 } 1140 1141 purgeVariableDependenciesOnElmtId(rmElmtId) { 1142 this.__optionsArray.purgeDependencyOnElmtId(rmElmtId); 1143 this.__options.purgeDependencyOnElmtId(rmElmtId); 1144 this.__selectedIndexes.purgeDependencyOnElmtId(rmElmtId); 1145 this.__componentSize.purgeDependencyOnElmtId(rmElmtId); 1146 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 1147 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 1148 this.__buttonItemsPosition.purgeDependencyOnElmtId(rmElmtId); 1149 this.__focusIndex.purgeDependencyOnElmtId(rmElmtId); 1150 this.__zoomScaleArray.purgeDependencyOnElmtId(rmElmtId); 1151 this.__buttonItemProperty.purgeDependencyOnElmtId(rmElmtId); 1152 this.__buttonItemsSelected.purgeDependencyOnElmtId(rmElmtId); 1153 this.__pressArray.purgeDependencyOnElmtId(rmElmtId); 1154 this.__hoverArray.purgeDependencyOnElmtId(rmElmtId); 1155 this.__hoverColorArray.purgeDependencyOnElmtId(rmElmtId); 1156 this.__maxFontScale.purgeDependencyOnElmtId(rmElmtId); 1157 this.__buttonWidth.purgeDependencyOnElmtId(rmElmtId); 1158 this.__buttonHeight.purgeDependencyOnElmtId(rmElmtId); 1159 } 1160 1161 aboutToBeDeleted() { 1162 this.__optionsArray.aboutToBeDeleted(); 1163 this.__options.aboutToBeDeleted(); 1164 this.__selectedIndexes.aboutToBeDeleted(); 1165 this.__componentSize.aboutToBeDeleted(); 1166 this.__buttonBorderRadius.aboutToBeDeleted(); 1167 this.__buttonItemsSize.aboutToBeDeleted(); 1168 this.__buttonItemsPosition.aboutToBeDeleted(); 1169 this.__focusIndex.aboutToBeDeleted(); 1170 this.__zoomScaleArray.aboutToBeDeleted(); 1171 this.__buttonItemProperty.aboutToBeDeleted(); 1172 this.__buttonItemsSelected.aboutToBeDeleted(); 1173 this.__pressArray.aboutToBeDeleted(); 1174 this.__hoverArray.aboutToBeDeleted(); 1175 this.__hoverColorArray.aboutToBeDeleted(); 1176 this.__maxFontScale.aboutToBeDeleted(); 1177 this.__buttonWidth.aboutToBeDeleted(); 1178 this.__buttonHeight.aboutToBeDeleted(); 1179 SubscriberManager.Get().delete(this.id__()); 1180 this.aboutToBeDeletedInternal(); 1181 } 1182 1183 get optionsArray() { 1184 return this.__optionsArray.get(); 1185 } 1186 1187 get options() { 1188 return this.__options.get(); 1189 } 1190 1191 get selectedIndexes() { 1192 return this.__selectedIndexes.get(); 1193 } 1194 1195 set selectedIndexes(newValue) { 1196 this.__selectedIndexes.set(newValue); 1197 } 1198 1199 get componentSize() { 1200 return this.__componentSize.get(); 1201 } 1202 1203 set componentSize(newValue) { 1204 this.__componentSize.set(newValue); 1205 } 1206 1207 get buttonBorderRadius() { 1208 return this.__buttonBorderRadius.get(); 1209 } 1210 1211 set buttonBorderRadius(newValue) { 1212 this.__buttonBorderRadius.set(newValue); 1213 } 1214 1215 get buttonItemsSize() { 1216 return this.__buttonItemsSize.get(); 1217 } 1218 1219 set buttonItemsSize(newValue) { 1220 this.__buttonItemsSize.set(newValue); 1221 } 1222 1223 get buttonItemsPosition() { 1224 return this.__buttonItemsPosition.get(); 1225 } 1226 1227 set buttonItemsPosition(newValue) { 1228 this.__buttonItemsPosition.set(newValue); 1229 } 1230 1231 get focusIndex() { 1232 return this.__focusIndex.get(); 1233 } 1234 1235 set focusIndex(newValue) { 1236 this.__focusIndex.set(newValue); 1237 } 1238 1239 get zoomScaleArray() { 1240 return this.__zoomScaleArray.get(); 1241 } 1242 1243 set zoomScaleArray(newValue) { 1244 this.__zoomScaleArray.set(newValue); 1245 } 1246 1247 get buttonItemProperty() { 1248 return this.__buttonItemProperty.get(); 1249 } 1250 1251 set buttonItemProperty(newValue) { 1252 this.__buttonItemProperty.set(newValue); 1253 } 1254 1255 get buttonItemsSelected() { 1256 return this.__buttonItemsSelected.get(); 1257 } 1258 1259 set buttonItemsSelected(newValue) { 1260 this.__buttonItemsSelected.set(newValue); 1261 } 1262 1263 get pressArray() { 1264 return this.__pressArray.get(); 1265 } 1266 1267 set pressArray(newValue) { 1268 this.__pressArray.set(newValue); 1269 } 1270 1271 get hoverArray() { 1272 return this.__hoverArray.get(); 1273 } 1274 1275 set hoverArray(newValue) { 1276 this.__hoverArray.set(newValue); 1277 } 1278 1279 get hoverColorArray() { 1280 return this.__hoverColorArray.get(); 1281 } 1282 1283 set hoverColorArray(newValue) { 1284 this.__hoverColorArray.set(newValue); 1285 } 1286 1287 get maxFontScale() { 1288 return this.__maxFontScale.get(); 1289 } 1290 1291 set maxFontScale(newValue) { 1292 this.__maxFontScale.set(newValue); 1293 } 1294 1295 get buttonWidth() { 1296 return this.__buttonWidth.get(); 1297 } 1298 1299 set buttonWidth(newValue) { 1300 this.__buttonWidth.set(newValue); 1301 } 1302 1303 get buttonHeight() { 1304 return this.__buttonHeight.get(); 1305 } 1306 1307 set buttonHeight(newValue) { 1308 this.__buttonHeight.set(newValue); 1309 } 1310 1311 onButtonItemsSizeChange() { 1312 this.buttonItemsSize.forEach((value, index) => { 1313 this.buttonWidth[index] = value.width; 1314 this.buttonHeight[index] = value.height; 1315 }); 1316 } 1317 1318 changeSelectedIndexes(c3) { 1319 if (this.optionsArray.e2 === void 0 || this.optionsArray.deleteCount === void 0 || 1320 this.optionsArray.f2 === void 0) { 1321 return; 1322 } 1323 if (!(this.options.multiply ?? false)) { 1324 if (this.selectedIndexes[0] === void 0) { 1325 return; 1326 } 1327 if (this.selectedIndexes[0] < this.optionsArray.e2) { 1328 return; 1329 } 1330 if (this.optionsArray.e2 + this.optionsArray.deleteCount > this.selectedIndexes[0]) { 1331 if (this.options.type === 'tab') { 1332 this.selectedIndexes[0] = 0; 1333 } else if (this.options.type === 'capsule') { 1334 this.selectedIndexes = []; 1335 } 1336 } else { 1337 this.selectedIndexes[0] = 1338 this.selectedIndexes[0] - this.optionsArray.deleteCount + this.optionsArray.f2; 1339 } 1340 } else { 1341 let d3 = this.selectedIndexes; 1342 for (let f3 = 0; f3 < this.optionsArray.deleteCount; f3++) { 1343 let g3 = d3.indexOf(this.optionsArray.e2); 1344 let indexes = d3.map(value => this.optionsArray.e2 && 1345 (value > this.optionsArray.e2) ? value - 1 : value); 1346 if (g3 !== -1) { 1347 indexes.splice(g3, 1); 1348 } 1349 d3 = indexes; 1350 } 1351 for (let e3 = 0; e3 < this.optionsArray.f2; e3++) { 1352 let indexes = d3.map(value => this.optionsArray.e2 && 1353 (value >= this.optionsArray.e2) ? value + 1 : value); 1354 d3 = indexes; 1355 } 1356 this.selectedIndexes = d3; 1357 } 1358 } 1359 1360 changeFocusIndex(b3) { 1361 if (this.optionsArray.e2 === void 0 || this.optionsArray.deleteCount === void 0 || 1362 this.optionsArray.f2 === void 0) { 1363 return; 1364 } 1365 if (this.focusIndex === -1) { 1366 return; 1367 } 1368 if (this.focusIndex < this.optionsArray.e2) { 1369 return; 1370 } 1371 if (this.optionsArray.e2 + this.optionsArray.deleteCount > this.focusIndex) { 1372 this.focusIndex = 0; 1373 } else { 1374 this.focusIndex = this.focusIndex - this.optionsArray.deleteCount + this.optionsArray.f2; 1375 } 1376 } 1377 1378 onOptionsArrayChange() { 1379 if (this.options === void 0 || this.options.buttons === void 0) { 1380 return; 1381 } 1382 let a3 = Math.min(this.options.buttons.length, this.buttonItemsSize.length); 1383 if (this.optionsArray.e2 !== void 0 && this.optionsArray.deleteCount !== void 0 && 1384 this.optionsArray.f2 !== void 0) { 1385 this.changeSelectedIndexes(a3); 1386 this.changeFocusIndex(a3); 1387 this.optionsArray.e2 = void 0; 1388 this.optionsArray.deleteCount = void 0; 1389 this.optionsArray.f2 = void 0; 1390 } 1391 } 1392 1393 onOptionsChange() { 1394 if (this.options === void 0 || this.options.buttons === void 0) { 1395 return; 1396 } 1397 this.calculateBorderRadius(); 1398 } 1399 1400 aboutToAppear() { 1401 for (let index = 0; index < this.buttonItemsRealHeight.length; index++) { 1402 this.buttonItemsRealHeight[index] = 0; 1403 } 1404 } 1405 1406 getBorderRadius(index) { 1407 let borderRadius = this.buttonBorderRadius[index]; 1408 if (this.options.type === 'capsule' && this.buttonItemsSelected[this.focusIndex]) { 1409 borderRadius.topStart = LengthMetrics.vp((borderRadius.topStart?.value ?? 0) + 4); 1410 borderRadius.topEnd = LengthMetrics.vp((borderRadius.topEnd?.value ?? 0) + 4); 1411 borderRadius.bottomStart = LengthMetrics.vp((borderRadius.bottomStart?.value ?? 0) + 4); 1412 borderRadius.bottomEnd = LengthMetrics.vp((borderRadius.bottomEnd?.value ?? 0) + 4); 1413 } 1414 return borderRadius; 1415 } 1416 1417 focusStack(index, parent = null) { 1418 this.observeComponentCreation2((elmtId, isInitialRender) => { 1419 Stack.create(); 1420 Stack.direction(this.options.direction); 1421 Stack.size({ width: 1, height: 1 }); 1422 Stack.align(Alignment.Center); 1423 }, Stack); 1424 this.observeComponentCreation2((elmtId, isInitialRender) => { 1425 Stack.create(); 1426 Stack.direction(this.options.direction); 1427 Stack.borderRadius(this.getBorderRadius(index)); 1428 Stack.size({ 1429 width: this.options.type === 'capsule' && this.buttonItemsSelected[this.focusIndex] ? 1430 this.buttonWidth[index] + 8 : this.buttonWidth[index], 1431 height: this.options.type === 'capsule' && this.buttonItemsSelected[this.focusIndex] ? 1432 this.buttonHeight[index] + 8 : this.buttonHeight[index] 1433 }); 1434 Stack.borderColor(e1.a2); 1435 Stack.borderWidth(2); 1436 }, Stack); 1437 Stack.pop(); 1438 Stack.pop(); 1439 } 1440 1441 calculateBorderRadius() { 1442 let v2 = Array.from({ 1443 length: a1 1444 }, (z2, index) => { 1445 return { 1446 topStart: LengthMetrics.vp(0), 1447 topEnd: LengthMetrics.vp(0), 1448 bottomStart: LengthMetrics.vp(0), 1449 bottomEnd: LengthMetrics.vp(0) 1450 }; 1451 }); 1452 for (let index = 0; index < this.buttonBorderRadius.length; index++) { 1453 let w2 = this.buttonItemsSize[index].height / 2; 1454 if (this.options.type === 'tab' || !(this.options.multiply ?? false)) { 1455 v2[index].topStart = LengthMetrics.vp(this.options.j2 ?? w2); 1456 v2[index].topEnd = LengthMetrics.vp(this.options.j2 ?? w2); 1457 v2[index].bottomStart = LengthMetrics.vp(this.options.j2 ?? w2); 1458 v2[index].bottomEnd = LengthMetrics.vp(this.options.j2 ?? w2); 1459 } else { 1460 if (index === 0) { 1461 v2[index].topStart = LengthMetrics.vp(this.options.j2 ?? w2); 1462 v2[index].topEnd = LengthMetrics.vp(0); 1463 v2[index].bottomStart = LengthMetrics.vp(this.options.j2 ?? w2); 1464 v2[index].bottomEnd = LengthMetrics.vp(0); 1465 } else if (this.options.buttons && 1466 index === Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) { 1467 v2[index].topStart = LengthMetrics.vp(0); 1468 v2[index].topEnd = LengthMetrics.vp(this.options.j2 ?? w2); 1469 v2[index].bottomStart = LengthMetrics.vp(0); 1470 v2[index].bottomEnd = LengthMetrics.vp(this.options.j2 ?? w2); 1471 } else { 1472 v2[index].topStart = LengthMetrics.vp(0); 1473 v2[index].topEnd = LengthMetrics.vp(0); 1474 v2[index].bottomStart = LengthMetrics.vp(0); 1475 v2[index].bottomEnd = LengthMetrics.vp(0); 1476 } 1477 } 1478 } 1479 this.buttonBorderRadius = v2; 1480 } 1481 1482 getAccessibilityDescription(value) { 1483 if (value) { 1484 try { 1485 return (typeof value === 'string') ? value : 1486 getContext(this).resourceManager.getStringSync(value.id); 1487 } catch (error) { 1488 console.error(`Ace SegmentButton getAccessibilityDescription, error: ${error.toString()}`); 1489 } 1490 } 1491 return ''; 1492 } 1493 1494 initialRender() { 1495 this.observeComponentCreation2((elmtId, isInitialRender) => { 1496 If.create(); 1497 if (this.optionsArray !== void 0 && this.optionsArray.length > 1) { 1498 this.ifElseBranchUpdateFunction(0, () => { 1499 this.observeComponentCreation2((elmtId, isInitialRender) => { 1500 Row.create({ space: 1 }); 1501 Row.direction(this.options.direction); 1502 Row.focusScopeId(this.groupId, true); 1503 Row.padding(this.options.m2); 1504 Row.onSizeChange((u2, newValue) => { 1505 this.componentSize = { width: newValue.width, height: newValue.height }; 1506 }); 1507 }, Row); 1508 this.observeComponentCreation2((elmtId, isInitialRender) => { 1509 ForEach.create(); 1510 const forEachItemGenFunction = (_item, index) => { 1511 const item = _item; 1512 this.observeComponentCreation2((elmtId, isInitialRender) => { 1513 If.create(); 1514 if (index < a1) { 1515 this.ifElseBranchUpdateFunction(0, () => { 1516 this.observeComponentCreation2((elmtId, isInitialRender) => { 1517 Button.createWithChild(); 1518 Button.type(ButtonType.Normal); 1519 Button.stateEffect(false); 1520 Button.hoverEffect(HoverEffect.None); 1521 Button.backgroundColor(Color.Transparent); 1522 Button.accessibilityLevel(item.accessibilityLevel); 1523 Button.accessibilitySelected(this.options.multiply ? undefined : 1524 this.selectedIndexes.includes(index)); 1525 Button.accessibilityChecked(this.options.multiply ? 1526 this.selectedIndexes.includes(index) : undefined); 1527 Button.accessibilityDescription(this.getAccessibilityDescription(item.accessibilityDescription)); 1528 Button.direction(this.options.direction); 1529 Button.borderRadius(this.buttonBorderRadius[index]); 1530 Button.scale({ 1531 x: this.options.type === 'capsule' && (this.options.multiply ?? false) ? 1532 1 : this.zoomScaleArray[index], 1533 y: this.options.type === 'capsule' && (this.options.multiply ?? false) ? 1534 1 : this.zoomScaleArray[index] 1535 }); 1536 Button.layoutWeight(1); 1537 Button.padding(0); 1538 Button.onSizeChange((t2, newValue) => { 1539 this.buttonItemsSize[index] = { 1540 width: newValue.width, 1541 height: this.buttonItemsSize[index].height 1542 }; 1543 if (newValue.width) { 1544 this.buttonItemsPosition[index] = { 1545 start: LengthMetrics.vp(Number.parseFloat(this.options.m2.toString()) + 1546 (Number.parseFloat(newValue.width.toString()) + 1) * index), 1547 top: LengthMetrics.px(Math.floor(this.getUIContext() 1548 .vp2px(Number.parseFloat(this.options.m2.toString())))) 1549 }; 1550 } 1551 }); 1552 ViewStackProcessor.visualState("normal"); 1553 Button.overlay(undefined); 1554 ViewStackProcessor.visualState("focused"); 1555 Button.overlay({ 1556 builder: () => { 1557 this.focusStack.call(this, index); 1558 } 1559 }, { 1560 align: Alignment.Center 1561 }); 1562 ViewStackProcessor.visualState(); 1563 Button.onFocus(() => { 1564 this.focusIndex = index; 1565 }); 1566 Gesture.create(GesturePriority.Low); 1567 TapGesture.create(); 1568 TapGesture.onAction(() => { 1569 if (this.options.type === 'capsule' && 1570 (this.options.multiply ?? false)) { 1571 if (this.selectedIndexes.indexOf(index) === -1) { 1572 this.selectedIndexes.push(index); 1573 } else { 1574 this.selectedIndexes.splice(this.selectedIndexes.indexOf(index), 1575 1); 1576 } 1577 } else { 1578 this.selectedIndexes[0] = index; 1579 } 1580 }); 1581 TapGesture.pop(); 1582 Gesture.pop(); 1583 Button.onTouch((event) => { 1584 if (event.source !== SourceType.TouchScreen) { 1585 return; 1586 } 1587 if (event.type === TouchType.Down) { 1588 Context.animateTo({ 1589 curve: curves.interpolatingSpring(10, 1, 410, 38) 1590 }, () => { 1591 this.zoomScaleArray[index] = 0.95; 1592 }); 1593 } else if (event.type === TouchType.Up) { 1594 Context.animateTo({ 1595 curve: curves.interpolatingSpring(10, 1, 410, 38) 1596 }, () => { 1597 this.zoomScaleArray[index] = 1; 1598 }); 1599 } 1600 }); 1601 Button.onHover((isHover) => { 1602 this.hoverArray[index] = isHover; 1603 if (isHover) { 1604 Context.animateTo({ duration: 250, curve: Curve.Friction }, () => { 1605 this.hoverColorArray[index].e3 = (e1.b2); 1606 }); 1607 } else { 1608 Context.animateTo({ duration: 250, curve: Curve.Friction }, () => { 1609 this.hoverColorArray[index].e3 = Color.Transparent; 1610 }); 1611 } 1612 }); 1613 Button.onMouse((event) => { 1614 switch (event.action) { 1615 case MouseAction.Press: 1616 Context.animateTo({ curve: curves.springMotion(0.347, 0.99) }, 1617 () => { 1618 this.zoomScaleArray[index] = 0.95; 1619 }); 1620 Context.animateTo({ duration: 100, curve: Curve.Sharp }, () => { 1621 this.pressArray[index] = true; 1622 }); 1623 break; 1624 case MouseAction.Release: 1625 Context.animateTo({ curve: curves.springMotion(0.347, 0.99) }, 1626 () => { 1627 this.zoomScaleArray[index] = 1; 1628 }); 1629 Context.animateTo({ duration: 100, curve: Curve.Sharp }, () => { 1630 this.pressArray[index] = false; 1631 }); 1632 break; 1633 } 1634 }); 1635 }, Button); 1636 this.observeComponentCreation2((elmtId, isInitialRender) => { 1637 __Common__.create(); 1638 __Common__.onSizeChange((s2, newValue) => { 1639 this.buttonItemsRealHeight[index] = newValue.height; 1640 let maxHeight = Math.max(...this.buttonItemsRealHeight.slice(0, 1641 this.options.buttons ? 1642 this.options.buttons.length : 0)); 1643 for (let index = 0; index < this.buttonItemsSize.length; index++) { 1644 this.buttonItemsSize[index] = 1645 { width: this.buttonItemsSize[index].width, height: maxHeight }; 1646 } 1647 this.calculateBorderRadius(); 1648 }); 1649 }, __Common__); 1650 { 1651 this.observeComponentCreation2((elmtId, isInitialRender) => { 1652 if (isInitialRender) { 1653 let componentCall = new i1(this, { 1654 selectedIndexes: this.__selectedIndexes, 1655 focusIndex: this.__focusIndex, 1656 index: index, 1657 itemOptions: item, 1658 options: this.options, 1659 property: this.buttonItemProperty[index], 1660 groupId: this.groupId, 1661 maxFontScale: this.maxFontScale 1662 }, undefined, elmtId, () => { 1663 }, { 1664 page: "segmentbutton/src/main/ets/components/MainPage.ets", 1665 line: 817, 1666 u3: 15 1667 }); 1668 ViewPU.create(componentCall); 1669 let paramsLambda = () => { 1670 return { 1671 selectedIndexes: this.selectedIndexes, 1672 focusIndex: this.focusIndex, 1673 index: index, 1674 itemOptions: item, 1675 options: this.options, 1676 property: this.buttonItemProperty[index], 1677 groupId: this.groupId, 1678 maxFontScale: this.maxFontScale 1679 }; 1680 }; 1681 componentCall.paramsGenerator_ = paramsLambda; 1682 } else { 1683 this.updateStateVarsOfChildByElmtId(elmtId, { 1684 index: index, 1685 itemOptions: item, 1686 options: this.options, 1687 property: this.buttonItemProperty[index], 1688 maxFontScale: this.maxFontScale 1689 }); 1690 } 1691 }, { name: "SegmentButtonItem" }); 1692 } 1693 __Common__.pop(); 1694 Button.pop(); 1695 }); 1696 } else { 1697 this.ifElseBranchUpdateFunction(1, () => { 1698 }); 1699 } 1700 }, If); 1701 If.pop(); 1702 }; 1703 this.forEachUpdateFunction(elmtId, this.optionsArray, forEachItemGenFunction, undefined, true, 1704 false); 1705 }, ForEach); 1706 ForEach.pop(); 1707 Row.pop(); 1708 }); 1709 } else { 1710 this.ifElseBranchUpdateFunction(1, () => { 1711 }); 1712 } 1713 }, If); 1714 If.pop(); 1715 } 1716 1717 rerender() { 1718 this.updateDirtyElements(); 1719 } 1720} 1721 1722let n1 = class ItemProperty { 1723 constructor() { 1724 this.fontColor = e1.q1; 1725 this.fontSize = e1.u1; 1726 this.fontWeight = FontWeight.Regular; 1727 this.isSelected = false; 1728 } 1729}; 1730n1 = j([ 1731 Observed 1732], n1); 1733 1734export class SegmentButton extends ViewPU { 1735 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 1736 super(parent, __localStorage, elmtId, extraInfo); 1737 if (typeof paramsLambda === "function") { 1738 this.paramsGenerator_ = paramsLambda; 1739 } 1740 this.__options = new SynchedPropertyNesedObjectPU(params.options, this, "options"); 1741 this.__selectedIndexes = new SynchedPropertyObjectTwoWayPU(params.selectedIndexes, this, "selectedIndexes"); 1742 this.onItemClicked = undefined; 1743 this.__maxFontScale = new SynchedPropertyObjectOneWayPU(params.maxFontScale, this, "maxFontScale"); 1744 this.__componentSize = new ObservedPropertyObjectPU({ width: 0, height: 0 }, this, "componentSize"); 1745 this.addProvidedVar("componentSize", this.__componentSize, false); 1746 this.__buttonBorderRadius = new ObservedPropertyObjectPU(Array.from({ 1747 length: a1 1748 }, (r2, index) => { 1749 return { 1750 topStart: LengthMetrics.vp(0), 1751 topEnd: LengthMetrics.vp(0), 1752 bottomStart: LengthMetrics.vp(0), 1753 bottomEnd: LengthMetrics.vp(0) 1754 }; 1755 }), this, "buttonBorderRadius"); 1756 this.addProvidedVar("buttonBorderRadius", this.__buttonBorderRadius, false); 1757 this.__buttonItemsSize = new ObservedPropertyObjectPU(Array.from({ length: a1 }, (q2, index) => { 1758 return {}; 1759 }), this, "buttonItemsSize"); 1760 this.addProvidedVar("buttonItemsSize", this.__buttonItemsSize, false); 1761 this.__buttonItemsPosition = new ObservedPropertyObjectPU(Array.from({ 1762 length: a1 1763 }, (o2, index) => { 1764 return {}; 1765 }), this, "buttonItemsPosition"); 1766 this.addProvidedVar("buttonItemsPosition", this.__buttonItemsPosition, false); 1767 this.__buttonItemsSelected = 1768 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (n2, index) => false), this, "buttonItemsSelected"); 1769 this.addProvidedVar("buttonItemsSelected", this.__buttonItemsSelected, false); 1770 this.__buttonItemProperty = new ObservedPropertyObjectPU(Array.from({ 1771 length: a1 1772 }, (m2, index) => new n1()), this, "buttonItemProperty"); 1773 this.addProvidedVar("buttonItemProperty", this.__buttonItemProperty, false); 1774 this.__focusIndex = new ObservedPropertySimplePU(-1, this, "focusIndex"); 1775 this.addProvidedVar("focusIndex", this.__focusIndex, false); 1776 this.__selectedItemPosition = new ObservedPropertyObjectPU({}, this, "selectedItemPosition"); 1777 this.addProvidedVar("selectedItemPosition", this.__selectedItemPosition, false); 1778 this.__zoomScaleArray = 1779 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (l2, index) => 1.0), this, "zoomScaleArray"); 1780 this.addProvidedVar("zoomScaleArray", this.__zoomScaleArray, false); 1781 this.__pressArray = 1782 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (k2, index) => false), this, "pressArray"); 1783 this.__hoverArray = 1784 new ObservedPropertyObjectPU(Array.from({ length: a1 }, (j2, index) => false), this, "hoverArray"); 1785 this.__hoverColorArray = new ObservedPropertyObjectPU(Array.from({ 1786 length: a1 1787 }, (i2, index) => new j1()), this, "hoverColorArray"); 1788 this.doSelectedChangeAnimate = false; 1789 this.isCurrentPositionSelected = false; 1790 this.panGestureStartPoint = { x: 0, y: 0 }; 1791 this.isPanGestureMoved = false; 1792 this.__shouldMirror = new ObservedPropertySimplePU(false, this, "shouldMirror"); 1793 this.setInitiallyProvidedValue(params); 1794 this.declareWatch("options", this.onOptionsChange); 1795 this.declareWatch("selectedIndexes", this.onSelectedChange); 1796 this.declareWatch("buttonItemsPosition", this.onItemsPositionChange); 1797 this.finalizeConstruction(); 1798 } 1799 1800 setInitiallyProvidedValue(params) { 1801 this.__options.set(params.options); 1802 if (params.onItemClicked !== undefined) { 1803 this.onItemClicked = params.onItemClicked; 1804 } 1805 if (params.maxFontScale === undefined) { 1806 this.__maxFontScale.set(b1); 1807 } 1808 if (params.componentSize !== undefined) { 1809 this.componentSize = params.componentSize; 1810 } 1811 if (params.buttonBorderRadius !== undefined) { 1812 this.buttonBorderRadius = params.buttonBorderRadius; 1813 } 1814 if (params.buttonItemsSize !== undefined) { 1815 this.buttonItemsSize = params.buttonItemsSize; 1816 } 1817 if (params.buttonItemsPosition !== undefined) { 1818 this.buttonItemsPosition = params.buttonItemsPosition; 1819 } 1820 if (params.buttonItemsSelected !== undefined) { 1821 this.buttonItemsSelected = params.buttonItemsSelected; 1822 } 1823 if (params.buttonItemProperty !== undefined) { 1824 this.buttonItemProperty = params.buttonItemProperty; 1825 } 1826 if (params.focusIndex !== undefined) { 1827 this.focusIndex = params.focusIndex; 1828 } 1829 if (params.selectedItemPosition !== undefined) { 1830 this.selectedItemPosition = params.selectedItemPosition; 1831 } 1832 if (params.zoomScaleArray !== undefined) { 1833 this.zoomScaleArray = params.zoomScaleArray; 1834 } 1835 if (params.pressArray !== undefined) { 1836 this.pressArray = params.pressArray; 1837 } 1838 if (params.hoverArray !== undefined) { 1839 this.hoverArray = params.hoverArray; 1840 } 1841 if (params.hoverColorArray !== undefined) { 1842 this.hoverColorArray = params.hoverColorArray; 1843 } 1844 if (params.doSelectedChangeAnimate !== undefined) { 1845 this.doSelectedChangeAnimate = params.doSelectedChangeAnimate; 1846 } 1847 if (params.isCurrentPositionSelected !== undefined) { 1848 this.isCurrentPositionSelected = params.isCurrentPositionSelected; 1849 } 1850 if (params.panGestureStartPoint !== undefined) { 1851 this.panGestureStartPoint = params.panGestureStartPoint; 1852 } 1853 if (params.isPanGestureMoved !== undefined) { 1854 this.isPanGestureMoved = params.isPanGestureMoved; 1855 } 1856 if (params.shouldMirror !== undefined) { 1857 this.shouldMirror = params.shouldMirror; 1858 } 1859 } 1860 1861 updateStateVars(params) { 1862 this.__options.set(params.options); 1863 this.__maxFontScale.reset(params.maxFontScale); 1864 } 1865 1866 purgeVariableDependenciesOnElmtId(rmElmtId) { 1867 this.__options.purgeDependencyOnElmtId(rmElmtId); 1868 this.__selectedIndexes.purgeDependencyOnElmtId(rmElmtId); 1869 this.__maxFontScale.purgeDependencyOnElmtId(rmElmtId); 1870 this.__componentSize.purgeDependencyOnElmtId(rmElmtId); 1871 this.__buttonBorderRadius.purgeDependencyOnElmtId(rmElmtId); 1872 this.__buttonItemsSize.purgeDependencyOnElmtId(rmElmtId); 1873 this.__buttonItemsPosition.purgeDependencyOnElmtId(rmElmtId); 1874 this.__buttonItemsSelected.purgeDependencyOnElmtId(rmElmtId); 1875 this.__buttonItemProperty.purgeDependencyOnElmtId(rmElmtId); 1876 this.__focusIndex.purgeDependencyOnElmtId(rmElmtId); 1877 this.__selectedItemPosition.purgeDependencyOnElmtId(rmElmtId); 1878 this.__zoomScaleArray.purgeDependencyOnElmtId(rmElmtId); 1879 this.__pressArray.purgeDependencyOnElmtId(rmElmtId); 1880 this.__hoverArray.purgeDependencyOnElmtId(rmElmtId); 1881 this.__hoverColorArray.purgeDependencyOnElmtId(rmElmtId); 1882 this.__shouldMirror.purgeDependencyOnElmtId(rmElmtId); 1883 } 1884 1885 aboutToBeDeleted() { 1886 this.__options.aboutToBeDeleted(); 1887 this.__selectedIndexes.aboutToBeDeleted(); 1888 this.__maxFontScale.aboutToBeDeleted(); 1889 this.__componentSize.aboutToBeDeleted(); 1890 this.__buttonBorderRadius.aboutToBeDeleted(); 1891 this.__buttonItemsSize.aboutToBeDeleted(); 1892 this.__buttonItemsPosition.aboutToBeDeleted(); 1893 this.__buttonItemsSelected.aboutToBeDeleted(); 1894 this.__buttonItemProperty.aboutToBeDeleted(); 1895 this.__focusIndex.aboutToBeDeleted(); 1896 this.__selectedItemPosition.aboutToBeDeleted(); 1897 this.__zoomScaleArray.aboutToBeDeleted(); 1898 this.__pressArray.aboutToBeDeleted(); 1899 this.__hoverArray.aboutToBeDeleted(); 1900 this.__hoverColorArray.aboutToBeDeleted(); 1901 this.__shouldMirror.aboutToBeDeleted(); 1902 SubscriberManager.Get().delete(this.id__()); 1903 this.aboutToBeDeletedInternal(); 1904 } 1905 1906 get options() { 1907 return this.__options.get(); 1908 } 1909 1910 get selectedIndexes() { 1911 return this.__selectedIndexes.get(); 1912 } 1913 1914 set selectedIndexes(newValue) { 1915 this.__selectedIndexes.set(newValue); 1916 } 1917 1918 get maxFontScale() { 1919 return this.__maxFontScale.get(); 1920 } 1921 1922 set maxFontScale(newValue) { 1923 this.__maxFontScale.set(newValue); 1924 } 1925 1926 get componentSize() { 1927 return this.__componentSize.get(); 1928 } 1929 1930 set componentSize(newValue) { 1931 this.__componentSize.set(newValue); 1932 } 1933 1934 get buttonBorderRadius() { 1935 return this.__buttonBorderRadius.get(); 1936 } 1937 1938 set buttonBorderRadius(newValue) { 1939 this.__buttonBorderRadius.set(newValue); 1940 } 1941 1942 get buttonItemsSize() { 1943 return this.__buttonItemsSize.get(); 1944 } 1945 1946 set buttonItemsSize(newValue) { 1947 this.__buttonItemsSize.set(newValue); 1948 } 1949 1950 get buttonItemsPosition() { 1951 return this.__buttonItemsPosition.get(); 1952 } 1953 1954 set buttonItemsPosition(newValue) { 1955 this.__buttonItemsPosition.set(newValue); 1956 } 1957 1958 get buttonItemsSelected() { 1959 return this.__buttonItemsSelected.get(); 1960 } 1961 1962 set buttonItemsSelected(newValue) { 1963 this.__buttonItemsSelected.set(newValue); 1964 } 1965 1966 get buttonItemProperty() { 1967 return this.__buttonItemProperty.get(); 1968 } 1969 1970 set buttonItemProperty(newValue) { 1971 this.__buttonItemProperty.set(newValue); 1972 } 1973 1974 get focusIndex() { 1975 return this.__focusIndex.get(); 1976 } 1977 1978 set focusIndex(newValue) { 1979 this.__focusIndex.set(newValue); 1980 } 1981 1982 get selectedItemPosition() { 1983 return this.__selectedItemPosition.get(); 1984 } 1985 1986 set selectedItemPosition(newValue) { 1987 this.__selectedItemPosition.set(newValue); 1988 } 1989 1990 get zoomScaleArray() { 1991 return this.__zoomScaleArray.get(); 1992 } 1993 1994 set zoomScaleArray(newValue) { 1995 this.__zoomScaleArray.set(newValue); 1996 } 1997 1998 get pressArray() { 1999 return this.__pressArray.get(); 2000 } 2001 2002 set pressArray(newValue) { 2003 this.__pressArray.set(newValue); 2004 } 2005 2006 get hoverArray() { 2007 return this.__hoverArray.get(); 2008 } 2009 2010 set hoverArray(newValue) { 2011 this.__hoverArray.set(newValue); 2012 } 2013 2014 get hoverColorArray() { 2015 return this.__hoverColorArray.get(); 2016 } 2017 2018 set hoverColorArray(newValue) { 2019 this.__hoverColorArray.set(newValue); 2020 } 2021 2022 get shouldMirror() { 2023 return this.__shouldMirror.get(); 2024 } 2025 2026 set shouldMirror(newValue) { 2027 this.__shouldMirror.set(newValue); 2028 } 2029 2030 onItemsPositionChange() { 2031 if (this.options === void 0 || this.options.buttons === void 0) { 2032 return; 2033 } 2034 if (this.options.type === 'capsule') { 2035 this.options.w3(); 2036 } 2037 if (this.doSelectedChangeAnimate) { 2038 this.updateAnimatedProperty(this.getSelectedChangeCurve()); 2039 } else { 2040 this.updateAnimatedProperty(null); 2041 } 2042 } 2043 2044 setItemsSelected() { 2045 this.buttonItemsSelected.forEach((h2, index) => { 2046 this.buttonItemsSelected[index] = false; 2047 }); 2048 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2049 this.selectedIndexes.forEach(index => this.buttonItemsSelected[index] = true); 2050 } else { 2051 this.buttonItemsSelected[this.selectedIndexes[0]] = true; 2052 } 2053 } 2054 2055 updateSelectedIndexes() { 2056 if (this.selectedIndexes === void 0) { 2057 this.selectedIndexes = []; 2058 } 2059 if (this.options.type === 'tab' && this.selectedIndexes.length === 0) { 2060 this.selectedIndexes[0] = 0; 2061 } 2062 if (this.selectedIndexes.length > 1) { 2063 if (this.options.type === 'tab') { 2064 this.selectedIndexes = [0]; 2065 } 2066 if (this.options.type === 'capsule' && !(this.options.multiply ?? false)) { 2067 this.selectedIndexes = []; 2068 } 2069 } 2070 let g2 = this.selectedIndexes.some(index => { 2071 return (index === void 0 || index < 0 || (this.options.buttons && index >= this.options.buttons.length)); 2072 }); 2073 if (g2) { 2074 if (this.options.type === 'tab') { 2075 this.selectedIndexes = [0]; 2076 } else { 2077 this.selectedIndexes = []; 2078 } 2079 } 2080 } 2081 2082 onOptionsChange() { 2083 if (this.options === void 0 || this.options.buttons === void 0) { 2084 return; 2085 } 2086 this.shouldMirror = this.isShouldMirror(); 2087 this.updateSelectedIndexes(); 2088 this.setItemsSelected(); 2089 this.updateAnimatedProperty(null); 2090 } 2091 2092 onSelectedChange() { 2093 if (this.options === void 0 || this.options.buttons === void 0) { 2094 return; 2095 } 2096 this.updateSelectedIndexes(); 2097 this.setItemsSelected(); 2098 if (this.doSelectedChangeAnimate) { 2099 this.updateAnimatedProperty(this.getSelectedChangeCurve()); 2100 } else { 2101 this.updateAnimatedProperty(null); 2102 } 2103 } 2104 2105 aboutToAppear() { 2106 if (this.options === void 0 || this.options.buttons === void 0) { 2107 return; 2108 } 2109 this.options.h2 = () => { 2110 if (this.options.type === 'tab') { 2111 this.selectedIndexes = [0]; 2112 } else { 2113 this.selectedIndexes = []; 2114 } 2115 }; 2116 this.shouldMirror = this.isShouldMirror(); 2117 this.updateSelectedIndexes(); 2118 this.setItemsSelected(); 2119 this.updateAnimatedProperty(null); 2120 } 2121 2122 isMouseWheelScroll(event) { 2123 return event.source === SourceType.Mouse && !this.isPanGestureMoved; 2124 } 2125 2126 isMovedFromPanGestureStartPoint(x, y) { 2127 return !i(x, this.panGestureStartPoint.x) || !i(y, this.panGestureStartPoint.y); 2128 } 2129 2130 isShouldMirror() { 2131 if (this.options.direction == Direction.Rtl) { 2132 return true; 2133 } 2134 try { 2135 let f2 = t.System.getSystemLanguage(); 2136 if (f2 === 'ug' && this.options.direction != Direction.Ltr) { 2137 return true; 2138 } 2139 } catch (error) { 2140 console.error(`Ace SegmentButton getSystemLanguage, error: ${error.toString()}`); 2141 } 2142 return false; 2143 } 2144 2145 initialRender() { 2146 this.observeComponentCreation2((elmtId, isInitialRender) => { 2147 Stack.create(); 2148 Stack.direction(this.options ? this.options.direction : undefined); 2149 Stack.onBlur(() => { 2150 this.focusIndex = -1; 2151 }); 2152 Stack.onKeyEvent((event) => { 2153 if (this.options === void 0 || this.options.buttons === void 0) { 2154 return; 2155 } 2156 if (event.type === KeyType.Down) { 2157 if (event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER || 2158 event.keyCode === KeyCode.KEYCODE_NUMPAD_ENTER) { 2159 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2160 if (this.selectedIndexes.indexOf(this.focusIndex) === -1) { 2161 this.selectedIndexes.push(this.focusIndex); 2162 } else { 2163 this.selectedIndexes.splice(this.selectedIndexes.indexOf(this.focusIndex), 1); 2164 } 2165 } else { 2166 this.selectedIndexes[0] = this.focusIndex; 2167 } 2168 } 2169 } 2170 }); 2171 Stack.accessibilityLevel('no'); 2172 Gesture.create(GesturePriority.High); 2173 GestureGroup.create(GestureMode.Parallel); 2174 TapGesture.create(); 2175 TapGesture.onAction((event) => { 2176 this.focusIndex = -1; 2177 let a2 = event.fingerList.find(Boolean); 2178 if (a2 === void 0) { 2179 return; 2180 } 2181 if (this.options === void 0 || this.options.buttons === void 0) { 2182 return; 2183 } 2184 let b2 = a2.localX; 2185 let c2 = Math.min(this.options.buttons.length, this.buttonItemsSize.length); 2186 for (let d2 = 0; d2 < c2; d2++) { 2187 b2 = b2 - this.buttonItemsSize[d2].width; 2188 if (b2 >= 0) { 2189 continue; 2190 } 2191 this.doSelectedChangeAnimate = 2192 this.selectedIndexes[0] > Math.min(this.options.buttons.length, this.buttonItemsSize.length) ? 2193 false : true; 2194 let e2 = this.isShouldMirror() ? c2 - 1 - d2 : d2; 2195 if (this.onItemClicked) { 2196 this.onItemClicked(e2); 2197 } 2198 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2199 let selectedIndex = this.selectedIndexes.indexOf(e2); 2200 if (selectedIndex === -1) { 2201 this.selectedIndexes.push(e2); 2202 } else { 2203 this.selectedIndexes.splice(selectedIndex, 1); 2204 } 2205 } else { 2206 this.selectedIndexes[0] = e2; 2207 } 2208 this.doSelectedChangeAnimate = false; 2209 break; 2210 } 2211 }); 2212 TapGesture.pop(); 2213 SwipeGesture.create(); 2214 SwipeGesture.onAction((event) => { 2215 if (this.options === void 0 || this.options.buttons === void 0 || 2216 event.sourceTool === SourceTool.TOUCHPAD) { 2217 return; 2218 } 2219 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2220 return; 2221 } 2222 if (this.isCurrentPositionSelected) { 2223 return; 2224 } 2225 if (event.angle > 0 && this.selectedIndexes[0] !== 2226 Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) { 2227 this.doSelectedChangeAnimate = true; 2228 this.selectedIndexes[0] = this.selectedIndexes[0] + 1; 2229 this.doSelectedChangeAnimate = false; 2230 } else if (event.angle < 0 && this.selectedIndexes[0] !== 0) { 2231 this.doSelectedChangeAnimate = true; 2232 this.selectedIndexes[0] = this.selectedIndexes[0] - 1; 2233 this.doSelectedChangeAnimate = false; 2234 } 2235 }); 2236 SwipeGesture.pop(); 2237 PanGesture.create(); 2238 PanGesture.onActionStart((event) => { 2239 if (this.options === void 0 || this.options.buttons === void 0) { 2240 return; 2241 } 2242 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2243 return; 2244 } 2245 let v1 = event.fingerList.find(Boolean); 2246 if (v1 === void 0) { 2247 return; 2248 } 2249 let w1 = v1.localX; 2250 this.panGestureStartPoint = { x: v1.globalX, y: v1.globalY }; 2251 this.isPanGestureMoved = false; 2252 for (let z1 = 0; z1 < Math.min(this.options.buttons.length, this.buttonItemsSize.length); z1++) { 2253 w1 = w1 - this.buttonItemsSize[z1].width; 2254 if (w1 < 0) { 2255 this.isCurrentPositionSelected = z1 === this.selectedIndexes[0] ? true : false; 2256 break; 2257 } 2258 } 2259 }); 2260 PanGesture.onActionUpdate((event) => { 2261 if (this.options === void 0 || this.options.buttons === void 0) { 2262 return; 2263 } 2264 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2265 return; 2266 } 2267 if (!this.isCurrentPositionSelected) { 2268 return; 2269 } 2270 let q1 = event.fingerList.find(Boolean); 2271 if (q1 === void 0) { 2272 return; 2273 } 2274 let s1 = q1.localX; 2275 if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(q1.globalX, q1.globalY)) { 2276 this.isPanGestureMoved = true; 2277 } 2278 for (let u1 = 0; u1 < Math.min(this.options.buttons.length, this.buttonItemsSize.length); u1++) { 2279 s1 = s1 - this.buttonItemsSize[u1].width; 2280 if (s1 < 0) { 2281 this.doSelectedChangeAnimate = true; 2282 this.selectedIndexes[0] = u1; 2283 this.doSelectedChangeAnimate = false; 2284 break; 2285 } 2286 } 2287 this.zoomScaleArray.forEach((t1, index) => { 2288 if (index === this.selectedIndexes[0]) { 2289 Context.animateTo({ curve: curves.interpolatingSpring(10, 1, 410, 38) }, () => { 2290 this.zoomScaleArray[index] = 0.95; 2291 }); 2292 } else { 2293 Context.animateTo({ curve: curves.interpolatingSpring(10, 1, 410, 38) }, () => { 2294 this.zoomScaleArray[index] = 1; 2295 }); 2296 } 2297 }); 2298 }); 2299 PanGesture.onActionEnd((event) => { 2300 if (this.options === void 0 || this.options.buttons === void 0) { 2301 return; 2302 } 2303 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2304 return; 2305 } 2306 let p1 = event.fingerList.find(Boolean); 2307 if (p1 === void 0) { 2308 return; 2309 } 2310 if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(p1.globalX, p1.globalY)) { 2311 this.isPanGestureMoved = true; 2312 } 2313 if (this.isMouseWheelScroll(event)) { 2314 let offset = event.offsetX !== 0 ? event.offsetX : event.offsetY; 2315 this.doSelectedChangeAnimate = true; 2316 if (offset > 0 && this.selectedIndexes[0] > 0) { 2317 this.selectedIndexes[0] -= 1; 2318 } else if (offset < 0 && this.selectedIndexes[0] < 2319 Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) { 2320 this.selectedIndexes[0] += 1; 2321 } 2322 this.doSelectedChangeAnimate = false; 2323 } 2324 Context.animateTo({ curve: curves.interpolatingSpring(10, 1, 410, 38) }, () => { 2325 this.zoomScaleArray[this.selectedIndexes[0]] = 1; 2326 }); 2327 this.isCurrentPositionSelected = false; 2328 }); 2329 PanGesture.pop(); 2330 GestureGroup.pop(); 2331 Gesture.pop(); 2332 }, Stack); 2333 this.observeComponentCreation2((elmtId, isInitialRender) => { 2334 If.create(); 2335 if (this.options !== void 0 && this.options.buttons != void 0) { 2336 this.ifElseBranchUpdateFunction(0, () => { 2337 this.observeComponentCreation2((elmtId, isInitialRender) => { 2338 If.create(); 2339 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2340 this.ifElseBranchUpdateFunction(0, () => { 2341 { 2342 this.observeComponentCreation2((elmtId, isInitialRender) => { 2343 if (isInitialRender) { 2344 let componentCall = new f1(this, { 2345 optionsArray: this.options.buttons, 2346 options: this.options, 2347 }, undefined, elmtId, () => { 2348 }, { 2349 page: "segmentbutton/src/main/ets/components/MainPage.ets", 2350 line: 1120, 2351 u3: 11 2352 }); 2353 ViewPU.create(componentCall); 2354 let paramsLambda = () => { 2355 return { 2356 optionsArray: this.options.buttons, 2357 options: this.options 2358 }; 2359 }; 2360 componentCall.paramsGenerator_ = paramsLambda; 2361 } else { 2362 this.updateStateVarsOfChildByElmtId(elmtId, { 2363 optionsArray: this.options.buttons, 2364 options: this.options 2365 }); 2366 } 2367 }, { name: "MultiSelectBackground" }); 2368 } 2369 }); 2370 } else { 2371 this.ifElseBranchUpdateFunction(1, () => { 2372 this.observeComponentCreation2((elmtId, isInitialRender) => { 2373 Stack.create(); 2374 Stack.direction(this.options.direction); 2375 Stack.size(ObservedObject.GetRawObject(this.componentSize)); 2376 Stack.backgroundColor(this.options.backgroundColor ?? e1.BACKGROUND_COLOR); 2377 Stack.borderRadius(this.options.l2 ?? this.componentSize.height / 2); 2378 Stack.backgroundBlurStyle(this.options.backgroundBlurStyle); 2379 }, Stack); 2380 this.observeComponentCreation2((elmtId, isInitialRender) => { 2381 If.create(); 2382 if (this.options.buttons !== void 0 && this.options.buttons.length > 1) { 2383 this.ifElseBranchUpdateFunction(0, () => { 2384 this.observeComponentCreation2((elmtId, isInitialRender) => { 2385 Row.create({ space: 1 }); 2386 Row.direction(this.options.direction); 2387 }, Row); 2388 this.observeComponentCreation2((elmtId, isInitialRender) => { 2389 ForEach.create(); 2390 const forEachItemGenFunction = (_item, index) => { 2391 const item = _item; 2392 this.observeComponentCreation2((elmtId, isInitialRender) => { 2393 If.create(); 2394 if (index < a1) { 2395 this.ifElseBranchUpdateFunction(0, () => { 2396 this.observeComponentCreation2((elmtId, 2397 isInitialRender) => { 2398 Stack.create(); 2399 Stack.direction(this.options.direction); 2400 Stack.scale({ 2401 x: this.options.type === 'capsule' && 2402 (this.options.multiply ?? false) ? 1 : 2403 this.zoomScaleArray[index], 2404 y: this.options.type === 'capsule' && 2405 (this.options.multiply ?? false) ? 1 : 2406 this.zoomScaleArray[index] 2407 }); 2408 }, Stack); 2409 { 2410 this.observeComponentCreation2((elmtId, 2411 isInitialRender) => { 2412 if (isInitialRender) { 2413 let componentCall = new l1(this, { 2414 pressIndex: index, 2415 colorProperty: this.hoverColorArray[index], 2416 press: this.pressArray[index], 2417 hover: this.hoverArray[index], 2418 options: this.options, 2419 }, undefined, elmtId, () => { 2420 }, { 2421 page: "segmentbutton/src/main/ets/components/MainPage.ets", 2422 line: 1131, 2423 u3: 23 2424 }); 2425 ViewPU.create(componentCall); 2426 let paramsLambda = () => { 2427 return { 2428 pressIndex: index, 2429 colorProperty: this.hoverColorArray[index], 2430 press: this.pressArray[index], 2431 hover: this.hoverArray[index], 2432 options: this.options 2433 }; 2434 }; 2435 componentCall.paramsGenerator_ = 2436 paramsLambda; 2437 } else { 2438 this.updateStateVarsOfChildByElmtId(elmtId, 2439 { 2440 colorProperty: this.hoverColorArray[index], 2441 press: this.pressArray[index], 2442 hover: this.hoverArray[index], 2443 options: this.options 2444 }); 2445 } 2446 }, { name: "PressAndHoverEffect" }); 2447 } 2448 Stack.pop(); 2449 }); 2450 } else { 2451 this.ifElseBranchUpdateFunction(1, () => { 2452 }); 2453 } 2454 }, If); 2455 If.pop(); 2456 }; 2457 this.forEachUpdateFunction(elmtId, this.options.buttons, 2458 forEachItemGenFunction, undefined, true, false); 2459 }, ForEach); 2460 ForEach.pop(); 2461 Row.pop(); 2462 }); 2463 } else { 2464 this.ifElseBranchUpdateFunction(1, () => { 2465 }); 2466 } 2467 }, If); 2468 If.pop(); 2469 Stack.pop(); 2470 }); 2471 } 2472 }, If); 2473 If.pop(); 2474 this.observeComponentCreation2((elmtId, isInitialRender) => { 2475 Stack.create(); 2476 Context.animation({ duration: 0 }); 2477 Stack.direction(this.options.direction); 2478 Stack.size(ObservedObject.GetRawObject(this.componentSize)); 2479 Context.animation(null); 2480 Stack.borderRadius((this.options.type === 'capsule' && (this.options.multiply ?? false) ? 2481 this.options.j2 : this.options.l2) ?? 2482 this.componentSize.height / 2); 2483 Stack.clip(true); 2484 }, Stack); 2485 this.observeComponentCreation2((elmtId, isInitialRender) => { 2486 If.create(); 2487 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2488 this.ifElseBranchUpdateFunction(0, () => { 2489 { 2490 this.observeComponentCreation2((elmtId, isInitialRender) => { 2491 if (isInitialRender) { 2492 let componentCall = new h1(this, { 2493 optionsArray: this.options.buttons, 2494 options: this.options, 2495 selectedIndexes: this.__selectedIndexes 2496 }, undefined, elmtId, () => { 2497 }, { 2498 page: "segmentbutton/src/main/ets/components/MainPage.ets", 2499 line: 1157, 2500 u3: 13 2501 }); 2502 ViewPU.create(componentCall); 2503 let paramsLambda = () => { 2504 return { 2505 optionsArray: this.options.buttons, 2506 options: this.options, 2507 selectedIndexes: this.selectedIndexes 2508 }; 2509 }; 2510 componentCall.paramsGenerator_ = paramsLambda; 2511 } else { 2512 this.updateStateVarsOfChildByElmtId(elmtId, { 2513 optionsArray: this.options.buttons, 2514 options: this.options 2515 }); 2516 } 2517 }, { name: "MultiSelectItemArray" }); 2518 } 2519 }); 2520 } else { 2521 this.ifElseBranchUpdateFunction(1, () => { 2522 { 2523 this.observeComponentCreation2((elmtId, isInitialRender) => { 2524 if (isInitialRender) { 2525 let componentCall = new g1(this, { 2526 optionsArray: this.options.buttons, 2527 options: this.options, 2528 selectedIndexes: this.__selectedIndexes 2529 }, undefined, elmtId, () => { 2530 }, { 2531 page: "segmentbutton/src/main/ets/components/MainPage.ets", 2532 line: 1163, 2533 u3: 13 2534 }); 2535 ViewPU.create(componentCall); 2536 let paramsLambda = () => { 2537 return { 2538 optionsArray: this.options.buttons, 2539 options: this.options, 2540 selectedIndexes: this.selectedIndexes 2541 }; 2542 }; 2543 componentCall.paramsGenerator_ = paramsLambda; 2544 } else { 2545 this.updateStateVarsOfChildByElmtId(elmtId, { 2546 optionsArray: this.options.buttons, 2547 options: this.options 2548 }); 2549 } 2550 }, { name: "SelectItem" }); 2551 } 2552 }); 2553 } 2554 }, If); 2555 If.pop(); 2556 Stack.pop(); 2557 { 2558 this.observeComponentCreation2((elmtId, isInitialRender) => { 2559 if (isInitialRender) { 2560 let componentCall = new m1(this, { 2561 pressArray: this.__pressArray, 2562 hoverArray: this.__hoverArray, 2563 hoverColorArray: this.__hoverColorArray, 2564 optionsArray: this.options.buttons, 2565 options: this.options, 2566 selectedIndexes: this.__selectedIndexes, 2567 maxFontScale: this.getMaxFontSize() 2568 }, undefined, elmtId, () => { 2569 }, { page: "segmentbutton/src/main/ets/components/MainPage.ets", line: 1178, u3: 9 }); 2570 ViewPU.create(componentCall); 2571 let paramsLambda = () => { 2572 return { 2573 pressArray: this.pressArray, 2574 hoverArray: this.hoverArray, 2575 hoverColorArray: this.hoverColorArray, 2576 optionsArray: this.options.buttons, 2577 options: this.options, 2578 selectedIndexes: this.selectedIndexes, 2579 maxFontScale: this.getMaxFontSize() 2580 }; 2581 }; 2582 componentCall.paramsGenerator_ = paramsLambda; 2583 } else { 2584 this.updateStateVarsOfChildByElmtId(elmtId, { 2585 optionsArray: this.options.buttons, 2586 options: this.options, 2587 maxFontScale: this.getMaxFontSize() 2588 }); 2589 } 2590 }, { name: "SegmentButtonItemArrayComponent" }); 2591 } 2592 }); 2593 } else { 2594 this.ifElseBranchUpdateFunction(1, () => { 2595 }); 2596 } 2597 }, If); 2598 If.pop(); 2599 Stack.pop(); 2600 } 2601 2602 getMaxFontSize() { 2603 if (typeof this.maxFontScale === void 0) { 2604 return b1; 2605 } 2606 if (typeof this.maxFontScale === 'number') { 2607 return Math.max(Math.min(this.maxFontScale, c1), d1); 2608 } 2609 const resourceManager = this.getUIContext().getHostContext()?.resourceManager; 2610 if (!resourceManager) { 2611 return b1; 2612 } 2613 try { 2614 return resourceManager.getNumber(this.maxFontScale.id); 2615 } catch (error) { 2616 console.error(`Ace SegmentButton getMaxFontSize, error: ${error.toString()}`); 2617 return b1; 2618 } 2619 } 2620 2621 getSelectedChangeCurve() { 2622 if (this.options.type === 'capsule' && (this.options.multiply ?? false)) { 2623 return null; 2624 } 2625 return curves.springMotion(0.347, 0.99); 2626 } 2627 2628 updateAnimatedProperty(curve) { 2629 let o1 = () => { 2630 this.selectedItemPosition = 2631 this.selectedIndexes.length === 0 ? {} : this.buttonItemsPosition[this.selectedIndexes[0]]; 2632 this.buttonItemsSelected.forEach((selected, index) => { 2633 this.buttonItemProperty[index].fontColor = selected ? 2634 this.options.selectedFontColor ?? (this.options.type === 'tab' ? 2635 e1.s1 : e1.t1) : 2636 this.options.fontColor ?? e1.q1; 2637 }); 2638 }; 2639 if (curve) { 2640 Context.animateTo({ curve: curve }, o1); 2641 } else { 2642 o1(); 2643 } 2644 this.buttonItemsSelected.forEach((selected, index) => { 2645 this.buttonItemProperty[index].fontSize = selected ? this.options.selectedFontSize ?? 2646 e1.v1 : this.options.fontSize ?? e1.u1; 2647 this.buttonItemProperty[index].fontWeight = 2648 selected ? this.options.selectedFontWeight ?? FontWeight.Medium : 2649 this.options.fontWeight ?? FontWeight.Regular; 2650 this.buttonItemProperty[index].isSelected = selected; 2651 }); 2652 } 2653 2654 rerender() { 2655 this.updateDirtyElements(); 2656 } 2657} 2658 2659export default { 2660 SegmentButton, 2661 SegmentButtonOptions, 2662 SegmentButtonItemOptionsArray, 2663 SegmentButtonItemOptions, 2664}; 2665