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