1/* 2 * Copyright (c) 2023-2024 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 16if (!("finalizeConstruction" in ViewPU.prototype)) { 17 Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); 18} 19 20const display = requireNapi('display'); 21const mediaquery = requireNapi('mediaquery'); 22const LengthMetrics = requireNapi('arkui.node').LengthMetrics; 23const SymbolGlyphModifier = requireNapi('arkui.modifier').SymbolGlyphModifier; 24const componentUtils = requireNapi('arkui.componentUtils'); 25const Configuration = requireNapi('configuration'); 26const SystemDateTime = requireNapi('systemDateTime'); 27 28const o = 10003; 29const t = 10002; 30const u = 10007; 31export const a1 = { 32 icon: { 33 size: { width: 32, height: 32 }, 34 margin: { 35 top: LengthMetrics.vp(12), 36 bottom: LengthMetrics.vp(12), 37 start: LengthMetrics.vp(12), 38 end: LengthMetrics.vp(12) 39 }, 40 fillColor: '', 41 borderRadius: { "id": -1, "type": 10002, params: ['sys.float.ohos_id_corner_radius_default_s'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 42 }, 43 title: { 44 margin: { bottom: LengthMetrics.vp(2) }, 45 minFontSize: 12, 46 fontWeight: FontWeight.Medium, 47 fontSize: { "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_sub_title2'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 48 fontColor: { "id": -1, "type": 10001, params: ['sys.color.font_primary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 49 }, 50 button: { 51 margin: { 52 top: LengthMetrics.vp(16), 53 bottom: LengthMetrics.vp(16), 54 start: LengthMetrics.vp(16), 55 end: LengthMetrics.vp(16) 56 }, 57 padding: { 58 top: LengthMetrics.vp(4), 59 bottom: LengthMetrics.vp(4), 60 start: LengthMetrics.vp(4), 61 end: LengthMetrics.vp(4) 62 }, 63 fontSize: { "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_button2'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 64 fontColor: { "id": -1, "type": 10001, params: ['sys.color.font_emphasize'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 65 e2: { 66 top: LengthMetrics.vp(8), 67 bottom: LengthMetrics.vp(8), 68 start: LengthMetrics.vp(8), 69 end: LengthMetrics.vp(8) 70 }, 71 minFontSize: 9, 72 fontWeight: FontWeight.Medium, 73 f2: { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_hover'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 74 backgroundColor: { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 75 }, 76 message: { 77 fontSize: { "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_body2'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 78 fontColor: { "id": -1, "type": 10001, params: ['sys.color.font_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 79 fontWeight: FontWeight.Regular, 80 g2: { "id": -1, "type": 10001, params: ['sys.color.font_primary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 81 }, 82 h2: { 83 padding: { 84 top: LengthMetrics.vp(12), 85 bottom: LengthMetrics.vp(12), 86 start: LengthMetrics.vp(12), 87 end: LengthMetrics.vp(12) 88 }, 89 }, 90 i2: { 91 size: { width: 22, height: 22 }, 92 padding: { 93 top: LengthMetrics.vp(2), 94 bottom: LengthMetrics.vp(2), 95 start: LengthMetrics.vp(2), 96 end: LengthMetrics.vp(2) 97 }, 98 margin: { 99 top: LengthMetrics.vp(12), 100 bottom: LengthMetrics.vp(12), 101 start: LengthMetrics.vp(12), 102 end: LengthMetrics.vp(12) 103 }, 104 symbolStyle: new SymbolGlyphModifier({ "id": -1, "type": 40000, params: ['sys.symbol.xmark'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }), 105 fillColor: { "id": -1, "type": 10001, params: ['sys.color.icon_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 106 f2: { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_hover'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 107 backgroundColor: { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, 108 j2: '18vp', 109 l2: { "id": -1, "type": 10003, params: ['sys.string.off_used_for_accessibility_text'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 110 }, 111}; 112const b1 = () => { 113}; 114const c1 = 400; 115export function Popup(options, parent = null) { 116 const d2 = options; 117 { 118 (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, options = d2) => { 119 if (isInitialRender) { 120 let componentCall = new d1(parent ? parent : this, { 121 icon: options.icon, 122 title: options.title, 123 message: options.message, 124 popupDirection: options.direction, 125 showClose: options.showClose, 126 onClose: options.onClose, 127 buttons: options.buttons, 128 maxWidth: options.maxWidth 129 }, undefined, elmtId, () => { }, { page: "library/src/main/ets/components/MainPage.ets", line: 210, m2: 3 }); 130 ViewPU.create(componentCall); 131 let paramsLambda = () => { 132 return { 133 icon: options.icon, 134 title: options.title, 135 message: options.message, 136 popupDirection: options.direction, 137 showClose: options.showClose, 138 onClose: options.onClose, 139 buttons: options.buttons, 140 maxWidth: options.maxWidth 141 }; 142 }; 143 componentCall.paramsGenerator_ = paramsLambda; 144 } 145 else { 146 (parent ? parent : this).updateStateVarsOfChildByElmtId(elmtId, { 147 icon: options.icon, 148 title: options.title, 149 message: options.message, 150 popupDirection: options.direction, 151 showClose: options.showClose, 152 buttons: options.buttons, 153 maxWidth: options.maxWidth 154 }); 155 } 156 }, { name: "PopupComponent" }); 157 } 158} 159function i(dimension, c2) { 160 const matches = dimension.match(c2); 161 if (!matches || matches.length < 3) { 162 return false; 163 } 164 const value = Number.parseFloat(matches[1]); 165 return value >= 0; 166} 167function j(dimension) { 168 return i(dimension, new RegExp('(-?\\d+(?:\\.\\d+)?)_?(fp|vp|px|lpx|%)?$', 'i')); 169} 170function m(context, value) { 171 const resourceManager = context?.resourceManager; 172 if (value === void (0) || value === null || resourceManager === void (0)) { 173 return false; 174 } 175 if (value.type !== o && value.type !== u && 176 value.type !== t) { 177 return false; 178 } 179 if (value.type === u || value.type === t) { 180 if (resourceManager.getNumber(value.id) >= 0) { 181 return true; 182 } 183 else { 184 return false; 185 } 186 } 187 if (value.type === o && !j(resourceManager.getStringSync(value.id))) { 188 return false; 189 } 190 else { 191 return true; 192 } 193} 194export class d1 extends ViewPU { 195 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 196 super(parent, __localStorage, elmtId, extraInfo); 197 if (typeof paramsLambda === "function") { 198 this.paramsGenerator_ = paramsLambda; 199 } 200 this.onClose = b1; 201 this.theme = a1; 202 this.applycontentKey = 'applyContent' + SystemDateTime.getTime(false); 203 this.__icon = new SynchedPropertyObjectOneWayPU(params.icon, this, "icon"); 204 this.__maxWidth = new SynchedPropertyObjectOneWayPU(params.maxWidth, this, "maxWidth"); 205 this.__messageMaxWidth = new SynchedPropertySimpleOneWayPU(params.messageMaxWidth, this, "messageMaxWidth"); 206 this.__title = new SynchedPropertyObjectOneWayPU(params.title, this, "title"); 207 this.__message = new SynchedPropertyObjectOneWayPU(params.message, this, "message"); 208 this.__popupDirection = new SynchedPropertySimpleOneWayPU(params.popupDirection, this, "popupDirection"); 209 this.__showClose = new SynchedPropertyObjectOneWayPU(params.showClose, this, "showClose"); 210 this.__buttons = new SynchedPropertyObjectOneWayPU(params.buttons, this, "buttons"); 211 this.textHeight = 0; 212 this.__titleHeight = new ObservedPropertySimplePU(0, this, "titleHeight"); 213 this.__applyHeight = new ObservedPropertySimplePU(0, this, "applyHeight"); 214 this.__buttonHeight = new ObservedPropertySimplePU(0, this, "buttonHeight"); 215 this.__messageMaxWeight = new ObservedPropertyObjectPU(0, this, "messageMaxWeight"); 216 this.__beforeScreenStatus = new ObservedPropertySimplePU(undefined, this, "beforeScreenStatus"); 217 this.__currentScreenStatus = new ObservedPropertySimplePU(true, this, "currentScreenStatus"); 218 this.__applySizeOptions = new ObservedPropertyObjectPU(undefined, this, "applySizeOptions"); 219 this.__closeButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "closeButtonBackgroundColor"); 220 this.__firstButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "firstButtonBackgroundColor"); 221 this.__secondButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "secondButtonBackgroundColor"); 222 this.__closeButtonFillColorWithTheme = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.icon_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "closeButtonFillColorWithTheme"); 223 this.listener = mediaquery.matchMediaSync('(orientation: landscape)'); 224 this.setInitiallyProvidedValue(params); 225 this.finalizeConstruction(); 226 } 227 setInitiallyProvidedValue(params) { 228 if (params.onClose !== undefined) { 229 this.onClose = params.onClose; 230 } 231 if (params.theme !== undefined) { 232 this.theme = params.theme; 233 } 234 if (params.applycontentKey !== undefined) { 235 this.applycontentKey = params.applycontentKey; 236 } 237 if (params.icon === undefined) { 238 this.__icon.set({ image: '' }); 239 } 240 if (params.messageMaxWidth === undefined) { 241 this.__messageMaxWidth.set(0); 242 } 243 if (params.title === undefined) { 244 this.__title.set({ text: '' }); 245 } 246 if (params.message === undefined) { 247 this.__message.set({ text: '' }); 248 } 249 if (params.popupDirection === undefined) { 250 this.__popupDirection.set(Direction.Auto); 251 } 252 if (params.showClose === undefined) { 253 this.__showClose.set(true); 254 } 255 if (params.buttons === undefined) { 256 this.__buttons.set([{ text: '' }, { text: '' }]); 257 } 258 if (params.textHeight !== undefined) { 259 this.textHeight = params.textHeight; 260 } 261 if (params.titleHeight !== undefined) { 262 this.titleHeight = params.titleHeight; 263 } 264 if (params.applyHeight !== undefined) { 265 this.applyHeight = params.applyHeight; 266 } 267 if (params.buttonHeight !== undefined) { 268 this.buttonHeight = params.buttonHeight; 269 } 270 if (params.messageMaxWeight !== undefined) { 271 this.messageMaxWeight = params.messageMaxWeight; 272 } 273 if (params.beforeScreenStatus !== undefined) { 274 this.beforeScreenStatus = params.beforeScreenStatus; 275 } 276 if (params.currentScreenStatus !== undefined) { 277 this.currentScreenStatus = params.currentScreenStatus; 278 } 279 if (params.applySizeOptions !== undefined) { 280 this.applySizeOptions = params.applySizeOptions; 281 } 282 if (params.closeButtonBackgroundColor !== undefined) { 283 this.closeButtonBackgroundColor = params.closeButtonBackgroundColor; 284 } 285 if (params.firstButtonBackgroundColor !== undefined) { 286 this.firstButtonBackgroundColor = params.firstButtonBackgroundColor; 287 } 288 if (params.secondButtonBackgroundColor !== undefined) { 289 this.secondButtonBackgroundColor = params.secondButtonBackgroundColor; 290 } 291 if (params.closeButtonFillColorWithTheme !== undefined) { 292 this.closeButtonFillColorWithTheme = params.closeButtonFillColorWithTheme; 293 } 294 if (params.listener !== undefined) { 295 this.listener = params.listener; 296 } 297 } 298 updateStateVars(params) { 299 this.__icon.reset(params.icon); 300 this.__maxWidth.reset(params.maxWidth); 301 this.__messageMaxWidth.reset(params.messageMaxWidth); 302 this.__title.reset(params.title); 303 this.__message.reset(params.message); 304 this.__popupDirection.reset(params.popupDirection); 305 this.__showClose.reset(params.showClose); 306 this.__buttons.reset(params.buttons); 307 } 308 purgeVariableDependenciesOnElmtId(rmElmtId) { 309 this.__icon.purgeDependencyOnElmtId(rmElmtId); 310 this.__maxWidth.purgeDependencyOnElmtId(rmElmtId); 311 this.__messageMaxWidth.purgeDependencyOnElmtId(rmElmtId); 312 this.__title.purgeDependencyOnElmtId(rmElmtId); 313 this.__message.purgeDependencyOnElmtId(rmElmtId); 314 this.__popupDirection.purgeDependencyOnElmtId(rmElmtId); 315 this.__showClose.purgeDependencyOnElmtId(rmElmtId); 316 this.__buttons.purgeDependencyOnElmtId(rmElmtId); 317 this.__titleHeight.purgeDependencyOnElmtId(rmElmtId); 318 this.__applyHeight.purgeDependencyOnElmtId(rmElmtId); 319 this.__buttonHeight.purgeDependencyOnElmtId(rmElmtId); 320 this.__messageMaxWeight.purgeDependencyOnElmtId(rmElmtId); 321 this.__beforeScreenStatus.purgeDependencyOnElmtId(rmElmtId); 322 this.__currentScreenStatus.purgeDependencyOnElmtId(rmElmtId); 323 this.__applySizeOptions.purgeDependencyOnElmtId(rmElmtId); 324 this.__closeButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 325 this.__firstButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 326 this.__secondButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 327 this.__closeButtonFillColorWithTheme.purgeDependencyOnElmtId(rmElmtId); 328 } 329 aboutToBeDeleted() { 330 this.__icon.aboutToBeDeleted(); 331 this.__maxWidth.aboutToBeDeleted(); 332 this.__messageMaxWidth.aboutToBeDeleted(); 333 this.__title.aboutToBeDeleted(); 334 this.__message.aboutToBeDeleted(); 335 this.__popupDirection.aboutToBeDeleted(); 336 this.__showClose.aboutToBeDeleted(); 337 this.__buttons.aboutToBeDeleted(); 338 this.__titleHeight.aboutToBeDeleted(); 339 this.__applyHeight.aboutToBeDeleted(); 340 this.__buttonHeight.aboutToBeDeleted(); 341 this.__messageMaxWeight.aboutToBeDeleted(); 342 this.__beforeScreenStatus.aboutToBeDeleted(); 343 this.__currentScreenStatus.aboutToBeDeleted(); 344 this.__applySizeOptions.aboutToBeDeleted(); 345 this.__closeButtonBackgroundColor.aboutToBeDeleted(); 346 this.__firstButtonBackgroundColor.aboutToBeDeleted(); 347 this.__secondButtonBackgroundColor.aboutToBeDeleted(); 348 this.__closeButtonFillColorWithTheme.aboutToBeDeleted(); 349 SubscriberManager.Get().delete(this.id__()); 350 this.aboutToBeDeletedInternal(); 351 } 352 get icon() { 353 return this.__icon.get(); 354 } 355 set icon(newValue) { 356 this.__icon.set(newValue); 357 } 358 get maxWidth() { 359 return this.__maxWidth.get(); 360 } 361 set maxWidth(newValue) { 362 this.__maxWidth.set(newValue); 363 } 364 get messageMaxWidth() { 365 return this.__messageMaxWidth.get(); 366 } 367 set messageMaxWidth(newValue) { 368 this.__messageMaxWidth.set(newValue); 369 } 370 get title() { 371 return this.__title.get(); 372 } 373 set title(newValue) { 374 this.__title.set(newValue); 375 } 376 get message() { 377 return this.__message.get(); 378 } 379 set message(newValue) { 380 this.__message.set(newValue); 381 } 382 get popupDirection() { 383 return this.__popupDirection.get(); 384 } 385 set popupDirection(newValue) { 386 this.__popupDirection.set(newValue); 387 } 388 get showClose() { 389 return this.__showClose.get(); 390 } 391 set showClose(newValue) { 392 this.__showClose.set(newValue); 393 } 394 get buttons() { 395 return this.__buttons.get(); 396 } 397 set buttons(newValue) { 398 this.__buttons.set(newValue); 399 } 400 get titleHeight() { 401 return this.__titleHeight.get(); 402 } 403 set titleHeight(newValue) { 404 this.__titleHeight.set(newValue); 405 } 406 get applyHeight() { 407 return this.__applyHeight.get(); 408 } 409 set applyHeight(newValue) { 410 this.__applyHeight.set(newValue); 411 } 412 get buttonHeight() { 413 return this.__buttonHeight.get(); 414 } 415 set buttonHeight(newValue) { 416 this.__buttonHeight.set(newValue); 417 } 418 get messageMaxWeight() { 419 return this.__messageMaxWeight.get(); 420 } 421 set messageMaxWeight(newValue) { 422 this.__messageMaxWeight.set(newValue); 423 } 424 get beforeScreenStatus() { 425 return this.__beforeScreenStatus.get(); 426 } 427 set beforeScreenStatus(newValue) { 428 this.__beforeScreenStatus.set(newValue); 429 } 430 get currentScreenStatus() { 431 return this.__currentScreenStatus.get(); 432 } 433 set currentScreenStatus(newValue) { 434 this.__currentScreenStatus.set(newValue); 435 } 436 get applySizeOptions() { 437 return this.__applySizeOptions.get(); 438 } 439 set applySizeOptions(newValue) { 440 this.__applySizeOptions.set(newValue); 441 } 442 get closeButtonBackgroundColor() { 443 return this.__closeButtonBackgroundColor.get(); 444 } 445 set closeButtonBackgroundColor(newValue) { 446 this.__closeButtonBackgroundColor.set(newValue); 447 } 448 get firstButtonBackgroundColor() { 449 return this.__firstButtonBackgroundColor.get(); 450 } 451 set firstButtonBackgroundColor(newValue) { 452 this.__firstButtonBackgroundColor.set(newValue); 453 } 454 get secondButtonBackgroundColor() { 455 return this.__secondButtonBackgroundColor.get(); 456 } 457 set secondButtonBackgroundColor(newValue) { 458 this.__secondButtonBackgroundColor.set(newValue); 459 } 460 get closeButtonFillColorWithTheme() { 461 return this.__closeButtonFillColorWithTheme.get(); 462 } 463 set closeButtonFillColorWithTheme(newValue) { 464 this.__closeButtonFillColorWithTheme.set(newValue); 465 } 466 getIconWidth() { 467 return this.icon?.width ?? this.theme.icon.size.width; 468 } 469 getIconHeight() { 470 return this.icon?.height ?? this.theme.icon.size.height; 471 } 472 getIconFillColor() { 473 return this.icon?.fillColor ?? this.theme.icon.fillColor; 474 } 475 getIconBorderRadius() { 476 return this.icon?.borderRadius ?? this.theme.icon.borderRadius; 477 } 478 getIconMargin() { 479 return { 480 start: new LengthMetrics(this.theme.button.margin.start.value / 2, this.theme.button.margin.start.unit), 481 end: new LengthMetrics(this.theme.icon.margin.start.value - (this.theme.button.margin.end.value / 2), this.theme.button.margin.start.unit) 482 }; 483 } 484 getIconImage() { 485 return this.icon?.image; 486 } 487 getTitleText() { 488 return this.title?.text; 489 } 490 getTitlePadding() { 491 return { 492 start: new LengthMetrics(this.theme.button.margin.start.value / 2, this.theme.button.margin.start.unit), 493 end: this.theme.i2.margin.end 494 }; 495 } 496 getTitleMargin() { 497 return this.theme.title.margin; 498 } 499 getTitleMinFontSize() { 500 return this.theme.title.minFontSize; 501 } 502 getTitleFontWeight() { 503 return this.title?.fontWeight ?? this.theme.title.fontWeight; 504 } 505 getTitleFontSize() { 506 return this.title?.fontSize ?? this.theme.title.fontSize; 507 } 508 getTitleFontColor() { 509 return this.title?.fontColor ?? this.theme.title.fontColor; 510 } 511 getCloseButtonWidth() { 512 return this.theme.i2.size.width; 513 } 514 getCloseButtonHeight() { 515 return this.theme.i2.size.height; 516 } 517 getCloseButtonFillColor() { 518 return this.closeButtonFillColorWithTheme; 519 } 520 getCloseButtonHoverColor() { 521 return this.theme.i2.f2; 522 } 523 getCloseButtonBackgroundColor() { 524 return this.theme.i2.backgroundColor; 525 } 526 getCloseButtonPadding() { 527 return this.theme.i2.padding; 528 } 529 getCloseButtonSymbolSize() { 530 return this.theme.i2.j2; 531 } 532 getMessageText() { 533 return this.message.text; 534 } 535 getMessageFontSize() { 536 return this.message.fontSize ?? this.theme.message.fontSize; 537 } 538 getMessageFontColor() { 539 let fontColor; 540 if (this.message.fontColor) { 541 fontColor = this.message.fontColor; 542 } 543 else { 544 if (this.title.text !== '' && this.title.text !== void (0)) { 545 fontColor = this.theme.message.fontColor; 546 } 547 else { 548 fontColor = this.theme.message.g2; 549 } 550 } 551 return fontColor; 552 } 553 getMessagePadding() { 554 let padding; 555 padding = { 556 start: LengthMetrics.vp(this.theme.button.margin.start.value / 2), 557 end: LengthMetrics.vp(this.theme.i2.margin.end.value) 558 }; 559 return padding; 560 } 561 getMessageMaxWeight() { 562 let a2 = undefined; 563 let b2 = undefined; 564 try { 565 b2 = display.getDefaultDisplaySync(); 566 } 567 catch (error) { 568 console.error(`Ace Popup getDefaultDisplaySync, error: ${error.toString()}`); 569 return a2 = 400; 570 } 571 if (this.showClose || this.showClose === void (0)) { 572 if (this.messageMaxWidth != undefined) { 573 if (this.maxWidth != undefined && this.maxWidth > px2vp(b2.width)) { 574 a2 = px2vp(b2.width); 575 } 576 else { 577 a2 = this.messageMaxWidth; 578 } 579 } 580 else { 581 if (b2.width != 0) { 582 a2 = px2vp(b2.width); 583 } 584 else { 585 a2 = -1; 586 } 587 } 588 a2 -= (this.theme.h2.padding.start.value - (this.theme.button.margin.end.value / 2)); 589 a2 -= this.theme.h2.padding.end.value; 590 a2 -= this.theme.button.margin.start.value / 2; 591 a2 -= this.theme.i2.margin.end.value; 592 a2 -= this.getCloseButtonWidth(); 593 } 594 return a2; 595 } 596 getMessageFontWeight() { 597 return this.theme.message.fontWeight; 598 } 599 getButtonMargin() { 600 return { 601 top: LengthMetrics.vp(this.theme.button.e2.top.value / 2 - 4), 602 bottom: LengthMetrics.vp(this.theme.button.e2.bottom.value / 2 - 4), 603 start: LengthMetrics.vp(this.theme.button.margin.start.value / 2 - 4), 604 end: LengthMetrics.vp(this.theme.button.margin.end.value / 2 - 4) 605 }; 606 } 607 getButtonTextMargin() { 608 return { top: LengthMetrics.vp(this.theme.button.e2.bottom.value) }; 609 } 610 getButtonTextPadding() { 611 return this.theme.button.padding; 612 } 613 getButtonHoverColor() { 614 return this.theme.button.f2; 615 } 616 getButtonBackgroundColor() { 617 return this.theme.button.backgroundColor; 618 } 619 getFirstButtonText() { 620 return this.buttons?.[0]?.text; 621 } 622 getSecondButtonText() { 623 return this.buttons?.[1]?.text; 624 } 625 getFirstButtonFontSize() { 626 return this.buttons?.[0]?.fontSize ?? this.theme.button.fontSize; 627 } 628 getSecondButtonFontSize() { 629 return this.buttons?.[1]?.fontSize ?? this.theme.button.fontSize; 630 } 631 getFirstButtonFontColor() { 632 return this.buttons?.[0]?.fontColor ?? this.theme.button.fontColor; 633 } 634 getSecondButtonFontColor() { 635 return this.buttons?.[1]?.fontColor ?? this.theme.button.fontColor; 636 } 637 getButtonMinFontSize() { 638 return this.theme.button.minFontSize; 639 } 640 getButtonFontWeight() { 641 return this.theme.button.fontWeight; 642 } 643 getWindowsPadding() { 644 let top = this.theme.h2.padding.top; 645 let bottom = LengthMetrics.vp(this.theme.h2.padding.bottom.value - (this.theme.button.e2.bottom.value / 2)); 646 let start = LengthMetrics.vp(this.theme.h2.padding.start.value - (this.theme.button.margin.end.value / 2)); 647 let end = this.theme.button.padding.end; 648 let z1 = this.toVp(this.maxWidth); 649 if (z1 === 0) { 650 start = LengthMetrics.vp(0); 651 end = LengthMetrics.vp(0); 652 } 653 return { 654 top: top, 655 bottom: bottom, 656 start: start, 657 end: end 658 }; 659 } 660 onWillApplyTheme(theme) { 661 this.theme.title.fontColor = theme.colors.fontPrimary; 662 this.theme.button.fontColor = theme.colors.fontEmphasize; 663 this.theme.message.fontColor = theme.colors.fontSecondary; 664 this.theme.message.g2 = theme.colors.fontPrimary; 665 this.closeButtonFillColorWithTheme = theme.colors.iconSecondary; 666 } 667 aboutToAppear() { 668 this.listener.on("change", (w1) => { 669 this.currentScreenStatus = w1.matches; 670 }); 671 } 672 aboutToDisappear() { 673 this.listener.off("change"); 674 } 675 getScrollMaxHeight() { 676 let v1 = undefined; 677 if (this.currentScreenStatus !== this.beforeScreenStatus) { 678 this.applySizeOptions = this.getApplyMaxSize(); 679 this.beforeScreenStatus = this.currentScreenStatus; 680 return v1; 681 } 682 v1 = px2vp(componentUtils.getRectangleById(this.applycontentKey).size?.height); 683 v1 -= this.titleHeight; 684 v1 -= this.buttonHeight; 685 v1 -= this.theme.h2.padding.top.value; 686 v1 -= (this.theme.button.e2.bottom.value / 2); 687 v1 -= this.theme.title.margin.bottom.value; 688 v1 -= (this.theme.h2.padding.bottom.value - 689 (this.theme.button.e2.bottom.value / 2)); 690 if (Math.floor(this.textHeight) > Math.floor(v1 + 1)) { 691 return v1; 692 } 693 else { 694 v1 = undefined; 695 return v1; 696 } 697 } 698 getLayoutWeight() { 699 let layoutWeight; 700 if ((this.icon.image !== '' && this.icon.image !== void (0)) || 701 (this.title.text !== '' && this.title.text !== void (0)) || 702 (this.buttons?.[0]?.text !== '' && this.buttons?.[0]?.text !== void (0)) || 703 (this.buttons?.[1]?.text !== '' && this.buttons?.[1]?.text !== void (0))) { 704 layoutWeight = 1; 705 } 706 else { 707 layoutWeight = 0; 708 } 709 return layoutWeight; 710 } 711 resourceToVp(value) { 712 try { 713 if (value.id !== -1) { 714 return px2vp(getContext(this).resourceManager.getNumber(value.id)); 715 } 716 else { 717 return px2vp(getContext(this) 718 .resourceManager 719 .getNumberByName((value.params[0]).split('.')[2])); 720 } 721 } 722 catch (error) { 723 return c1; 724 } 725 } 726 toVp(value) { 727 let s1 = undefined; 728 try { 729 s1 = display.getDefaultDisplaySync(); 730 } 731 catch (error) { 732 console.error(`Ace Popup getDefaultDisplaySync, error: ${error.toString()}`); 733 return Number.NEGATIVE_INFINITY; 734 } 735 if (value === void (0)) { 736 return Number.NEGATIVE_INFINITY; 737 } 738 switch (typeof (value)) { 739 case 'number': 740 return value; 741 case 'object': 742 try { 743 let u1 = this.resourceToVp(value); 744 if (u1 === 0 && 745 !m(getContext(this), value)) { 746 return Number.NEGATIVE_INFINITY; 747 } 748 return u1; 749 } 750 catch (error) { 751 return Number.NEGATIVE_INFINITY; 752 } 753 case 'string': 754 let t1 = new RegExp('(-?\\d+(?:\\.\\d+)?)_?(fp|vp|px|lpx|%)?$', 'i'); 755 let matches = value.match(t1); 756 if (!matches) { 757 return Number.NEGATIVE_INFINITY; 758 } 759 let length = Number(matches?.[1] ?? 0); 760 let unit = matches?.[2] ?? 'vp'; 761 switch (unit.toLowerCase()) { 762 case 'px': 763 length = px2vp(length); 764 break; 765 case 'fp': 766 length = px2vp(fp2px(length)); 767 break; 768 case 'lpx': 769 length = px2vp(lpx2px(length)); 770 break; 771 case '%': 772 length = length / 100 * px2vp(s1.width); 773 break; 774 case 'vp': 775 break; 776 default: 777 break; 778 } 779 return length; 780 default: 781 return Number.NEGATIVE_INFINITY; 782 } 783 } 784 getApplyMaxSize() { 785 let m1 = undefined; 786 let n1 = undefined; 787 let o1 = undefined; 788 let p1 = undefined; 789 let q1 = 400; 790 try { 791 p1 = display.getDefaultDisplaySync(); 792 } 793 catch (error) { 794 console.error(`Ace Popup getDefaultDisplaySync, error: ${error.toString()}`); 795 this.messageMaxWeight = 400; 796 return o1 = { maxWidth: 400, maxHeight: 480 }; 797 } 798 if (this.maxWidth !== undefined) { 799 if (typeof this.maxWidth === 'number' && this.maxWidth >= 0) { 800 q1 = this.maxWidth; 801 } 802 else if (typeof this.maxWidth === 'number' && this.maxWidth < 0) { 803 q1 = c1; 804 } 805 else { 806 q1 = this.toVp(this.maxWidth); 807 } 808 } 809 if (px2vp(p1.width) > q1) { 810 m1 = q1; 811 } 812 else { 813 if (p1.width != 0) { 814 m1 = px2vp(p1.width); 815 } 816 else { 817 m1 = -1; 818 } 819 } 820 if (px2vp(p1.height) > 480) { 821 n1 = 480; 822 } 823 else { 824 n1 = px2vp(p1.height) - 40 - 40; 825 } 826 o1 = { maxWidth: m1, maxHeight: n1 }; 827 this.messageMaxWidth = m1; 828 this.messageMaxWeight = this.getMessageMaxWeight(); 829 return o1; 830 } 831 getTitleTextAlign() { 832 let l1 = TextAlign.Start; 833 if ((Configuration.getLocale().dir === 'rtl') && this.popupDirection === Direction.Auto) { 834 l1 = TextAlign.End; 835 } 836 return l1; 837 } 838 initialRender() { 839 this.observeComponentCreation2((elmtId, isInitialRender) => { 840 Row.create(); 841 Row.direction(this.popupDirection); 842 Row.alignItems(VerticalAlign.Top); 843 Row.padding(this.getWindowsPadding()); 844 Row.constraintSize(ObservedObject.GetRawObject(this.applySizeOptions)); 845 Row.constraintSize(this.getApplyMaxSize()); 846 Row.key(this.applycontentKey); 847 Row.onAreaChange((k1, rect) => { 848 this.applyHeight = rect.height; 849 }); 850 }, Row); 851 this.observeComponentCreation2((elmtId, isInitialRender) => { 852 If.create(); 853 if (this.icon.image !== '' && this.icon.image !== void (0)) { 854 this.ifElseBranchUpdateFunction(0, () => { 855 this.observeComponentCreation2((elmtId, isInitialRender) => { 856 Image.create(this.getIconImage()); 857 Image.direction(this.popupDirection); 858 Image.width(this.getIconWidth()); 859 Image.height(this.getIconHeight()); 860 Image.margin(this.getIconMargin()); 861 Image.fillColor(this.getIconFillColor()); 862 Image.borderRadius(this.getIconBorderRadius()); 863 Image.draggable(false); 864 }, Image); 865 }); 866 } 867 else { 868 this.ifElseBranchUpdateFunction(1, () => { 869 }); 870 } 871 }, If); 872 If.pop(); 873 this.observeComponentCreation2((elmtId, isInitialRender) => { 874 If.create(); 875 if (this.title.text !== '' && this.title.text !== void (0)) { 876 this.ifElseBranchUpdateFunction(0, () => { 877 this.observeComponentCreation2((elmtId, isInitialRender) => { 878 Column.create(); 879 Column.direction(this.popupDirection); 880 Column.layoutWeight(this.getLayoutWeight()); 881 }, Column); 882 this.observeComponentCreation2((elmtId, isInitialRender) => { 883 Flex.create({ alignItems: ItemAlign.Start }); 884 Flex.direction(this.popupDirection); 885 Flex.width("100%"); 886 Flex.margin(this.getTitleMargin()); 887 Flex.onAreaChange((j1, rect) => { 888 this.titleHeight = rect.height; 889 }); 890 }, Flex); 891 this.observeComponentCreation2((elmtId, isInitialRender) => { 892 Text.create(this.getTitleText()); 893 Text.direction(this.popupDirection); 894 Text.flexGrow(1); 895 Text.maxLines(2); 896 Text.align(Alignment.Start); 897 Text.padding(this.getTitlePadding()); 898 Text.minFontSize(this.getTitleMinFontSize()); 899 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 900 Text.fontWeight(this.getTitleFontWeight()); 901 Text.fontSize(this.getTitleFontSize()); 902 Text.fontColor(this.getTitleFontColor()); 903 Text.constraintSize({ minHeight: this.getCloseButtonHeight() }); 904 Text.textAlign(this.getTitleTextAlign()); 905 }, Text); 906 Text.pop(); 907 this.observeComponentCreation2((elmtId, isInitialRender) => { 908 If.create(); 909 if (this.showClose || this.showClose === void (0)) { 910 this.ifElseBranchUpdateFunction(0, () => { 911 this.observeComponentCreation2((elmtId, isInitialRender) => { 912 Button.createWithChild(); 913 Button.direction(this.popupDirection); 914 Button.width(this.getCloseButtonWidth()); 915 Button.height(this.getCloseButtonHeight()); 916 Button.padding(this.getCloseButtonPadding()); 917 Button.backgroundColor(ObservedObject.GetRawObject(this.closeButtonBackgroundColor)); 918 Button.flexShrink(0); 919 Button.accessibilityText(this.theme.i2.l2); 920 Button.onHover((isHover) => { 921 if (isHover) { 922 this.closeButtonBackgroundColor = this.getCloseButtonHoverColor(); 923 } 924 else { 925 this.closeButtonBackgroundColor = this.getCloseButtonBackgroundColor(); 926 } 927 }); 928 Button.onClick(() => { 929 if (this.onClose) { 930 this.onClose(); 931 } 932 }); 933 }, Button); 934 this.observeComponentCreation2((elmtId, isInitialRender) => { 935 SymbolGlyph.create(); 936 SymbolGlyph.fontColor([this.getCloseButtonFillColor()]); 937 SymbolGlyph.fontSize(this.getCloseButtonSymbolSize()); 938 SymbolGlyph.direction(this.popupDirection); 939 SymbolGlyph.attributeModifier.bind(this)(this.theme.i2.symbolStyle); 940 SymbolGlyph.focusable(true); 941 SymbolGlyph.draggable(false); 942 }, SymbolGlyph); 943 Button.pop(); 944 }); 945 } 946 else { 947 this.ifElseBranchUpdateFunction(1, () => { 948 }); 949 } 950 }, If); 951 If.pop(); 952 Flex.pop(); 953 this.observeComponentCreation2((elmtId, isInitialRender) => { 954 Scroll.create(); 955 Scroll.direction(this.popupDirection); 956 Scroll.width("100%"); 957 Scroll.align(Alignment.TopStart); 958 Scroll.padding(this.getMessagePadding()); 959 Scroll.scrollBar(BarState.Auto); 960 Scroll.scrollable(ScrollDirection.Vertical); 961 Scroll.constraintSize({ maxHeight: this.getScrollMaxHeight() }); 962 Scroll.edgeEffect(EdgeEffect.Spring, { alwaysEnabled: false }); 963 }, Scroll); 964 this.observeComponentCreation2((elmtId, isInitialRender) => { 965 Text.create(this.getMessageText()); 966 Text.direction(this.popupDirection); 967 Text.fontSize(this.getMessageFontSize()); 968 Text.fontColor(this.getMessageFontColor()); 969 Text.fontWeight(this.getMessageFontWeight()); 970 Text.constraintSize({ minHeight: this.getCloseButtonHeight() }); 971 Text.onAreaChange((i1, rect) => { 972 this.textHeight = rect.height; 973 }); 974 }, Text); 975 Text.pop(); 976 Scroll.pop(); 977 this.observeComponentCreation2((elmtId, isInitialRender) => { 978 Flex.create({ wrap: FlexWrap.Wrap }); 979 Flex.direction(this.popupDirection); 980 Flex.margin(this.getButtonTextMargin()); 981 Flex.flexGrow(1); 982 Flex.onAreaChange((h1, rect) => { 983 if ((this.buttons?.[0]?.text !== '' && this.buttons?.[0]?.text !== void (0)) || 984 (this.buttons?.[1]?.text !== '' && this.buttons?.[1]?.text !== void (0))) { 985 this.buttonHeight = rect.height; 986 } 987 else { 988 this.buttonHeight = 0; 989 } 990 }); 991 }, Flex); 992 this.observeComponentCreation2((elmtId, isInitialRender) => { 993 If.create(); 994 if (this.buttons?.[0]?.text !== '' && this.buttons?.[0]?.text !== void (0)) { 995 this.ifElseBranchUpdateFunction(0, () => { 996 this.observeComponentCreation2((elmtId, isInitialRender) => { 997 Button.createWithChild(); 998 Button.type(ButtonType.Normal); 999 Button.borderRadius({ "id": -1, "type": 10002, params: ['sys.float.popup_button_border_radius'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1000 Button.direction(this.popupDirection); 1001 Button.margin(this.getButtonMargin()); 1002 Button.padding(this.getButtonTextPadding()); 1003 Button.backgroundColor(ObservedObject.GetRawObject(this.firstButtonBackgroundColor)); 1004 Button.onHover((isHover) => { 1005 if (isHover) { 1006 this.firstButtonBackgroundColor = this.getButtonHoverColor(); 1007 } 1008 else { 1009 this.firstButtonBackgroundColor = this.getButtonBackgroundColor(); 1010 } 1011 }); 1012 Button.onClick(() => { 1013 if (this.buttons?.[0]?.action) { 1014 this.buttons?.[0]?.action(); 1015 } 1016 }); 1017 }, Button); 1018 this.observeComponentCreation2((elmtId, isInitialRender) => { 1019 Text.create(this.getFirstButtonText()); 1020 Text.direction(this.popupDirection); 1021 Text.maxLines(2); 1022 Text.focusable(true); 1023 Text.fontSize(this.getFirstButtonFontSize()); 1024 Text.fontColor(this.getFirstButtonFontColor()); 1025 Text.fontWeight(this.getButtonFontWeight()); 1026 Text.minFontSize(this.getButtonMinFontSize()); 1027 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1028 }, Text); 1029 Text.pop(); 1030 Button.pop(); 1031 }); 1032 } 1033 else { 1034 this.ifElseBranchUpdateFunction(1, () => { 1035 }); 1036 } 1037 }, If); 1038 If.pop(); 1039 this.observeComponentCreation2((elmtId, isInitialRender) => { 1040 If.create(); 1041 if (this.buttons?.[1]?.text !== '' && this.buttons?.[1]?.text !== void (0)) { 1042 this.ifElseBranchUpdateFunction(0, () => { 1043 this.observeComponentCreation2((elmtId, isInitialRender) => { 1044 Button.createWithChild(); 1045 Button.type(ButtonType.Normal); 1046 Button.borderRadius({ "id": -1, "type": 10002, params: ['sys.float.popup_button_border_radius'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1047 Button.direction(this.popupDirection); 1048 Button.margin(this.getButtonMargin()); 1049 Button.padding(this.getButtonTextPadding()); 1050 Button.backgroundColor(ObservedObject.GetRawObject(this.secondButtonBackgroundColor)); 1051 Button.onHover((isHover) => { 1052 if (isHover) { 1053 this.secondButtonBackgroundColor = this.getButtonHoverColor(); 1054 } 1055 else { 1056 this.secondButtonBackgroundColor = this.getButtonBackgroundColor(); 1057 } 1058 }); 1059 Button.onClick(() => { 1060 if (this.buttons?.[1]?.action) { 1061 this.buttons?.[1]?.action(); 1062 } 1063 }); 1064 }, Button); 1065 this.observeComponentCreation2((elmtId, isInitialRender) => { 1066 Text.create(this.getSecondButtonText()); 1067 Text.direction(this.popupDirection); 1068 Text.maxLines(2); 1069 Text.focusable(true); 1070 Text.fontSize(this.getSecondButtonFontSize()); 1071 Text.fontColor(this.getSecondButtonFontColor()); 1072 Text.fontWeight(this.getButtonFontWeight()); 1073 Text.minFontSize(this.getButtonMinFontSize()); 1074 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1075 }, Text); 1076 Text.pop(); 1077 Button.pop(); 1078 }); 1079 } 1080 else { 1081 this.ifElseBranchUpdateFunction(1, () => { 1082 }); 1083 } 1084 }, If); 1085 If.pop(); 1086 Flex.pop(); 1087 Column.pop(); 1088 }); 1089 } 1090 else { 1091 this.ifElseBranchUpdateFunction(1, () => { 1092 this.observeComponentCreation2((elmtId, isInitialRender) => { 1093 Column.create(); 1094 Column.direction(this.popupDirection); 1095 Column.layoutWeight(this.getLayoutWeight()); 1096 }, Column); 1097 this.observeComponentCreation2((elmtId, isInitialRender) => { 1098 Flex.create(); 1099 Flex.height(0); 1100 Flex.onAreaChange((g1, rect) => { 1101 this.titleHeight = rect.height; 1102 }); 1103 }, Flex); 1104 Flex.pop(); 1105 this.observeComponentCreation2((elmtId, isInitialRender) => { 1106 Row.create(); 1107 Row.direction(this.popupDirection); 1108 Row.alignItems(VerticalAlign.Top); 1109 }, Row); 1110 this.observeComponentCreation2((elmtId, isInitialRender) => { 1111 Scroll.create(); 1112 Scroll.direction(this.popupDirection); 1113 Scroll.layoutWeight(this.getLayoutWeight()); 1114 Scroll.edgeEffect(EdgeEffect.Spring, { alwaysEnabled: false }); 1115 Scroll.align(Alignment.TopStart); 1116 Scroll.padding(this.getMessagePadding()); 1117 Scroll.scrollBar(BarState.Auto); 1118 Scroll.scrollable(ScrollDirection.Vertical); 1119 Scroll.constraintSize({ maxHeight: this.getScrollMaxHeight() }); 1120 }, Scroll); 1121 this.observeComponentCreation2((elmtId, isInitialRender) => { 1122 Text.create(this.getMessageText()); 1123 Text.direction(this.popupDirection); 1124 Text.fontSize(this.getMessageFontSize()); 1125 Text.fontColor(this.getMessageFontColor()); 1126 Text.fontWeight(this.getMessageFontWeight()); 1127 Text.constraintSize({ maxWidth: this.messageMaxWeight, minHeight: this.getCloseButtonHeight() }); 1128 Text.onAreaChange((f1, rect) => { 1129 this.textHeight = rect.height; 1130 }); 1131 }, Text); 1132 Text.pop(); 1133 Scroll.pop(); 1134 this.observeComponentCreation2((elmtId, isInitialRender) => { 1135 If.create(); 1136 if (this.showClose || this.showClose === void (0)) { 1137 this.ifElseBranchUpdateFunction(0, () => { 1138 this.observeComponentCreation2((elmtId, isInitialRender) => { 1139 Button.createWithChild(); 1140 Button.direction(this.popupDirection); 1141 Button.width(this.getCloseButtonWidth()); 1142 Button.height(this.getCloseButtonHeight()); 1143 Button.padding(this.getCloseButtonPadding()); 1144 Button.backgroundColor(ObservedObject.GetRawObject(this.closeButtonBackgroundColor)); 1145 Button.flexShrink(0); 1146 Button.accessibilityText(this.theme.i2.l2); 1147 Button.onHover((isHover) => { 1148 if (isHover) { 1149 this.closeButtonBackgroundColor = this.getCloseButtonHoverColor(); 1150 } 1151 else { 1152 this.closeButtonBackgroundColor = this.getCloseButtonBackgroundColor(); 1153 } 1154 }); 1155 Button.onClick(() => { 1156 if (this.onClose) { 1157 this.onClose(); 1158 } 1159 }); 1160 }, Button); 1161 this.observeComponentCreation2((elmtId, isInitialRender) => { 1162 SymbolGlyph.create(); 1163 SymbolGlyph.fontColor([this.getCloseButtonFillColor()]); 1164 SymbolGlyph.fontSize(this.getCloseButtonSymbolSize()); 1165 SymbolGlyph.direction(this.popupDirection); 1166 SymbolGlyph.attributeModifier.bind(this)(this.theme.i2.symbolStyle); 1167 SymbolGlyph.focusable(true); 1168 SymbolGlyph.draggable(false); 1169 }, SymbolGlyph); 1170 Button.pop(); 1171 }); 1172 } 1173 else { 1174 this.ifElseBranchUpdateFunction(1, () => { 1175 }); 1176 } 1177 }, If); 1178 If.pop(); 1179 Row.pop(); 1180 this.observeComponentCreation2((elmtId, isInitialRender) => { 1181 Flex.create({ wrap: FlexWrap.Wrap }); 1182 Flex.direction(this.popupDirection); 1183 Flex.margin(this.getButtonTextMargin()); 1184 Flex.flexGrow(1); 1185 Flex.onAreaChange((e1, rect) => { 1186 if ((this.buttons?.[0]?.text !== '' && this.buttons?.[0]?.text !== void (0)) || 1187 (this.buttons?.[1]?.text !== '' && this.buttons?.[1]?.text !== void (0))) { 1188 this.buttonHeight = rect.height; 1189 } 1190 else { 1191 this.buttonHeight = 0; 1192 } 1193 }); 1194 }, Flex); 1195 this.observeComponentCreation2((elmtId, isInitialRender) => { 1196 If.create(); 1197 if (this.buttons?.[0]?.text !== '' && this.buttons?.[0]?.text !== void (0)) { 1198 this.ifElseBranchUpdateFunction(0, () => { 1199 this.observeComponentCreation2((elmtId, isInitialRender) => { 1200 Button.createWithChild(); 1201 Button.type(ButtonType.Normal); 1202 Button.borderRadius({ "id": -1, "type": 10002, params: ['sys.float.popup_button_border_radius'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1203 Button.direction(this.popupDirection); 1204 Button.margin(this.getButtonMargin()); 1205 Button.padding(this.getButtonTextPadding()); 1206 Button.backgroundColor(ObservedObject.GetRawObject(this.firstButtonBackgroundColor)); 1207 Button.onHover((isHover) => { 1208 if (isHover) { 1209 this.firstButtonBackgroundColor = this.getButtonHoverColor(); 1210 } 1211 else { 1212 this.firstButtonBackgroundColor = this.getButtonBackgroundColor(); 1213 } 1214 }); 1215 Button.onClick(() => { 1216 if (this.buttons?.[0]?.action) { 1217 this.buttons?.[0]?.action(); 1218 } 1219 }); 1220 }, Button); 1221 this.observeComponentCreation2((elmtId, isInitialRender) => { 1222 Text.create(this.getFirstButtonText()); 1223 Text.direction(this.popupDirection); 1224 Text.maxLines(2); 1225 Text.focusable(true); 1226 Text.fontSize(this.getFirstButtonFontSize()); 1227 Text.fontColor(this.getFirstButtonFontColor()); 1228 Text.fontWeight(this.getButtonFontWeight()); 1229 Text.minFontSize(this.getButtonMinFontSize()); 1230 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1231 }, Text); 1232 Text.pop(); 1233 Button.pop(); 1234 }); 1235 } 1236 else { 1237 this.ifElseBranchUpdateFunction(1, () => { 1238 }); 1239 } 1240 }, If); 1241 If.pop(); 1242 this.observeComponentCreation2((elmtId, isInitialRender) => { 1243 If.create(); 1244 if (this.buttons?.[1]?.text !== '' && this.buttons?.[1]?.text !== void (0)) { 1245 this.ifElseBranchUpdateFunction(0, () => { 1246 this.observeComponentCreation2((elmtId, isInitialRender) => { 1247 Button.createWithChild(); 1248 Button.type(ButtonType.Normal); 1249 Button.borderRadius({ "id": -1, "type": 10002, params: ['sys.float.popup_button_border_radius'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); 1250 Button.direction(this.popupDirection); 1251 Button.margin(this.getButtonMargin()); 1252 Button.padding(this.getButtonTextPadding()); 1253 Button.backgroundColor(ObservedObject.GetRawObject(this.secondButtonBackgroundColor)); 1254 Button.onHover((isHover) => { 1255 if (isHover) { 1256 this.secondButtonBackgroundColor = this.getButtonHoverColor(); 1257 } 1258 else { 1259 this.secondButtonBackgroundColor = this.getButtonBackgroundColor(); 1260 } 1261 }); 1262 Button.onClick(() => { 1263 if (this.buttons?.[1]?.action) { 1264 this.buttons?.[1]?.action(); 1265 } 1266 }); 1267 }, Button); 1268 this.observeComponentCreation2((elmtId, isInitialRender) => { 1269 Text.create(this.getSecondButtonText()); 1270 Text.direction(this.popupDirection); 1271 Text.maxLines(2); 1272 Text.focusable(true); 1273 Text.fontSize(this.getSecondButtonFontSize()); 1274 Text.fontColor(this.getSecondButtonFontColor()); 1275 Text.fontWeight(this.getButtonFontWeight()); 1276 Text.minFontSize(this.getButtonMinFontSize()); 1277 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1278 }, Text); 1279 Text.pop(); 1280 Button.pop(); 1281 }); 1282 } 1283 else { 1284 this.ifElseBranchUpdateFunction(1, () => { 1285 }); 1286 } 1287 }, If); 1288 If.pop(); 1289 Flex.pop(); 1290 Column.pop(); 1291 }); 1292 } 1293 }, If); 1294 If.pop(); 1295 Row.pop(); 1296 } 1297 rerender() { 1298 this.updateDirtyElements(); 1299 } 1300} 1301 1302export default { Popup };