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'); 26 27const o = 10003; 28const t = 10002; 29const u = 10007; 30 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 d2: { 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 e2: { "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 f2: { "id": -1, "type": 10001, params: ['sys.color.font_primary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" } 81 }, 82 g2: { 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 h2: { 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 e2: { "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 i2: 18, 109 e1: { "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 c2 = options; 117 { 118 (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, options = c2) => { 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: 209, j2: 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, b2) { 160 const matches = dimension.match(b2); 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.__icon = new SynchedPropertyObjectOneWayPU(params.icon, this, "icon"); 203 this.__maxWidth = new SynchedPropertyObjectOneWayPU(params.maxWidth, this, "maxWidth"); 204 this.__messageMaxWidth = new SynchedPropertySimpleOneWayPU(params.messageMaxWidth, this, "messageMaxWidth"); 205 this.__title = new SynchedPropertyObjectOneWayPU(params.title, this, "title"); 206 this.__message = new SynchedPropertyObjectOneWayPU(params.message, this, "message"); 207 this.__popupDirection = new SynchedPropertySimpleOneWayPU(params.popupDirection, this, "popupDirection"); 208 this.__showClose = new SynchedPropertyObjectOneWayPU(params.showClose, this, "showClose"); 209 this.__buttons = new SynchedPropertyObjectOneWayPU(params.buttons, this, "buttons"); 210 this.textHeight = 0; 211 this.__titleHeight = new ObservedPropertySimplePU(0, this, "titleHeight"); 212 this.__applyHeight = new ObservedPropertySimplePU(0, this, "applyHeight"); 213 this.__buttonHeight = new ObservedPropertySimplePU(0, this, "buttonHeight"); 214 this.__messageMaxWeight = new ObservedPropertyObjectPU(0, this, "messageMaxWeight"); 215 this.__beforeScreenStatus = new ObservedPropertySimplePU(undefined, this, "beforeScreenStatus"); 216 this.__currentScreenStatus = new ObservedPropertySimplePU(true, this, "currentScreenStatus"); 217 this.__applySizeOptions = new ObservedPropertyObjectPU(undefined, this, "applySizeOptions"); 218 this.__closeButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "closeButtonBackgroundColor"); 219 this.__firstButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "firstButtonBackgroundColor"); 220 this.__secondButtonBackgroundColor = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_background_transparent'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "secondButtonBackgroundColor"); 221 this.__closeButtonFillColorWithTheme = new ObservedPropertyObjectPU({ "id": -1, "type": 10001, params: ['sys.color.icon_secondary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }, this, "closeButtonFillColorWithTheme"); 222 this.listener = mediaquery.matchMediaSync('(orientation: landscape)'); 223 this.setInitiallyProvidedValue(params); 224 this.finalizeConstruction(); 225 } 226 setInitiallyProvidedValue(params) { 227 if (params.onClose !== undefined) { 228 this.onClose = params.onClose; 229 } 230 if (params.theme !== undefined) { 231 this.theme = params.theme; 232 } 233 if (params.icon === undefined) { 234 this.__icon.set({ image: '' }); 235 } 236 if (params.messageMaxWidth === undefined) { 237 this.__messageMaxWidth.set(0); 238 } 239 if (params.title === undefined) { 240 this.__title.set({ text: '' }); 241 } 242 if (params.message === undefined) { 243 this.__message.set({ text: '' }); 244 } 245 if (params.popupDirection === undefined) { 246 this.__popupDirection.set(Direction.Auto); 247 } 248 if (params.showClose === undefined) { 249 this.__showClose.set(true); 250 } 251 if (params.buttons === undefined) { 252 this.__buttons.set([{ text: '' }, { text: '' }]); 253 } 254 if (params.textHeight !== undefined) { 255 this.textHeight = params.textHeight; 256 } 257 if (params.titleHeight !== undefined) { 258 this.titleHeight = params.titleHeight; 259 } 260 if (params.applyHeight !== undefined) { 261 this.applyHeight = params.applyHeight; 262 } 263 if (params.buttonHeight !== undefined) { 264 this.buttonHeight = params.buttonHeight; 265 } 266 if (params.messageMaxWeight !== undefined) { 267 this.messageMaxWeight = params.messageMaxWeight; 268 } 269 if (params.beforeScreenStatus !== undefined) { 270 this.beforeScreenStatus = params.beforeScreenStatus; 271 } 272 if (params.currentScreenStatus !== undefined) { 273 this.currentScreenStatus = params.currentScreenStatus; 274 } 275 if (params.applySizeOptions !== undefined) { 276 this.applySizeOptions = params.applySizeOptions; 277 } 278 if (params.closeButtonBackgroundColor !== undefined) { 279 this.closeButtonBackgroundColor = params.closeButtonBackgroundColor; 280 } 281 if (params.firstButtonBackgroundColor !== undefined) { 282 this.firstButtonBackgroundColor = params.firstButtonBackgroundColor; 283 } 284 if (params.secondButtonBackgroundColor !== undefined) { 285 this.secondButtonBackgroundColor = params.secondButtonBackgroundColor; 286 } 287 if (params.closeButtonFillColorWithTheme !== undefined) { 288 this.closeButtonFillColorWithTheme = params.closeButtonFillColorWithTheme; 289 } 290 if (params.listener !== undefined) { 291 this.listener = params.listener; 292 } 293 } 294 updateStateVars(params) { 295 this.__icon.reset(params.icon); 296 this.__maxWidth.reset(params.maxWidth); 297 this.__messageMaxWidth.reset(params.messageMaxWidth); 298 this.__title.reset(params.title); 299 this.__message.reset(params.message); 300 this.__popupDirection.reset(params.popupDirection); 301 this.__showClose.reset(params.showClose); 302 this.__buttons.reset(params.buttons); 303 } 304 purgeVariableDependenciesOnElmtId(rmElmtId) { 305 this.__icon.purgeDependencyOnElmtId(rmElmtId); 306 this.__maxWidth.purgeDependencyOnElmtId(rmElmtId); 307 this.__messageMaxWidth.purgeDependencyOnElmtId(rmElmtId); 308 this.__title.purgeDependencyOnElmtId(rmElmtId); 309 this.__message.purgeDependencyOnElmtId(rmElmtId); 310 this.__popupDirection.purgeDependencyOnElmtId(rmElmtId); 311 this.__showClose.purgeDependencyOnElmtId(rmElmtId); 312 this.__buttons.purgeDependencyOnElmtId(rmElmtId); 313 this.__titleHeight.purgeDependencyOnElmtId(rmElmtId); 314 this.__applyHeight.purgeDependencyOnElmtId(rmElmtId); 315 this.__buttonHeight.purgeDependencyOnElmtId(rmElmtId); 316 this.__messageMaxWeight.purgeDependencyOnElmtId(rmElmtId); 317 this.__beforeScreenStatus.purgeDependencyOnElmtId(rmElmtId); 318 this.__currentScreenStatus.purgeDependencyOnElmtId(rmElmtId); 319 this.__applySizeOptions.purgeDependencyOnElmtId(rmElmtId); 320 this.__closeButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 321 this.__firstButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 322 this.__secondButtonBackgroundColor.purgeDependencyOnElmtId(rmElmtId); 323 this.__closeButtonFillColorWithTheme.purgeDependencyOnElmtId(rmElmtId); 324 } 325 aboutToBeDeleted() { 326 this.__icon.aboutToBeDeleted(); 327 this.__maxWidth.aboutToBeDeleted(); 328 this.__messageMaxWidth.aboutToBeDeleted(); 329 this.__title.aboutToBeDeleted(); 330 this.__message.aboutToBeDeleted(); 331 this.__popupDirection.aboutToBeDeleted(); 332 this.__showClose.aboutToBeDeleted(); 333 this.__buttons.aboutToBeDeleted(); 334 this.__titleHeight.aboutToBeDeleted(); 335 this.__applyHeight.aboutToBeDeleted(); 336 this.__buttonHeight.aboutToBeDeleted(); 337 this.__messageMaxWeight.aboutToBeDeleted(); 338 this.__beforeScreenStatus.aboutToBeDeleted(); 339 this.__currentScreenStatus.aboutToBeDeleted(); 340 this.__applySizeOptions.aboutToBeDeleted(); 341 this.__closeButtonBackgroundColor.aboutToBeDeleted(); 342 this.__firstButtonBackgroundColor.aboutToBeDeleted(); 343 this.__secondButtonBackgroundColor.aboutToBeDeleted(); 344 this.__closeButtonFillColorWithTheme.aboutToBeDeleted(); 345 SubscriberManager.Get().delete(this.id__()); 346 this.aboutToBeDeletedInternal(); 347 } 348 get icon() { 349 return this.__icon.get(); 350 } 351 set icon(newValue) { 352 this.__icon.set(newValue); 353 } 354 get maxWidth() { 355 return this.__maxWidth.get(); 356 } 357 set maxWidth(newValue) { 358 this.__maxWidth.set(newValue); 359 } 360 get messageMaxWidth() { 361 return this.__messageMaxWidth.get(); 362 } 363 set messageMaxWidth(newValue) { 364 this.__messageMaxWidth.set(newValue); 365 } 366 get title() { 367 return this.__title.get(); 368 } 369 set title(newValue) { 370 this.__title.set(newValue); 371 } 372 get message() { 373 return this.__message.get(); 374 } 375 set message(newValue) { 376 this.__message.set(newValue); 377 } 378 get popupDirection() { 379 return this.__popupDirection.get(); 380 } 381 set popupDirection(newValue) { 382 this.__popupDirection.set(newValue); 383 } 384 get showClose() { 385 return this.__showClose.get(); 386 } 387 set showClose(newValue) { 388 this.__showClose.set(newValue); 389 } 390 get buttons() { 391 return this.__buttons.get(); 392 } 393 set buttons(newValue) { 394 this.__buttons.set(newValue); 395 } 396 get titleHeight() { 397 return this.__titleHeight.get(); 398 } 399 set titleHeight(newValue) { 400 this.__titleHeight.set(newValue); 401 } 402 get applyHeight() { 403 return this.__applyHeight.get(); 404 } 405 set applyHeight(newValue) { 406 this.__applyHeight.set(newValue); 407 } 408 get buttonHeight() { 409 return this.__buttonHeight.get(); 410 } 411 set buttonHeight(newValue) { 412 this.__buttonHeight.set(newValue); 413 } 414 get messageMaxWeight() { 415 return this.__messageMaxWeight.get(); 416 } 417 set messageMaxWeight(newValue) { 418 this.__messageMaxWeight.set(newValue); 419 } 420 get beforeScreenStatus() { 421 return this.__beforeScreenStatus.get(); 422 } 423 set beforeScreenStatus(newValue) { 424 this.__beforeScreenStatus.set(newValue); 425 } 426 get currentScreenStatus() { 427 return this.__currentScreenStatus.get(); 428 } 429 set currentScreenStatus(newValue) { 430 this.__currentScreenStatus.set(newValue); 431 } 432 get applySizeOptions() { 433 return this.__applySizeOptions.get(); 434 } 435 set applySizeOptions(newValue) { 436 this.__applySizeOptions.set(newValue); 437 } 438 get closeButtonBackgroundColor() { 439 return this.__closeButtonBackgroundColor.get(); 440 } 441 set closeButtonBackgroundColor(newValue) { 442 this.__closeButtonBackgroundColor.set(newValue); 443 } 444 get firstButtonBackgroundColor() { 445 return this.__firstButtonBackgroundColor.get(); 446 } 447 set firstButtonBackgroundColor(newValue) { 448 this.__firstButtonBackgroundColor.set(newValue); 449 } 450 get secondButtonBackgroundColor() { 451 return this.__secondButtonBackgroundColor.get(); 452 } 453 set secondButtonBackgroundColor(newValue) { 454 this.__secondButtonBackgroundColor.set(newValue); 455 } 456 get closeButtonFillColorWithTheme() { 457 return this.__closeButtonFillColorWithTheme.get(); 458 } 459 set closeButtonFillColorWithTheme(newValue) { 460 this.__closeButtonFillColorWithTheme.set(newValue); 461 } 462 getIconWidth() { 463 return this.icon?.width ?? this.theme.icon.size.width; 464 } 465 getIconHeight() { 466 return this.icon?.height ?? this.theme.icon.size.height; 467 } 468 getIconFillColor() { 469 return this.icon?.fillColor ?? this.theme.icon.fillColor; 470 } 471 getIconBorderRadius() { 472 return this.icon?.borderRadius ?? this.theme.icon.borderRadius; 473 } 474 getIconMargin() { 475 return { 476 start: new LengthMetrics(this.theme.button.margin.start.value / 2, this.theme.button.margin.start.unit), 477 end: new LengthMetrics(this.theme.icon.margin.start.value - (this.theme.button.margin.end.value / 2), this.theme.button.margin.start.unit) 478 }; 479 } 480 getIconImage() { 481 return this.icon?.image; 482 } 483 getTitleText() { 484 return this.title?.text; 485 } 486 getTitlePadding() { 487 return { 488 start: new LengthMetrics(this.theme.button.margin.start.value / 2, this.theme.button.margin.start.unit), 489 end: this.theme.h2.margin.end 490 }; 491 } 492 getTitleMargin() { 493 return this.theme.title.margin; 494 } 495 getTitleMinFontSize() { 496 return this.theme.title.minFontSize; 497 } 498 getTitleFontWeight() { 499 return this.title?.fontWeight ?? this.theme.title.fontWeight; 500 } 501 getTitleFontSize() { 502 return this.title?.fontSize ?? this.theme.title.fontSize; 503 } 504 getTitleFontColor() { 505 return this.title?.fontColor ?? this.theme.title.fontColor; 506 } 507 getCloseButtonWidth() { 508 return this.theme.h2.size.width; 509 } 510 getCloseButtonHeight() { 511 return this.theme.h2.size.height; 512 } 513 getCloseButtonFillColor() { 514 return this.closeButtonFillColorWithTheme; 515 } 516 getCloseButtonHoverColor() { 517 return this.theme.h2.e2; 518 } 519 getCloseButtonBackgroundColor() { 520 return this.theme.h2.backgroundColor; 521 } 522 getCloseButtonPadding() { 523 return this.theme.h2.padding; 524 } 525 getCloseButtonSymbolSize() { 526 return this.theme.h2.i2; 527 } 528 getMessageText() { 529 return this.message.text; 530 } 531 getMessageFontSize() { 532 return this.message.fontSize ?? this.theme.message.fontSize; 533 } 534 getMessageFontColor() { 535 let fontColor; 536 if (this.message.fontColor) { 537 fontColor = this.message.fontColor; 538 } 539 else { 540 if (this.title.text !== '' && this.title.text !== void (0)) { 541 fontColor = this.theme.message.fontColor; 542 } 543 else { 544 fontColor = this.theme.message.f2; 545 } 546 } 547 return fontColor; 548 } 549 getMessagePadding() { 550 let padding; 551 if (this.title.text !== '' && this.title.text !== void (0)) { 552 padding = { start: LengthMetrics.vp(this.theme.button.margin.start.value / 2) }; 553 } 554 else { 555 padding = { 556 start: LengthMetrics.vp(this.theme.button.margin.start.value / 2), 557 end: LengthMetrics.vp(this.theme.h2.margin.end.value) 558 }; 559 } 560 return padding; 561 } 562 getMessageMaxWeight() { 563 let z1 = undefined; 564 let a2 = undefined; 565 try { 566 a2 = display.getDefaultDisplaySync(); 567 } 568 catch (error) { 569 console.error(`Ace Popup getDefaultDisplaySync, error: ${error.toString()}`); 570 return z1 = 400; 571 } 572 if (this.showClose || this.showClose === void (0)) { 573 if (this.messageMaxWidth != undefined) { 574 if (this.maxWidth != undefined && this.maxWidth > px2vp(a2.width)) { 575 z1 = px2vp(a2.width); 576 } 577 else { 578 z1 = this.messageMaxWidth; 579 } 580 } 581 else { 582 if (a2.width != 0) { 583 z1 = px2vp(a2.width); 584 } 585 else { 586 z1 = -1; 587 } 588 } 589 z1 -= (this.theme.g2.padding.start.value - (this.theme.button.margin.end.value / 2)); 590 z1 -= this.theme.g2.padding.end.value; 591 z1 -= this.theme.button.margin.start.value / 2; 592 z1 -= this.getCloseButtonWidth(); 593 } 594 return z1; 595 } 596 getMessageFontWeight() { 597 return this.theme.message.fontWeight; 598 } 599 getButtonMargin() { 600 return { 601 top: LengthMetrics.vp(this.theme.button.d2.top.value / 2 - 4), 602 bottom: LengthMetrics.vp(this.theme.button.d2.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.d2.bottom.value) }; 609 } 610 getButtonTextPadding() { 611 return this.theme.button.padding; 612 } 613 getButtonHoverColor() { 614 return this.theme.button.e2; 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.g2.padding.top; 645 let bottom = LengthMetrics.vp(this.theme.g2.padding.bottom.value - (this.theme.button.d2.bottom.value / 2)); 646 let start = LengthMetrics.vp(this.theme.g2.padding.start.value - (this.theme.button.margin.end.value / 2)); 647 let end = this.theme.g2.padding.end; 648 let w1 = this.toVp(this.maxWidth); 649 if (w1 === 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.f2 = theme.colors.fontPrimary; 665 this.closeButtonFillColorWithTheme = theme.colors.iconSecondary; 666 } 667 aboutToAppear() { 668 this.listener.on("change", (v1) => { 669 this.currentScreenStatus = v1.matches; 670 }); 671 } 672 aboutToDisappear() { 673 this.listener.off("change"); 674 } 675 getScrollMaxHeight() { 676 let u1 = undefined; 677 if (this.currentScreenStatus !== this.beforeScreenStatus) { 678 this.applySizeOptions = this.getApplyMaxSize(); 679 this.beforeScreenStatus = this.currentScreenStatus; 680 return u1; 681 } 682 u1 = px2vp(componentUtils.getRectangleById('applyContent').size?.height); 683 u1 -= this.titleHeight; 684 u1 -= this.buttonHeight; 685 u1 -= this.theme.g2.padding.top.value; 686 u1 -= (this.theme.button.d2.bottom.value / 2); 687 u1 -= this.theme.title.margin.bottom.value; 688 u1 -= (this.theme.g2.padding.bottom.value - 689 (this.theme.button.d2.bottom.value / 2)); 690 if (Math.floor(this.textHeight) > Math.floor(u1 + 1)) { 691 return u1; 692 } 693 else { 694 u1 = undefined; 695 return u1; 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 q1 = undefined; 728 try { 729 q1 = 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 t1 = this.resourceToVp(value); 744 if (t1 === 0 && 745 !m(getContext(this), value)) { 746 return Number.NEGATIVE_INFINITY; 747 } 748 return t1; 749 } 750 catch (error) { 751 return Number.NEGATIVE_INFINITY; 752 } 753 case 'string': 754 let s1 = new RegExp('(-?\\d+(?:\\.\\d+)?)_?(fp|vp|px|lpx|%)?$', 'i'); 755 let matches = value.match(s1); 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(q1.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 l1 = undefined; 786 let m1 = undefined; 787 let n1 = undefined; 788 let o1 = undefined; 789 let p1 = 400; 790 try { 791 o1 = display.getDefaultDisplaySync(); 792 } 793 catch (error) { 794 console.error(`Ace Popup getDefaultDisplaySync, error: ${error.toString()}`); 795 this.messageMaxWeight = 400; 796 return n1 = { maxWidth: 400, maxHeight: 480 }; 797 } 798 if (this.maxWidth !== undefined) { 799 if (typeof this.maxWidth === 'number' && this.maxWidth >= 0) { 800 p1 = this.maxWidth; 801 } 802 else if (typeof this.maxWidth === 'number' && this.maxWidth < 0) { 803 p1 = c1; 804 } 805 else { 806 p1 = this.toVp(this.maxWidth); 807 } 808 } 809 if (px2vp(o1.width) > p1) { 810 l1 = p1; 811 } 812 else { 813 if (o1.width != 0) { 814 l1 = px2vp(o1.width); 815 } 816 else { 817 l1 = -1; 818 } 819 } 820 if (px2vp(o1.height) > 480) { 821 m1 = 480; 822 } 823 else { 824 m1 = px2vp(o1.height) - 40 - 40; 825 } 826 n1 = { maxWidth: l1, maxHeight: m1 }; 827 this.messageMaxWidth = l1; 828 this.messageMaxWeight = this.getMessageMaxWeight(); 829 return n1; 830 } 831 getTitleTextAlign() { 832 let k2 = TextAlign.Start; 833 if ((Configuration.getLocale().dir === 'rtl') && this.popupDirection === Direction.Auto) { 834 k2 = TextAlign.End; 835 } 836 return k2; 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('applyContent'); 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.h2.e1); 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.h2.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.h2.e1); 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.h2.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 };