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} 19const hilog = requireNapi('hilog'); 20const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; 21const resourceManager = requireNapi('resourceManager'); 22const LengthMetrics = requireNapi('arkui.node').LengthMetrics; 23export var EditableLeftIconType; 24(function (x10) { 25 x10[x10['Back'] = 0] = 'Back'; 26 x10[x10['Cancel'] = 1] = 'Cancel'; 27})(EditableLeftIconType || (EditableLeftIconType = {})); 28var ItemType; 29(function (w10) { 30 w10[w10['Image'] = 0] = 'Image'; 31 w10[w10['Icon'] = 1] = 'Icon'; 32 w10[w10['LeftIcon'] = 2] = 'LeftIcon'; 33})(ItemType || (ItemType = {})); 34const PUBLIC_CANCEL = { 'id': -1, 'type': 40000, params: ['sys.symbol.xmark'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 35const PUBLIC_OK = { 'id': -1, 'type': 40000, params: ['sys.symbol.checkmark'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 36const PUBLIC_BACK = { 'id': -1, 'type': 40000, params: ['sys.symbol.chevron_backward'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 37const DEFAULT_TITLE_BAR_HEIGHT = 56; 38const DEFAULT_TITLE_PADDING = 2; 39const MAX_LINE_ONE = 1; 40const MAX_LINES_TWO = 2; 41const MAX_MAIN_TITLE_PERCENT = 0.65; 42const MAX_SUB_TITLE_PERCENT = 0.35; 43const MIN_SUBTITLE_SIZE = '10.0vp'; 44const TEXT_EDITABLE_DIALOG = '18.3fp'; 45const IMAGE_SIZE = '64vp'; 46const MAX_DIALOG = '256vp'; 47const MIN_DIALOG = '216vp'; 48const SYMBOL_SIZE = '24vp'; 49const SYMBOL_TITLE_SIZE = '64vp'; 50const TITLE_VP = 20; 51const SUBTITLE_VP = 14; 52const TITLE_F = getNumberByResource(125831095, TITLE_VP); 53const SUBTITLE_F = getNumberByResource(125831097, SUBTITLE_VP); 54const TITLE_F_VP = (TITLE_F > 0 ? TITLE_F : TITLE_VP) + 'vp'; 55const SUBTITLE_F_VP = (SUBTITLE_F > 0 ? SUBTITLE_F : SUBTITLE_VP) + 'vp'; 56class EditableTitleBarTheme { 57 constructor() { 58 this.iconColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 59 this.iconBackgroundColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 60 this.iconBackgroundPressedColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_pressed_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 61 this.iconBackgroundHoverColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_hover_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 62 this.iconBackgroundFocusOutlineColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_focus_outline_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 63 this.titleColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_title_tertiary_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 64 this.subTitleColor = { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_subheader_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 65 } 66} 67class ButtonGestureModifier { 68 constructor(v10) { 69 this.fontSize = 1; 70 this.controller = null; 71 this.controller = v10; 72 } 73 applyGesture(s10) { 74 if (this.fontSize >= ButtonGestureModifier.minFontSize) { 75 s10.addGesture(new LongPressGestureHandler({ repeat: false, duration: ButtonGestureModifier.longPressTime }) 76 .onAction(() => { 77 if (s10) { 78 this.controller?.open(); 79 } 80 }) 81 .onActionEnd(() => { 82 this.controller?.close(); 83 })); 84 } 85 else { 86 s10.clearGestures(); 87 } 88 } 89} 90ButtonGestureModifier.longPressTime = 500; 91ButtonGestureModifier.minFontSize = 1.75; 92export class EditableTitleBar extends ViewPU { 93 constructor(m10, n10, o10, p10 = -1, q10 = undefined, r10) { 94 super(m10, o10, p10, r10); 95 if (typeof q10 === 'function') { 96 this.paramsGenerator_ = q10; 97 } 98 this.leftIconStyle = EditableLeftIconType.Back; 99 this.title = ''; 100 this.subtitle = ''; 101 this.isSaveIconRequired = true; 102 this.imageItem = undefined; 103 this.menuItems = undefined; 104 this.options = { 105 safeAreaTypes: [SafeAreaType.SYSTEM], 106 safeAreaEdges: [SafeAreaEdge.TOP], 107 }; 108 this.onSave = undefined; 109 this.onCancel = undefined; 110 this.constraintWidth = 0; 111 this.isFollowingSystemFontScale = false; 112 this.maxFontScale = 1; 113 this.systemFontScale = 1; 114 this.__editableTitleBarTheme = new ObservedPropertyObjectPU(new EditableTitleBarTheme(), this, 'editableTitleBarTheme'); 115 this.addProvidedVar('editableTitleBarTheme', this.__editableTitleBarTheme, false); 116 this.__contentMargin = new SynchedPropertyObjectOneWayPU(n10.contentMargin, this, 'contentMargin'); 117 this.__titleBarMargin = new ObservedPropertyObjectPU({ 118 start: LengthMetrics.resource({ 'id': -1, 'type': 10002, params: ['sys.float.margin_left'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }), 119 end: LengthMetrics.resource({ 'id': -1, 'type': 10002, params: ['sys.float.margin_right'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }), 120 }, this, 'titleBarMargin'); 121 this.__fontSize = new ObservedPropertySimplePU(1, this, 'fontSize'); 122 this.setInitiallyProvidedValue(n10); 123 this.finalizeConstruction(); 124 } 125 setInitiallyProvidedValue(l10) { 126 if (l10.leftIconStyle !== undefined) { 127 this.leftIconStyle = l10.leftIconStyle; 128 } 129 if (l10.title !== undefined) { 130 this.title = l10.title; 131 } 132 if (l10.subtitle !== undefined) { 133 this.subtitle = l10.subtitle; 134 } 135 if (l10.isSaveIconRequired !== undefined) { 136 this.isSaveIconRequired = l10.isSaveIconRequired; 137 } 138 if (l10.imageItem !== undefined) { 139 this.imageItem = l10.imageItem; 140 } 141 if (l10.menuItems !== undefined) { 142 this.menuItems = l10.menuItems; 143 } 144 if (l10.options !== undefined) { 145 this.options = l10.options; 146 } 147 if (l10.onSave !== undefined) { 148 this.onSave = l10.onSave; 149 } 150 if (l10.onCancel !== undefined) { 151 this.onCancel = l10.onCancel; 152 } 153 if (l10.constraintWidth !== undefined) { 154 this.constraintWidth = l10.constraintWidth; 155 } 156 if (l10.isFollowingSystemFontScale !== undefined) { 157 this.isFollowingSystemFontScale = l10.isFollowingSystemFontScale; 158 } 159 if (l10.maxFontScale !== undefined) { 160 this.maxFontScale = l10.maxFontScale; 161 } 162 if (l10.systemFontScale !== undefined) { 163 this.systemFontScale = l10.systemFontScale; 164 } 165 if (l10.editableTitleBarTheme !== undefined) { 166 this.editableTitleBarTheme = l10.editableTitleBarTheme; 167 } 168 if (l10.titleBarMargin !== undefined) { 169 this.titleBarMargin = l10.titleBarMargin; 170 } 171 if (l10.fontSize !== undefined) { 172 this.fontSize = l10.fontSize; 173 } 174 } 175 updateStateVars(k10) { 176 this.__contentMargin.reset(k10.contentMargin); 177 } 178 purgeVariableDependenciesOnElmtId(j10) { 179 this.__editableTitleBarTheme.purgeDependencyOnElmtId(j10); 180 this.__contentMargin.purgeDependencyOnElmtId(j10); 181 this.__titleBarMargin.purgeDependencyOnElmtId(j10); 182 this.__fontSize.purgeDependencyOnElmtId(j10); 183 } 184 aboutToBeDeleted() { 185 this.__editableTitleBarTheme.aboutToBeDeleted(); 186 this.__contentMargin.aboutToBeDeleted(); 187 this.__titleBarMargin.aboutToBeDeleted(); 188 this.__fontSize.aboutToBeDeleted(); 189 SubscriberManager.Get().delete(this.id__()); 190 this.aboutToBeDeletedInternal(); 191 } 192 get editableTitleBarTheme() { 193 return this.__editableTitleBarTheme.get(); 194 } 195 set editableTitleBarTheme(i10) { 196 this.__editableTitleBarTheme.set(i10); 197 } 198 get contentMargin() { 199 return this.__contentMargin.get(); 200 } 201 set contentMargin(h10) { 202 this.__contentMargin.set(h10); 203 } 204 get titleBarMargin() { 205 return this.__titleBarMargin.get(); 206 } 207 set titleBarMargin(g10) { 208 this.__titleBarMargin.set(g10); 209 } 210 get fontSize() { 211 return this.__fontSize.get(); 212 } 213 set fontSize(e10) { 214 this.__fontSize.set(e10); 215 } 216 onWillApplyTheme(d10) { 217 this.editableTitleBarTheme.iconColor = d10.colors.iconPrimary; 218 this.editableTitleBarTheme.titleColor = d10.colors.fontPrimary; 219 this.editableTitleBarTheme.subTitleColor = d10.colors.fontSecondary; 220 this.editableTitleBarTheme.iconBackgroundPressedColor = d10.colors.interactivePressed; 221 this.editableTitleBarTheme.iconBackgroundHoverColor = d10.colors.interactiveHover; 222 this.editableTitleBarTheme.iconBackgroundFocusOutlineColor = d10.colors.interactiveFocus; 223 } 224 aboutToAppear() { 225 try { 226 let c10 = this.getUIContext(); 227 this.isFollowingSystemFontScale = c10.isFollowingSystemFontScale(); 228 this.maxFontScale = c10.getMaxFontScale(); 229 } 230 catch (z9) { 231 let a10 = z9.code; 232 let b10 = z9.message; 233 hilog.error(0x3900, 'Ace', `Faild to init fontsizescale info,cause, code: ${a10}, message: ${b10}`); 234 } 235 } 236 decideFontScale() { 237 let y9 = this.getUIContext(); 238 this.systemFontScale = y9.getHostContext()?.config?.fontSizeScale ?? 1; 239 if (!this.isFollowingSystemFontScale) { 240 return 1; 241 } 242 return Math.min(this.systemFontScale, this.maxFontScale); 243 } 244 initialRender() { 245 this.observeComponentCreation2((w9, x9) => { 246 Flex.create({ 247 justifyContent: FlexAlign.SpaceBetween, 248 alignItems: ItemAlign.Stretch, 249 }); 250 Flex.backgroundColor(this.options.backgroundColor ?? EditableTitleBar.noneColor); 251 Flex.backgroundBlurStyle(this.options.backgroundBlurStyle ?? BlurStyle.NONE); 252 Flex.expandSafeArea(this.options.safeAreaTypes, this.options.safeAreaEdges); 253 }, Flex); 254 this.observeComponentCreation2((u9, v9) => { 255 Row.create(); 256 Row.width('100%'); 257 Row.margin(this.contentMargin ?? this.titleBarMargin); 258 Row.height(EditableTitleBar.totalHeight); 259 }, Row); 260 this.observeComponentCreation2((s9, t9) => { 261 Row.create(); 262 Row.flexShrink(0); 263 }, Row); 264 this.leftIconLayout.bind(this)(this); 265 Row.pop(); 266 this.observeComponentCreation2((l9, m9) => { 267 If.create(); 268 if (this.imageItem) { 269 this.ifElseBranchUpdateFunction(0, () => { 270 this.observeComponentCreation2((q9, r9) => { 271 Row.create(); 272 Row.flexShrink(0); 273 }, Row); 274 this.imageItemLayout.bind(this)(this); 275 Row.pop(); 276 }); 277 } 278 else { 279 this.ifElseBranchUpdateFunction(1, () => { 280 }); 281 } 282 }, If); 283 If.pop(); 284 this.observeComponentCreation2((j9, k9) => { 285 Row.create(); 286 Row.width('100%'); 287 Row.flexShrink(1); 288 }, Row); 289 this.titleLayout.bind(this)(this); 290 Row.pop(); 291 this.observeComponentCreation2((h9, i9) => { 292 Row.create(); 293 Row.flexShrink(0); 294 }, Row); 295 this.rightMenuItemsLayout.bind(this)(this); 296 Row.pop(); 297 Row.pop(); 298 Flex.pop(); 299 } 300 imageItemLayout(t8 = null) { 301 { 302 this.observeComponentCreation2((v8, w8) => { 303 if (w8) { 304 let x8 = new ImageMenuItem(ViewPU.__proto__ !== NativeViewPartialUpdate && t8 instanceof PUV2ViewBase ? t8 : this, { 305 item: this.imageItem, 306 attribute: ItemType.Image, 307 }, undefined, v8, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 241, col: 5 }); 308 ViewPU.create(x8); 309 let d7 = () => { 310 return { 311 item: this.imageItem, 312 attribute: ItemType.Image 313 }; 314 }; 315 x8.paramsGenerator_ = d7; 316 } 317 else { 318 this.updateStateVarsOfChildByElmtId(v8, {}); 319 } 320 }, { name: 'ImageMenuItem' }); 321 } 322 } 323 leftIconLayout(w7 = null) { 324 this.observeComponentCreation2((y7, z7) => { 325 If.create(); 326 if (this.leftIconStyle === EditableLeftIconType.Back) { 327 this.ifElseBranchUpdateFunction(0, () => { 328 { 329 this.observeComponentCreation2((l8, m8) => { 330 if (m8) { 331 let n8 = new ImageMenuItem(ViewPU.__proto__ !== NativeViewPartialUpdate && w7 instanceof PUV2ViewBase ? w7 : this, { 332 item: { 333 value: PUBLIC_BACK, 334 isEnabled: true, 335 action: () => this.onCancel ? this.onCancel() : this.getUIContext()?.getRouter()?.back() 336 }, 337 fontSize: this.fontSize, 338 attribute: ItemType.LeftIcon, 339 useSymbol: true, 340 }, undefined, l8, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 253, col: 7 }); 341 ViewPU.create(n8); 342 let c7 = () => { 343 return { 344 item: { 345 value: PUBLIC_BACK, 346 isEnabled: true, 347 action: () => this.onCancel ? this.onCancel() : this.getUIContext()?.getRouter()?.back() 348 }, 349 fontSize: this.fontSize, 350 attribute: ItemType.LeftIcon, 351 useSymbol: true 352 }; 353 }; 354 n8.paramsGenerator_ = c7; 355 } 356 else { 357 this.updateStateVarsOfChildByElmtId(l8, { 358 fontSize: this.fontSize 359 }); 360 } 361 }, { name: 'ImageMenuItem' }); 362 } 363 }); 364 } 365 else { 366 this.ifElseBranchUpdateFunction(1, () => { 367 { 368 this.observeComponentCreation2((c8, d8) => { 369 if (d8) { 370 let e8 = new ImageMenuItem(ViewPU.__proto__ !== NativeViewPartialUpdate && w7 instanceof PUV2ViewBase ? w7 : this, { 371 item: { 372 value: PUBLIC_CANCEL, 373 isEnabled: true, 374 action: () => this.onCancel && this.onCancel(), 375 }, 376 fontSize: this.fontSize, 377 attribute: ItemType.LeftIcon, 378 useSymbol: true, 379 }, undefined, c8, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 264, col: 7 }); 380 ViewPU.create(e8); 381 let z6 = () => { 382 return { 383 item: { 384 value: PUBLIC_CANCEL, 385 isEnabled: true, 386 action: () => this.onCancel && this.onCancel(), 387 }, 388 fontSize: this.fontSize, 389 attribute: ItemType.LeftIcon, 390 useSymbol: true 391 }; 392 }; 393 e8.paramsGenerator_ = z6; 394 } 395 else { 396 this.updateStateVarsOfChildByElmtId(c8, { 397 fontSize: this.fontSize 398 }); 399 } 400 }, { name: 'ImageMenuItem' }); 401 } 402 }); 403 } 404 }, If); 405 If.pop(); 406 } 407 titleLayout(b7 = null) { 408 this.observeComponentCreation2((u7, v7) => { 409 Column.create(); 410 Column.height(EditableTitleBar.totalHeight); 411 Column.justifyContent(FlexAlign.Center); 412 Column.margin({ 413 start: LengthMetrics.resource({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_space_horizontal'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }), 414 }); 415 Column.alignItems(HorizontalAlign.Start); 416 }, Column); 417 this.observeComponentCreation2((s7, t7) => { 418 Row.create(); 419 Row.justifyContent(FlexAlign.Start); 420 }, Row); 421 this.observeComponentCreation2((q7, r7) => { 422 Text.create(this.title); 423 Text.maxFontSize(TITLE_F_VP); 424 Text.minFontSize(SUBTITLE_F_VP); 425 Text.fontColor(this.editableTitleBarTheme.titleColor); 426 Text.maxLines(this.subtitle ? MAX_LINE_ONE : MAX_LINES_TWO); 427 Text.fontWeight(FontWeight.Bold); 428 Text.textAlign(TextAlign.Start); 429 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 430 Text.heightAdaptivePolicy(this.subtitle ? 431 TextHeightAdaptivePolicy.MAX_LINES_FIRST : TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST); 432 Text.constraintSize({ 433 maxHeight: this.subtitle ? EditableTitleBar.maxMainTitleHeight : EditableTitleBar.totalHeight, 434 }); 435 }, Text); 436 Text.pop(); 437 Row.pop(); 438 this.observeComponentCreation2((g7, h7) => { 439 If.create(); 440 if (this.subtitle) { 441 this.ifElseBranchUpdateFunction(0, () => { 442 this.observeComponentCreation2((o7, p7) => { 443 Row.create(); 444 Row.margin({ 445 top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level1'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 446 }); 447 Row.justifyContent(FlexAlign.Start); 448 }, Row); 449 this.observeComponentCreation2((m7, n7) => { 450 Text.create(this.subtitle); 451 Text.maxFontSize(SUBTITLE_F_VP); 452 Text.minFontSize(MIN_SUBTITLE_SIZE); 453 Text.fontColor(this.editableTitleBarTheme.subTitleColor); 454 Text.maxLines(MAX_LINE_ONE); 455 Text.fontWeight(FontWeight.Regular); 456 Text.textAlign(TextAlign.Start); 457 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 458 Text.heightAdaptivePolicy(TextHeightAdaptivePolicy.MAX_LINES_FIRST); 459 Text.constraintSize({ 460 maxHeight: this.title ? EditableTitleBar.maxSubTitleHeight : EditableTitleBar.totalHeight, 461 }); 462 }, Text); 463 Text.pop(); 464 Row.pop(); 465 }); 466 } 467 else { 468 this.ifElseBranchUpdateFunction(1, () => { 469 }); 470 } 471 }, If); 472 If.pop(); 473 Column.pop(); 474 } 475 rightMenuItemsLayout(t6 = null) { 476 { 477 this.observeComponentCreation2((v6, w6) => { 478 if (w6) { 479 let x6 = new EditableTitleBarMenuSection(ViewPU.__proto__ !== NativeViewPartialUpdate && t6 instanceof PUV2ViewBase ? t6 : this, { 480 menuItems: this.menuItems, 481 onSave: this.onSave, 482 isSaveEnabled: this.isSaveIconRequired, 483 fontSize: this.fontSize, 484 }, undefined, v6, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 329, col: 5 }); 485 ViewPU.create(x6); 486 let y6 = () => { 487 return { 488 menuItems: this.menuItems, 489 onSave: this.onSave, 490 isSaveEnabled: this.isSaveIconRequired, 491 fontSize: this.fontSize 492 }; 493 }; 494 x6.paramsGenerator_ = y6; 495 } 496 else { 497 this.updateStateVarsOfChildByElmtId(v6, { 498 fontSize: this.fontSize 499 }); 500 } 501 }, { name: 'EditableTitleBarMenuSection' }); 502 } 503 } 504 onPlaceChildren(o6, p6, q6) { 505 p6.forEach((s6) => { 506 s6.layout({ x: 0, y: 0 }); 507 }); 508 } 509 onMeasureSize(i6, j6, k6) { 510 let l6 = { width: i6.width, height: i6.height }; 511 this.fontSize = this.decideFontScale(); 512 j6.forEach((n6) => { 513 l6.height = n6.measure(k6).height; 514 l6.width = Number(k6.maxWidth); 515 }); 516 return l6; 517 } 518 rerender() { 519 this.updateDirtyElements(); 520 } 521} 522EditableTitleBar.maxCountOfExtraItems = 3; 523EditableTitleBar.maxOtherCountOfExtraItems = 2; 524EditableTitleBar.commonZero = 0; 525EditableTitleBar.noneColor = '#00000000'; 526EditableTitleBar.defaultHeight = getNumberByResource(125831115, DEFAULT_TITLE_BAR_HEIGHT); 527EditableTitleBar.defaultTitlePadding = getNumberByResource(125830920, DEFAULT_TITLE_PADDING); 528EditableTitleBar.totalHeight = EditableTitleBar.defaultHeight === EditableTitleBar.commonZero ? DEFAULT_TITLE_BAR_HEIGHT : 529 EditableTitleBar.defaultHeight; 530EditableTitleBar.titlePadding = EditableTitleBar.defaultTitlePadding === EditableTitleBar.commonZero ? 531 DEFAULT_TITLE_PADDING : EditableTitleBar.defaultTitlePadding; 532EditableTitleBar.maxMainTitleHeight = (EditableTitleBar.totalHeight - EditableTitleBar.titlePadding) * MAX_MAIN_TITLE_PERCENT; 533EditableTitleBar.maxSubTitleHeight = (EditableTitleBar.totalHeight - EditableTitleBar.titlePadding) * MAX_SUB_TITLE_PERCENT; 534class EditableTitleBarMenuSection extends ViewPU { 535 constructor(c6, d6, e6, f6 = -1, g6 = undefined, h6) { 536 super(c6, e6, f6, h6); 537 if (typeof g6 === 'function') { 538 this.paramsGenerator_ = g6; 539 } 540 this.menuItems = undefined; 541 this.onSave = undefined; 542 this.isSaveEnabled = true; 543 this.__fontSize = new SynchedPropertySimpleOneWayPU(d6.fontSize, this, 'fontSize'); 544 this.setInitiallyProvidedValue(d6); 545 this.finalizeConstruction(); 546 } 547 setInitiallyProvidedValue(b6) { 548 if (b6.menuItems !== undefined) { 549 this.menuItems = b6.menuItems; 550 } 551 if (b6.onSave !== undefined) { 552 this.onSave = b6.onSave; 553 } 554 if (b6.isSaveEnabled !== undefined) { 555 this.isSaveEnabled = b6.isSaveEnabled; 556 } 557 if (b6.fontSize === undefined) { 558 this.__fontSize.set(1); 559 } 560 } 561 updateStateVars(a6) { 562 this.__fontSize.reset(a6.fontSize); 563 } 564 purgeVariableDependenciesOnElmtId(z5) { 565 this.__fontSize.purgeDependencyOnElmtId(z5); 566 } 567 aboutToBeDeleted() { 568 this.__fontSize.aboutToBeDeleted(); 569 SubscriberManager.Get().delete(this.id__()); 570 this.aboutToBeDeletedInternal(); 571 } 572 get fontSize() { 573 return this.__fontSize.get(); 574 } 575 set fontSize(y5) { 576 this.__fontSize.set(y5); 577 } 578 initialRender() { 579 this.observeComponentCreation2((w5, x5) => { 580 Column.create(); 581 Column.justifyContent(FlexAlign.Center); 582 }, Column); 583 this.observeComponentCreation2((u5, v5) => { 584 Row.create(); 585 }, Row); 586 this.observeComponentCreation2((c5, d5) => { 587 If.create(); 588 if (this.menuItems !== undefined && this.menuItems.length > EditableTitleBar.commonZero) { 589 this.ifElseBranchUpdateFunction(0, () => { 590 this.observeComponentCreation2((h5, i5) => { 591 ForEach.create(); 592 const r5 = l5 => { 593 const m5 = l5; 594 { 595 this.observeComponentCreation2((o5, p5) => { 596 if (p5) { 597 let q5 = new ImageMenuItem(this, { 598 item: m5, 599 attribute: ItemType.Icon, 600 fontSize: this.fontSize, 601 }, undefined, o5, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 369, col: 15 }); 602 ViewPU.create(q5); 603 let s5 = () => { 604 return { 605 item: m5, 606 attribute: ItemType.Icon, 607 fontSize: this.fontSize 608 }; 609 }; 610 q5.paramsGenerator_ = s5; 611 } 612 else { 613 this.updateStateVarsOfChildByElmtId(o5, { 614 fontSize: this.fontSize 615 }); 616 } 617 }, { name: 'ImageMenuItem' }); 618 } 619 }; 620 this.forEachUpdateFunction(h5, this.menuItems.slice(EditableTitleBar.commonZero, this.isSaveEnabled ? 621 EditableTitleBar.maxOtherCountOfExtraItems : EditableTitleBar.maxCountOfExtraItems), r5); 622 }, ForEach); 623 ForEach.pop(); 624 }); 625 } 626 else { 627 this.ifElseBranchUpdateFunction(1, () => { 628 }); 629 } 630 }, If); 631 If.pop(); 632 this.observeComponentCreation2((r4, s4) => { 633 If.create(); 634 if (this.isSaveEnabled) { 635 this.ifElseBranchUpdateFunction(0, () => { 636 { 637 this.observeComponentCreation2((w4, x4) => { 638 if (x4) { 639 let y4 = new ImageMenuItem(this, { 640 item: { 641 value: PUBLIC_OK, 642 isEnabled: true, 643 action: () => this.onSave && this.onSave(), 644 }, 645 fontSize: this.fontSize, 646 attribute: ItemType.Icon, 647 useSymbol: true, 648 }, undefined, w4, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 377, col: 11 }); 649 ViewPU.create(y4); 650 let j5 = () => { 651 return { 652 item: { 653 value: PUBLIC_OK, 654 isEnabled: true, 655 action: () => this.onSave && this.onSave(), 656 }, 657 fontSize: this.fontSize, 658 attribute: ItemType.Icon, 659 useSymbol: true 660 }; 661 }; 662 y4.paramsGenerator_ = j5; 663 } 664 else { 665 this.updateStateVarsOfChildByElmtId(w4, { 666 fontSize: this.fontSize 667 }); 668 } 669 }, { name: 'ImageMenuItem' }); 670 } 671 }); 672 } 673 else { 674 this.ifElseBranchUpdateFunction(1, () => { 675 }); 676 } 677 }, If); 678 If.pop(); 679 Row.pop(); 680 Column.pop(); 681 } 682 rerender() { 683 this.updateDirtyElements(); 684 } 685} 686class ImageMenuItem extends ViewPU { 687 constructor(d4, e4, f4, g4 = -1, h4 = undefined, i4) { 688 super(d4, f4, g4, i4); 689 if (typeof h4 === 'function') { 690 this.paramsGenerator_ = h4; 691 } 692 this.item = { 693 value: '', 694 isEnabled: true, 695 label: '', 696 }; 697 this.attribute = ItemType.Image; 698 this.callbackId = undefined; 699 this.minFontSize = 1.75; 700 this.maxFontSize = 3.2; 701 this.longPressTime = 500; 702 this.useSymbol = false; 703 this.__fontSize = new SynchedPropertySimpleOneWayPU(e4.fontSize, this, 'fontSize'); 704 this.__isOnFocus = new ObservedPropertySimplePU(false, this, 'isOnFocus'); 705 this.__isOnHover = new ObservedPropertySimplePU(false, this, 'isOnHover'); 706 this.__isOnClick = new ObservedPropertySimplePU(false, this, 'isOnClick'); 707 this.__editableTitleBarTheme = this.initializeConsume('editableTitleBarTheme', 'editableTitleBarTheme'); 708 this.dialogController = new CustomDialogController({ 709 builder: () => { 710 let j4 = new EditableTitleBarDialog(this, { 711 cancel: () => { 712 }, 713 confirm: () => { 714 }, 715 itemEditableDialog: this.item, 716 textEditableTitleBarDialog: this.item.label ? this.item.label : this.textDialog(), 717 fontSize: this.fontSize, 718 useSymbol: this.useSymbol, 719 }, undefined, -1, () => { }, { page: 'library/src/main/ets/components/EditableTitleBar.ets', line: 413, col: 14 }); 720 j4.setController(this.dialogController); 721 ViewPU.create(j4); 722 let a5 = () => { 723 return { 724 cancel: () => { 725 }, 726 confirm: () => { 727 }, 728 itemEditableDialog: this.item, 729 textEditableTitleBarDialog: this.item.label ? this.item.label : this.textDialog(), 730 fontSize: this.fontSize, 731 useSymbol: this.useSymbol 732 }; 733 }; 734 j4.paramsGenerator_ = a5; 735 }, 736 maskColor: Color.Transparent, 737 isModal: true, 738 customStyle: true 739 }, this); 740 this.__buttonGestureModifier = new ObservedPropertyObjectPU(new ButtonGestureModifier(this.dialogController), this, 'buttonGestureModifier'); 741 this.setInitiallyProvidedValue(e4); 742 this.declareWatch('fontSize', this.onFontSizeUpdated); 743 this.finalizeConstruction(); 744 } 745 setInitiallyProvidedValue(c4) { 746 if (c4.item !== undefined) { 747 this.item = c4.item; 748 } 749 if (c4.attribute !== undefined) { 750 this.attribute = c4.attribute; 751 } 752 if (c4.callbackId !== undefined) { 753 this.callbackId = c4.callbackId; 754 } 755 if (c4.minFontSize !== undefined) { 756 this.minFontSize = c4.minFontSize; 757 } 758 if (c4.maxFontSize !== undefined) { 759 this.maxFontSize = c4.maxFontSize; 760 } 761 if (c4.longPressTime !== undefined) { 762 this.longPressTime = c4.longPressTime; 763 } 764 if (c4.useSymbol !== undefined) { 765 this.useSymbol = c4.useSymbol; 766 } 767 if (c4.fontSize === undefined) { 768 this.__fontSize.set(1); 769 } 770 if (c4.isOnFocus !== undefined) { 771 this.isOnFocus = c4.isOnFocus; 772 } 773 if (c4.isOnHover !== undefined) { 774 this.isOnHover = c4.isOnHover; 775 } 776 if (c4.isOnClick !== undefined) { 777 this.isOnClick = c4.isOnClick; 778 } 779 if (c4.dialogController !== undefined) { 780 this.dialogController = c4.dialogController; 781 } 782 if (c4.buttonGestureModifier !== undefined) { 783 this.buttonGestureModifier = c4.buttonGestureModifier; 784 } 785 } 786 updateStateVars(b4) { 787 this.__fontSize.reset(b4.fontSize); 788 } 789 purgeVariableDependenciesOnElmtId(a4) { 790 this.__fontSize.purgeDependencyOnElmtId(a4); 791 this.__isOnFocus.purgeDependencyOnElmtId(a4); 792 this.__isOnHover.purgeDependencyOnElmtId(a4); 793 this.__isOnClick.purgeDependencyOnElmtId(a4); 794 this.__editableTitleBarTheme.purgeDependencyOnElmtId(a4); 795 this.__buttonGestureModifier.purgeDependencyOnElmtId(a4); 796 } 797 aboutToBeDeleted() { 798 this.__fontSize.aboutToBeDeleted(); 799 this.__isOnFocus.aboutToBeDeleted(); 800 this.__isOnHover.aboutToBeDeleted(); 801 this.__isOnClick.aboutToBeDeleted(); 802 this.__editableTitleBarTheme.aboutToBeDeleted(); 803 this.__buttonGestureModifier.aboutToBeDeleted(); 804 SubscriberManager.Get().delete(this.id__()); 805 this.aboutToBeDeletedInternal(); 806 } 807 get fontSize() { 808 return this.__fontSize.get(); 809 } 810 set fontSize(z3) { 811 this.__fontSize.set(z3); 812 } 813 get isOnFocus() { 814 return this.__isOnFocus.get(); 815 } 816 set isOnFocus(y3) { 817 this.__isOnFocus.set(y3); 818 } 819 get isOnHover() { 820 return this.__isOnHover.get(); 821 } 822 set isOnHover(x3) { 823 this.__isOnHover.set(x3); 824 } 825 get isOnClick() { 826 return this.__isOnClick.get(); 827 } 828 set isOnClick(w3) { 829 this.__isOnClick.set(w3); 830 } 831 get editableTitleBarTheme() { 832 return this.__editableTitleBarTheme.get(); 833 } 834 set editableTitleBarTheme(v3) { 835 this.__editableTitleBarTheme.set(v3); 836 } 837 get buttonGestureModifier() { 838 return this.__buttonGestureModifier.get(); 839 } 840 set buttonGestureModifier(u3) { 841 this.__buttonGestureModifier.set(u3); 842 } 843 textDialog() { 844 if (this.item.value === PUBLIC_OK) { 845 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_save'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 846 } 847 else if (this.item.value === PUBLIC_CANCEL) { 848 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_cancel'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 849 } 850 else if (this.item.value === PUBLIC_BACK) { 851 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_back'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 852 } 853 else { 854 return this.item.label ? this.item.label : ''; 855 } 856 } 857 onFontSizeUpdated() { 858 this.buttonGestureModifier.fontSize = this.fontSize; 859 } 860 touchEventAction(t3) { 861 if (!this.item.isEnabled) { 862 return; 863 } 864 if (t3.type === TouchType.Down) { 865 this.isOnClick = true; 866 } 867 if (t3.type === TouchType.Up || t3.type === TouchType.Cancel) { 868 if (this.fontSize >= this.minFontSize) { 869 this.dialogController?.close(); 870 } 871 this.isOnClick = false; 872 } 873 } 874 keyEventAction(s3) { 875 if (!this.item.isEnabled) { 876 return; 877 } 878 if (s3.keyCode !== KeyCode.KEYCODE_ENTER && s3.keyCode !== KeyCode.KEYCODE_SPACE) { 879 return; 880 } 881 if (s3.type === KeyType.Down) { 882 this.isOnClick = true; 883 } 884 if (s3.type === KeyType.Up) { 885 this.isOnClick = false; 886 } 887 } 888 getBgColor() { 889 if (this.isOnClick) { 890 return this.editableTitleBarTheme.iconBackgroundPressedColor; 891 } 892 else if (this.isOnHover) { 893 return this.editableTitleBarTheme.iconBackgroundHoverColor; 894 } 895 else { 896 return this.editableTitleBarTheme.iconBackgroundColor; 897 } 898 } 899 getFgColor() { 900 if (this.isOnClick) { 901 return { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_pressed_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 902 } 903 else if (this.isOnHover) { 904 return { 'id': -1, 'type': 10001, params: ['sys.color.titlebar_icon_background_hover_color'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 905 } 906 else { 907 return EditableTitleBar.noneColor; 908 } 909 } 910 getAccessibilityReadText() { 911 if (this.item.value === PUBLIC_OK) { 912 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_save'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 913 } 914 else if (this.item.value === PUBLIC_CANCEL) { 915 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_cancel'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 916 } 917 else if (this.item.value === PUBLIC_BACK) { 918 return { 'id': -1, 'type': 10003, params: ['sys.string.icon_back'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }; 919 } 920 else if (this.item.label) { 921 return this.item.label; 922 } 923 return undefined; 924 } 925 IconBuilder(u2 = null) { 926 this.observeComponentCreation2((h3, i3) => { 927 Button.createWithChild({ type: ButtonType.Normal, stateEffect: this.item.isEnabled }); 928 Button.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 929 Button.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 930 Button.focusable(this.item.isEnabled); 931 Button.enabled(this.item.isEnabled); 932 Button.borderRadius({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 933 Button.margin({ 934 start: this.attribute === ItemType.LeftIcon ? LengthMetrics.vp(EditableTitleBar.commonZero) : 935 LengthMetrics.resource({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_space_horizontal'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }), 936 }); 937 Button.focusOnTouch(true); 938 Button.foregroundColor(this.getFgColor()); 939 Button.backgroundColor(this.getBgColor()); 940 ViewStackProcessor.visualState('focused'); 941 Button.border({ 942 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 943 width: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_focus_outline_weight'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 944 color: this.editableTitleBarTheme.iconBackgroundFocusOutlineColor, 945 style: BorderStyle.Solid, 946 }); 947 ViewStackProcessor.visualState('normal'); 948 Button.border({ 949 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 950 width: EditableTitleBar.commonZero, 951 }); 952 ViewStackProcessor.visualState('pressed'); 953 Button.border({ 954 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 955 width: EditableTitleBar.commonZero, 956 }); 957 ViewStackProcessor.visualState(); 958 Button.onFocus(() => { 959 if (!this.item.isEnabled) { 960 return; 961 } 962 this.isOnFocus = true; 963 }); 964 Button.onBlur(() => this.isOnFocus = false); 965 Button.onHover((r3) => { 966 if (!this.item.isEnabled) { 967 return; 968 } 969 this.isOnHover = r3; 970 }); 971 Button.onKeyEvent((q3) => { 972 this.keyEventAction(q3); 973 }); 974 Button.onTouch((p3) => { 975 this.touchEventAction(p3); 976 }); 977 Button.onClick(() => { 978 this.item.isEnabled && this.item.action && this.item.action(); 979 }); 980 Button.gestureModifier(ObservedObject.GetRawObject(this.buttonGestureModifier)); 981 }, Button); 982 this.observeComponentCreation2((x2, y2) => { 983 If.create(); 984 if (this.useSymbol) { 985 this.ifElseBranchUpdateFunction(0, () => { 986 this.observeComponentCreation2((f3, g3) => { 987 SymbolGlyph.create(this.item.value); 988 SymbolGlyph.fontColor([this.editableTitleBarTheme.iconColor]); 989 SymbolGlyph.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 990 SymbolGlyph.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 991 SymbolGlyph.focusable(this.item.isEnabled); 992 SymbolGlyph.enabled(this.item.isEnabled); 993 SymbolGlyph.draggable(false); 994 SymbolGlyph.fontSize(SYMBOL_SIZE); 995 SymbolGlyph.accessibilityText(this.getAccessibilityReadText()); 996 }, SymbolGlyph); 997 }); 998 } 999 else { 1000 this.ifElseBranchUpdateFunction(1, () => { 1001 this.observeComponentCreation2((b3, c3) => { 1002 Image.create(this.item.value); 1003 Image.fillColor(this.editableTitleBarTheme.iconColor); 1004 Image.matchTextDirection(this.item.value === PUBLIC_BACK ? true : false); 1005 Image.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1006 Image.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1007 Image.focusable(this.item.isEnabled); 1008 Image.enabled(this.item.isEnabled); 1009 Image.draggable(false); 1010 Image.accessibilityText(this.getAccessibilityReadText()); 1011 }, Image); 1012 }); 1013 } 1014 }, If); 1015 If.pop(); 1016 Button.pop(); 1017 } 1018 ImageBuilder(b2 = null) { 1019 this.observeComponentCreation2((s2, t2) => { 1020 Stack.create({ alignContent: Alignment.Center }); 1021 Stack.margin({ 1022 start: LengthMetrics.resource({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_space_horizontal'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }), 1023 }); 1024 }, Stack); 1025 this.observeComponentCreation2((q2, r2) => { 1026 If.create(); 1027 if (this.useSymbol) { 1028 this.ifElseBranchUpdateFunction(0, () => { 1029 this.observeComponentCreation2((p4, z4) => { 1030 SymbolGlyph.create(this.item.value); 1031 SymbolGlyph.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1032 SymbolGlyph.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1033 SymbolGlyph.borderRadius({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level10'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1034 SymbolGlyph.focusable(false); 1035 SymbolGlyph.enabled(this.item.isEnabled); 1036 }, SymbolGlyph); 1037 }); 1038 } 1039 else { 1040 this.ifElseBranchUpdateFunction(1, () => { 1041 this.observeComponentCreation2((k4, l4) => { 1042 Image.create(this.item.value); 1043 Image.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1044 Image.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1045 Image.borderRadius({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level10'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1046 Image.focusable(false); 1047 Image.enabled(this.item.isEnabled); 1048 Image.objectFit(ImageFit.Cover); 1049 }, Image); 1050 }); 1051 } 1052 }, If); 1053 If.pop(); 1054 this.observeComponentCreation2((f2, g2) => { 1055 Button.createWithLabel({ type: ButtonType.Circle }); 1056 Button.width({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_width'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1057 Button.height({ 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_height'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1058 Button.focusable(this.item.isEnabled); 1059 Button.enabled(this.item.isEnabled); 1060 Button.foregroundColor(this.getFgColor()); 1061 Button.backgroundColor(EditableTitleBar.noneColor); 1062 ViewStackProcessor.visualState('pressed'); 1063 Button.border({ 1064 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1065 width: EditableTitleBar.commonZero, 1066 }); 1067 ViewStackProcessor.visualState('normal'); 1068 Button.border({ 1069 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1070 width: EditableTitleBar.commonZero, 1071 }); 1072 ViewStackProcessor.visualState('focused'); 1073 Button.border({ 1074 radius: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_shape'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1075 width: { 'id': -1, 'type': 10002, params: ['sys.float.titlebar_icon_background_focus_outline_weight'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1076 color: this.editableTitleBarTheme.iconBackgroundFocusOutlineColor, 1077 style: BorderStyle.Solid, 1078 }); 1079 ViewStackProcessor.visualState(); 1080 Button.onFocus(() => { 1081 if (!this.item.isEnabled) { 1082 return; 1083 } 1084 this.isOnFocus = true; 1085 }); 1086 Button.onBlur(() => this.isOnFocus = false); 1087 Button.onHover((p2) => { 1088 if (!this.item.isEnabled) { 1089 return; 1090 } 1091 this.isOnHover = p2; 1092 }); 1093 Button.onKeyEvent((o2) => { 1094 this.keyEventAction(o2); 1095 }); 1096 Button.onTouch((n2) => { 1097 this.touchEventAction(n2); 1098 }); 1099 Button.onClick(() => { 1100 this.item.isEnabled && this.item.action && this.item.action(); 1101 }); 1102 Button.gestureModifier(ObservedObject.GetRawObject(this.buttonGestureModifier)); 1103 }, Button); 1104 Button.pop(); 1105 Stack.pop(); 1106 } 1107 initialRender() { 1108 this.observeComponentCreation2((x1, y1) => { 1109 If.create(); 1110 if (this.attribute === ItemType.Icon || this.attribute === ItemType.LeftIcon) { 1111 this.ifElseBranchUpdateFunction(0, () => { 1112 this.IconBuilder.bind(this)(this); 1113 }); 1114 } 1115 else { 1116 this.ifElseBranchUpdateFunction(1, () => { 1117 this.ImageBuilder.bind(this)(this); 1118 }); 1119 } 1120 }, If); 1121 If.pop(); 1122 } 1123 rerender() { 1124 this.updateDirtyElements(); 1125 } 1126} 1127class EditableTitleBarDialog extends ViewPU { 1128 constructor(o1, p1, q1, r1 = -1, s1 = undefined, t1) { 1129 super(o1, q1, r1, t1); 1130 if (typeof s1 === 'function') { 1131 this.paramsGenerator_ = s1; 1132 } 1133 this.itemEditableDialog = { 1134 value: '', 1135 isEnabled: true, 1136 }; 1137 this.callbackId = undefined; 1138 this.textEditableTitleBarDialog = ''; 1139 this.mainWindowStage = undefined; 1140 this.controller = undefined; 1141 this.minFontSize = 1.75; 1142 this.maxFontSize = 3.2; 1143 this.screenWidth = 640; 1144 this.verticalScreenLines = 6; 1145 this.horizontalsScreenLines = 1; 1146 this.useSymbol = false; 1147 this.cancel = () => { 1148 }; 1149 this.confirm = () => { 1150 }; 1151 this.__mainWindow = this.createStorageLink('mainWindow', undefined, 'mainWindow'); 1152 this.__fontSize = new SynchedPropertySimpleOneWayPU(p1.fontSize, this, 'fontSize'); 1153 this.__maxLines = new ObservedPropertySimplePU(1, this, 'maxLines'); 1154 this.__windowStandardHeight = this.createStorageProp('windowStandardHeight', 0, 'windowStandardHeight'); 1155 this.setInitiallyProvidedValue(p1); 1156 this.finalizeConstruction(); 1157 } 1158 setInitiallyProvidedValue(n1) { 1159 if (n1.itemEditableDialog !== undefined) { 1160 this.itemEditableDialog = n1.itemEditableDialog; 1161 } 1162 if (n1.callbackId !== undefined) { 1163 this.callbackId = n1.callbackId; 1164 } 1165 if (n1.textEditableTitleBarDialog !== undefined) { 1166 this.textEditableTitleBarDialog = n1.textEditableTitleBarDialog; 1167 } 1168 if (n1.mainWindowStage !== undefined) { 1169 this.mainWindowStage = n1.mainWindowStage; 1170 } 1171 if (n1.controller !== undefined) { 1172 this.controller = n1.controller; 1173 } 1174 if (n1.minFontSize !== undefined) { 1175 this.minFontSize = n1.minFontSize; 1176 } 1177 if (n1.maxFontSize !== undefined) { 1178 this.maxFontSize = n1.maxFontSize; 1179 } 1180 if (n1.screenWidth !== undefined) { 1181 this.screenWidth = n1.screenWidth; 1182 } 1183 if (n1.verticalScreenLines !== undefined) { 1184 this.verticalScreenLines = n1.verticalScreenLines; 1185 } 1186 if (n1.horizontalsScreenLines !== undefined) { 1187 this.horizontalsScreenLines = n1.horizontalsScreenLines; 1188 } 1189 if (n1.useSymbol !== undefined) { 1190 this.useSymbol = n1.useSymbol; 1191 } 1192 if (n1.cancel !== undefined) { 1193 this.cancel = n1.cancel; 1194 } 1195 if (n1.confirm !== undefined) { 1196 this.confirm = n1.confirm; 1197 } 1198 if (n1.fontSize === undefined) { 1199 this.__fontSize.set(1); 1200 } 1201 if (n1.maxLines !== undefined) { 1202 this.maxLines = n1.maxLines; 1203 } 1204 } 1205 updateStateVars(m1) { 1206 this.__fontSize.reset(m1.fontSize); 1207 } 1208 purgeVariableDependenciesOnElmtId(l1) { 1209 this.__mainWindow.purgeDependencyOnElmtId(l1); 1210 this.__fontSize.purgeDependencyOnElmtId(l1); 1211 this.__maxLines.purgeDependencyOnElmtId(l1); 1212 this.__windowStandardHeight.purgeDependencyOnElmtId(l1); 1213 } 1214 aboutToBeDeleted() { 1215 this.__mainWindow.aboutToBeDeleted(); 1216 this.__fontSize.aboutToBeDeleted(); 1217 this.__maxLines.aboutToBeDeleted(); 1218 this.__windowStandardHeight.aboutToBeDeleted(); 1219 SubscriberManager.Get().delete(this.id__()); 1220 this.aboutToBeDeletedInternal(); 1221 } 1222 setController(k1) { 1223 this.controller = k1; 1224 } 1225 get mainWindow() { 1226 return this.__mainWindow.get(); 1227 } 1228 set mainWindow(j1) { 1229 this.__mainWindow.set(j1); 1230 } 1231 get fontSize() { 1232 return this.__fontSize.get(); 1233 } 1234 set fontSize(i1) { 1235 this.__fontSize.set(i1); 1236 } 1237 get maxLines() { 1238 return this.__maxLines.get(); 1239 } 1240 set maxLines(h1) { 1241 this.__maxLines.set(h1); 1242 } 1243 get windowStandardHeight() { 1244 return this.__windowStandardHeight.get(); 1245 } 1246 set windowStandardHeight(g1) { 1247 this.__windowStandardHeight.set(g1); 1248 } 1249 initialRender() { 1250 this.observeComponentCreation2((k, l) => { 1251 If.create(); 1252 if (this.textEditableTitleBarDialog) { 1253 this.ifElseBranchUpdateFunction(0, () => { 1254 this.observeComponentCreation2((e1, f1) => { 1255 Column.create(); 1256 Column.width(this.fontSize === this.maxFontSize ? MAX_DIALOG : MIN_DIALOG); 1257 Column.constraintSize({ minHeight: this.fontSize === this.maxFontSize ? MAX_DIALOG : MIN_DIALOG }); 1258 Column.backgroundBlurStyle(BlurStyle.COMPONENT_ULTRA_THICK); 1259 Column.shadow(ShadowStyle.OUTER_DEFAULT_LG); 1260 Column.borderRadius(({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level10'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 1261 }, Column); 1262 this.observeComponentCreation2((c1, d1) => { 1263 If.create(); 1264 if (this.useSymbol) { 1265 this.ifElseBranchUpdateFunction(0, () => { 1266 this.observeComponentCreation2((k3, l3) => { 1267 SymbolGlyph.create(this.itemEditableDialog.value); 1268 SymbolGlyph.width(SYMBOL_TITLE_SIZE); 1269 SymbolGlyph.height(SYMBOL_TITLE_SIZE); 1270 SymbolGlyph.margin({ 1271 top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level24'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1272 bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1273 }); 1274 SymbolGlyph.fontSize(SYMBOL_TITLE_SIZE); 1275 SymbolGlyph.fontColor([{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]); 1276 }, SymbolGlyph); 1277 }); 1278 } 1279 else { 1280 this.ifElseBranchUpdateFunction(1, () => { 1281 this.observeComponentCreation2((k2, l2) => { 1282 Image.create(this.itemEditableDialog.value); 1283 Image.width(IMAGE_SIZE); 1284 Image.height(IMAGE_SIZE); 1285 Image.margin({ 1286 top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level24'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1287 bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1288 }); 1289 Image.fillColor({ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1290 }, Image); 1291 }); 1292 } 1293 }, If); 1294 If.pop(); 1295 this.observeComponentCreation2((a1, b1) => { 1296 Column.create(); 1297 Column.width('100%'); 1298 Column.padding({ 1299 left: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1300 right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1301 bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level12'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, 1302 }); 1303 }, Column); 1304 this.observeComponentCreation2((y, z) => { 1305 Text.create(this.textEditableTitleBarDialog); 1306 Text.fontSize(TEXT_EDITABLE_DIALOG); 1307 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 1308 Text.maxLines(this.maxLines); 1309 Text.width('100%'); 1310 Text.textAlign(TextAlign.Center); 1311 Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1312 }, Text); 1313 Text.pop(); 1314 Column.pop(); 1315 Column.pop(); 1316 }); 1317 } 1318 else { 1319 this.ifElseBranchUpdateFunction(1, () => { 1320 this.observeComponentCreation2((r, s) => { 1321 Column.create(); 1322 Column.width(this.fontSize === this.maxFontSize ? MAX_DIALOG : MIN_DIALOG); 1323 Column.constraintSize({ minHeight: this.fontSize === this.maxFontSize ? MAX_DIALOG : MIN_DIALOG }); 1324 Column.backgroundBlurStyle(BlurStyle.COMPONENT_ULTRA_THICK); 1325 Column.shadow(ShadowStyle.OUTER_DEFAULT_LG); 1326 Column.borderRadius(({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level10'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 1327 Column.justifyContent(FlexAlign.Center); 1328 }, Column); 1329 this.observeComponentCreation2((p, q) => { 1330 If.create(); 1331 if (this.useSymbol) { 1332 this.ifElseBranchUpdateFunction(0, () => { 1333 this.observeComponentCreation2((d2, h2) => { 1334 SymbolGlyph.create(this.itemEditableDialog.value); 1335 SymbolGlyph.width(SYMBOL_TITLE_SIZE); 1336 SymbolGlyph.height(SYMBOL_TITLE_SIZE); 1337 SymbolGlyph.fontSize(SYMBOL_TITLE_SIZE); 1338 SymbolGlyph.fontColor([{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]); 1339 }, SymbolGlyph); 1340 }); 1341 } 1342 else { 1343 this.ifElseBranchUpdateFunction(1, () => { 1344 this.observeComponentCreation2((v, w) => { 1345 Image.create(this.itemEditableDialog.value); 1346 Image.width(IMAGE_SIZE); 1347 Image.height(IMAGE_SIZE); 1348 Image.fillColor({ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 1349 }, Image); 1350 }); 1351 } 1352 }, If); 1353 If.pop(); 1354 Column.pop(); 1355 }); 1356 } 1357 }, If); 1358 If.pop(); 1359 } 1360 async aboutToAppear() { 1361 let g = this.getUIContext().getHostContext(); 1362 this.mainWindowStage = g.windowStage.getMainWindowSync(); 1363 let h = this.mainWindowStage.getWindowProperties(); 1364 let i = h.windowRect; 1365 if (px2vp(i.height) > this.screenWidth) { 1366 this.maxLines = this.verticalScreenLines; 1367 } 1368 else { 1369 this.maxLines = this.horizontalsScreenLines; 1370 } 1371 } 1372 rerender() { 1373 this.updateDirtyElements(); 1374 } 1375} 1376function getNumberByResource(a, b) { 1377 try { 1378 let f = resourceManager.getSystemResourceManager().getNumber(a); 1379 if (f === 0) { 1380 return b; 1381 } 1382 else { 1383 return f; 1384 } 1385 } 1386 catch (c) { 1387 let d = c.code; 1388 let e = c.message; 1389 hilog.error(0x3900, 'Ace', `EditableTitleBar getNumberByResource error, code: ${d},message:${e}`); 1390 return 0; 1391 } 1392} 1393 1394export default { 1395 EditableLeftIconType: EditableLeftIconType, 1396 EditableTitleBar: EditableTitleBar, 1397};