1/* 2 * Copyright (c) 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 16var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 17 var c = arguments.length, 18 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 19 if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') { 20 r = 21 Reflect.decorate(decorators, target, key, desc); 22 } else { 23 for (var i = decorators.length - 1; i >= 0; i--) { 24 if (d = 25 decorators[i]) { 26 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 27 } 28 } 29 } 30 return c > 3 && r && Object.defineProperty(target, key, r), r; 31}; 32if (!('finalizeConstruction' in ViewPU.prototype)) { 33 Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { 34 }); 35} 36 37const arkuiNode = requireNapi('arkui.node'); 38const LengthMetrics = arkuiNode.LengthMetrics; 39const ColorMetrics = arkuiNode.ColorMetrics; 40const LengthUnit = arkuiNode.LengthUnit; 41const resourceManager = requireNapi('resourceManager'); 42const BusinessError = requireNapi('base'); 43const common = requireNapi('app.ability.common'); 44const hilog = requireNapi('hilog'); 45const HashMap = requireNapi('util.HashMap'); 46const SymbolGlyphModifier = requireNapi('arkui.modifier').SymbolGlyphModifier; 47const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; 48 49const INDEX_ZERO = 0; 50const INDEX_ONE = 1; 51const INDEX_TWO = 2; 52// 行数及整体高度 53const SINGLE_LINE_NUM = 1; 54const DOUBLE_LINE_NUM = 2; 55// 资源数值 56const RESOURCE_TYPE_SYMBOL = 40000; 57// 左边尺寸常量 58const LEFT_ICON_SIZE_NUMBER = 16; 59const LEFT_TEXT_NUMBER = 8; 60// 右边尺寸常量 61const OPERATE_ITEM_LENGTH = 24; 62const ARROW_ICON_WIDTH = 12; 63const SINGLE_ICON_ZONE_SIZE = 28; 64const RIGHT_SINGLE_ICON_SIZE = '24vp'; 65const PADDING_LEVEL_2 = 4; 66const MAX_RIGHT_WIDTH = '34%'; 67const MIN_FONT_SIZE = 1.75; 68const MIN_HOT_AREA_LENGTH = 40; 69const MULTI_ICON_REGION_WIDTH = 37; 70const ICON_REGION_X = -9; 71const ICON_REGION_Y = -6; 72const SINGLE_ICON_REGION_X = -12; 73const SINGLE_ICON_NUMBER = 1; 74const PADDING_LEFT = 2; 75let SubHeaderV2Title = class SubHeaderV2Title { 76 constructor(options) { 77 this.primaryTitle = options.primaryTitle; 78 this.primaryTitleModifier = options.primaryTitleModifier; 79 this.secondaryTitle = options.secondaryTitle; 80 this.secondaryTitleModifier = options.secondaryTitleModifier; 81 } 82}; 83__decorate([ 84 Trace 85], SubHeaderV2Title.prototype, 'primaryTitle', void 0); 86__decorate([ 87 Trace 88], SubHeaderV2Title.prototype, 'primaryTitleModifier', void 0); 89__decorate([ 90 Trace 91], SubHeaderV2Title.prototype, 'secondaryTitle', void 0); 92__decorate([ 93 Trace 94], SubHeaderV2Title.prototype, 'secondaryTitleModifier', void 0); 95SubHeaderV2Title = __decorate([ 96 ObservedV2 97], SubHeaderV2Title); 98 99export { SubHeaderV2Title }; 100let SubHeaderV2Select = class SubHeaderV2Select { 101 constructor(options) { 102 this.options = options.options; 103 this.selectedIndex = options.selectedIndex; 104 this.selectedContent = options.selectedContent; 105 this.onSelect = options.onSelect; 106 this.defaultFocus = options.defaultFocus; 107 } 108}; 109__decorate([ 110 Trace 111], SubHeaderV2Select.prototype, 'options', void 0); 112__decorate([ 113 Trace 114], SubHeaderV2Select.prototype, 'selectedIndex', void 0); 115__decorate([ 116 Trace 117], SubHeaderV2Select.prototype, 'selectedContent', void 0); 118__decorate([ 119 Trace 120], SubHeaderV2Select.prototype, 'onSelect', void 0); 121__decorate([ 122 Trace 123], SubHeaderV2Select.prototype, 'defaultFocus', void 0); 124SubHeaderV2Select = __decorate([ 125 ObservedV2 126], SubHeaderV2Select); 127 128export { SubHeaderV2Select }; 129 130export var SubHeaderV2OperationType; 131(function (SubHeaderV2OperationType) { 132 SubHeaderV2OperationType[SubHeaderV2OperationType['TEXT_ARROW'] = 0] = 'TEXT_ARROW'; 133 SubHeaderV2OperationType[SubHeaderV2OperationType['BUTTON'] = 1] = 'BUTTON'; 134 SubHeaderV2OperationType[SubHeaderV2OperationType['ICON_GROUP'] = 2] = 'ICON_GROUP'; 135 SubHeaderV2OperationType[SubHeaderV2OperationType['LOADING'] = 3] = 'LOADING'; 136})(SubHeaderV2OperationType || (SubHeaderV2OperationType = {})); 137let SubHeaderV2OperationItem = class SubHeaderV2OperationItem { 138 constructor(options) { 139 this.content = options.content; 140 this.action = options.action; 141 this.accessibilityText = options.accessibilityText; 142 this.accessibilityDescription = options.accessibilityDescription; 143 this.accessibilityLevel = options.accessibilityLevel; 144 this.defaultFocus = options.defaultFocus; 145 } 146}; 147__decorate([ 148 Trace 149], SubHeaderV2OperationItem.prototype, 'content', void 0); 150__decorate([ 151 Trace 152], SubHeaderV2OperationItem.prototype, 'action', void 0); 153__decorate([ 154 Trace 155], SubHeaderV2OperationItem.prototype, 'accessibilityText', void 0); 156__decorate([ 157 Trace 158], SubHeaderV2OperationItem.prototype, 'accessibilityDescription', void 0); 159__decorate([ 160 Trace 161], SubHeaderV2OperationItem.prototype, 'accessibilityLevel', void 0); 162__decorate([ 163 Trace 164], SubHeaderV2OperationItem.prototype, 'defaultFocus', void 0); 165SubHeaderV2OperationItem = __decorate([ 166 ObservedV2 167], SubHeaderV2OperationItem); 168 169export { SubHeaderV2OperationItem }; 170let ContentIconOption = class ContentIconOption { 171}; 172__decorate([ 173 Trace 174], ContentIconOption.prototype, 'content', void 0); 175__decorate([ 176 Trace 177], ContentIconOption.prototype, 'subContent', void 0); 178__decorate([ 179 Trace 180], ContentIconOption.prototype, 'iconOptions', void 0); 181__decorate([ 182 Trace 183], ContentIconOption.prototype, 'action', void 0); 184__decorate([ 185 Trace 186], ContentIconOption.prototype, 'accessibilityLevel', void 0); 187__decorate([ 188 Trace 189], ContentIconOption.prototype, 'accessibilityText', void 0); 190__decorate([ 191 Trace 192], ContentIconOption.prototype, 'accessibilityDescription', void 0); 193__decorate([ 194 Trace 195], ContentIconOption.prototype, 'defaultFocus', void 0); 196ContentIconOption = __decorate([ 197 ObservedV2 198], ContentIconOption); 199let FontStyle = class FontStyle { 200 constructor() { 201 this.maxLines = 0; 202 this.fontWeight = 0; 203 } 204}; 205__decorate([ 206 Trace 207], FontStyle.prototype, 'maxLines', void 0); 208__decorate([ 209 Trace 210], FontStyle.prototype, 'fontWeight', void 0); 211__decorate([ 212 Trace 213], FontStyle.prototype, 'fontColor', void 0); 214__decorate([ 215 Trace 216], FontStyle.prototype, 'alignment', void 0); 217FontStyle = __decorate([ 218 ObservedV2 219], FontStyle); 220let SubHeaderTheme = class SubHeaderTheme { 221 constructor() { 222 this.fontPrimaryColor = { 223 'id': -1, 224 'type': 10001, 225 params: ['sys.color.font_primary'], 226 'bundleName': '__harDefaultBundleName__', 227 'moduleName': '__harDefaultModuleName__', 228 }; 229 this.fontSecondaryColor = { 230 'id': -1, 231 'type': 10001, 232 params: ['sys.color.font_secondary'], 233 'bundleName': '__harDefaultBundleName__', 234 'moduleName': '__harDefaultModuleName__', 235 }; 236 this.fontButtonColor = { 237 'id': -1, 238 'type': 10001, 239 params: ['sys.color.font_emphasize'], 240 'bundleName': '__harDefaultBundleName__', 241 'moduleName': '__harDefaultModuleName__', 242 }; 243 this.iconArrowColor = { 244 'id': -1, 245 'type': 10001, 246 params: ['sys.color.icon_tertiary'], 247 'bundleName': '__harDefaultBundleName__', 248 'moduleName': '__harDefaultModuleName__', 249 }; 250 this.textArrowHoverBgColor = { 251 'id': -1, 252 'type': 10001, 253 params: ['sys.color.interactive_hover'], 254 'bundleName': '__harDefaultBundleName__', 255 'moduleName': '__harDefaultModuleName__', 256 }; 257 this.borderFocusColor = { 258 'id': -1, 259 'type': 10001, 260 params: ['sys.color.interactive_focus'], 261 'bundleName': '__harDefaultBundleName__', 262 'moduleName': '__harDefaultModuleName__', 263 }; 264 this.leftIconColor = { 265 'id': -1, 266 'type': 10001, 267 params: ['sys.color.icon_secondary'], 268 'bundleName': '__harDefaultBundleName__', 269 'moduleName': '__harDefaultModuleName__', 270 }; 271 this.rightIconColor = { 272 'id': -1, 273 'type': 10001, 274 params: ['sys.color.icon_primary'], 275 'bundleName': '__harDefaultBundleName__', 276 'moduleName': '__harDefaultModuleName__', 277 }; 278 } 279}; 280__decorate([ 281 Trace 282], SubHeaderTheme.prototype, 'fontPrimaryColor', void 0); 283__decorate([ 284 Trace 285], SubHeaderTheme.prototype, 'fontSecondaryColor', void 0); 286__decorate([ 287 Trace 288], SubHeaderTheme.prototype, 'fontButtonColor', void 0); 289__decorate([ 290 Trace 291], SubHeaderTheme.prototype, 'iconArrowColor', void 0); 292__decorate([ 293 Trace 294], SubHeaderTheme.prototype, 'textArrowHoverBgColor', void 0); 295__decorate([ 296 Trace 297], SubHeaderTheme.prototype, 'borderFocusColor', void 0); 298__decorate([ 299 Trace 300], SubHeaderTheme.prototype, 'leftIconColor', void 0); 301__decorate([ 302 Trace 303], SubHeaderTheme.prototype, 'rightIconColor', void 0); 304SubHeaderTheme = __decorate([ 305 ObservedV2 306], SubHeaderTheme); 307 308function __Text__secondaryTitleStyles(fontStyle) { 309 Text.fontSize(`${getResourceValue('sys.float.Subtitle_S')}fp`); 310 Text.fontColor(fontStyle?.fontColor ?? { 311 'id': -1, 312 'type': 10001, 313 params: ['sys.color.font_secondary'], 314 'bundleName': '__harDefaultBundleName__', 315 'moduleName': '__harDefaultModuleName__', 316 }); 317 Text.fontWeight(fontStyle?.fontWeight); 318 Text.maxLines(fontStyle?.maxLines); 319 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 320 Text.align(fontStyle?.alignment); 321} 322 323function __Text__primaryTitleStyles(fontStyle) { 324 Text.fontSize(`${getResourceValue('sys.float.subheader_title_font_size')}fp`); 325 Text.fontColor(fontStyle?.fontColor ?? { 326 'id': -1, 327 'type': 10001, 328 params: ['sys.color.font_primary'], 329 'bundleName': '__harDefaultBundleName__', 330 'moduleName': '__harDefaultModuleName__', 331 }); 332 Text.fontWeight(fontStyle?.fontWeight); 333 Text.maxLines(fontStyle?.maxLines); 334 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 335 Text.align(fontStyle?.alignment); 336} 337 338class SubHeaderModifier { 339 constructor() { 340 this.isAgeing = false; 341 } 342 343 applyNormalAttribute(instance) { 344 if (this.isAgeing) { 345 instance.width('100%'); 346 } else { 347 } 348 } 349} 350 351export class SubHeaderV2 extends ViewV2 { 352 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { 353 super(parent, elmtId, extraInfo); 354 this.initParam('icon', (params && 'icon' in params) ? params.icon : undefined); 355 this.initParam('title', (params && 'title' in params) ? params.title : undefined); 356 this.initParam('select', (params && 'select' in params) ? params.select : undefined); 357 this.initParam('operationType', 358 (params && 'operationType' in params) ? params.operationType : SubHeaderV2OperationType.BUTTON); 359 this.initParam('operationItems', (params && 'operationItems' in params) ? params.operationItems : undefined); 360 this.titleBuilder = 'titleBuilder' in params ? params.titleBuilder : undefined; 361 this.fontSize = 1; 362 this.ageing = true; 363 this.textArrowBgColor = { 364 'id': -1, 365 'type': 10001, 366 params: ['sys.color.ohos_id_color_sub_background_transparent'], 367 'bundleName': '__harDefaultBundleName__', 368 'moduleName': '__harDefaultModuleName__', 369 }; 370 this.buttonBgColor = { 371 'id': -1, 372 'type': 10001, 373 params: ['sys.color.ohos_id_color_sub_background_transparent'], 374 'bundleName': '__harDefaultBundleName__', 375 'moduleName': '__harDefaultModuleName__', 376 }; 377 this.selectedIndex = -1; 378 this.selectedContent = ''; 379 this.symbolWidth = LEFT_ICON_SIZE_NUMBER + LEFT_TEXT_NUMBER; 380 this.subHeaderModifier = new SubHeaderModifier(); 381 this.isFollowingSystemFontScale = false; 382 this.appMaxFontScale = 3.2; 383 this.subHeaderV2Theme = new SubHeaderTheme(); 384 this.subHeaderMargin = { 385 start: LengthMetrics.vp(getResourceValue('sys.float.subheader_content_margin_start')), 386 end: LengthMetrics.vp(getResourceValue('sys.float.subheader_content_margin_end')), 387 }; 388 this.finalizeConstruction(); 389 } 390 391 onWillApplyTheme(theme) { 392 this.subHeaderV2Theme.fontPrimaryColor = theme.colors.fontPrimary; 393 this.subHeaderV2Theme.fontSecondaryColor = theme.colors.fontSecondary; 394 this.subHeaderV2Theme.fontButtonColor = theme.colors.fontEmphasize; 395 this.subHeaderV2Theme.iconArrowColor = theme.colors.iconTertiary; 396 this.subHeaderV2Theme.textArrowHoverBgColor = theme.colors.interactiveHover; 397 this.subHeaderV2Theme.borderFocusColor = theme.colors.interactiveFocus; 398 this.subHeaderV2Theme.leftIconColor = theme.colors.iconSecondary; 399 this.subHeaderV2Theme.rightIconColor = theme.colors.iconPrimary; 400 } 401 402 async aboutToAppear() { 403 let uiContext = this.getUIContext(); 404 this.isFollowingSystemFontScale = uiContext.isFollowingSystemFontScale(); 405 this.appMaxFontScale = uiContext.getMaxFontScale(); 406 this.fontSize = this.updateFontScale(); 407 if (this.isSuitableAging()) { 408 this.ageing = true; 409 this.subHeaderModifier.isAgeing = this.ageing; 410 } else { 411 this.ageing = false; 412 this.subHeaderModifier.isAgeing = this.ageing; 413 } 414 if (this.select) { 415 this.selectedIndex = this.select.selectedIndex; 416 this.selectedContent = this.select.selectedContent; 417 } 418 } 419 420 updateFontScale() { 421 try { 422 let uiContext = this.getUIContext(); 423 let systemFontScale = uiContext.getHostContext()?.config?.fontSizeScale ?? 1; 424 if (!this.isFollowingSystemFontScale) { 425 return 1; 426 } 427 return Math.min(systemFontScale, this.appMaxFontScale); 428 } catch (exception) { 429 let code = exception.code; 430 let message = exception.message; 431 hilog.error(0x3900, 'Ace', `Faild to init fontsizescale info,cause, code: ${code}, message: ${message}`); 432 return 1; 433 } 434 } 435 436 IconSecondaryTitleStyle($$, parent = null) { 437 this.observeComponentCreation2((elmtId, isInitialRender) => { 438 Flex.create({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }); 439 Flex.padding({ 440 end: LengthMetrics.vp(getResourceValue('sys.float.padding_level6')), 441 top: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 442 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 443 bottom: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 444 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 445 }); 446 }, Flex); 447 this.observeComponentCreation2((elmtId, isInitialRender) => { 448 If.create(); 449 if (Util.isSymbolResource($$.iconOptions)) { 450 this.ifElseBranchUpdateFunction(0, () => { 451 { 452 this.observeComponentCreation2((elmtId, isInitialRender) => { 453 if (isInitialRender) { 454 let componentCall = new SymbolGlyphChild(this, { 455 icon: $$.iconOptions, 456 fontColor: [this.subHeaderV2Theme.leftIconColor], 457 changeSymbolWidth: (result) => { 458 this.symbolWidth = result.width; 459 } 460 }, undefined, elmtId, () => { 461 }, { page: 'library/src/main/ets/components/MainPage.ets', line: 335, col: 9 }); 462 ViewV2.create(componentCall); 463 let paramsLambda = () => { 464 return { 465 icon: $$.iconOptions, 466 fontColor: [this.subHeaderV2Theme.leftIconColor], 467 changeSymbolWidth: (result) => { 468 this.symbolWidth = result.width; 469 } 470 }; 471 }; 472 componentCall.paramsGenerator_ = paramsLambda; 473 } else { 474 this.updateStateVarsOfChildByElmtId(elmtId, { 475 icon: $$.iconOptions, 476 fontColor: [this.subHeaderV2Theme.leftIconColor] 477 }); 478 } 479 }, { name: 'SymbolGlyphChild' }); 480 } 481 }); 482 } else { 483 this.ifElseBranchUpdateFunction(1, () => { 484 this.observeComponentCreation2((elmtId, isInitialRender) => { 485 Image.create($$.iconOptions); 486 Image.fillColor(this.subHeaderV2Theme.leftIconColor); 487 Image.width(getResourceValue('sys.float.subheader_left_icon_size')); 488 Image.height(getResourceValue('sys.float.subheader_left_icon_size')); 489 Image.margin({ end: LengthMetrics.vp(getResourceValue('sys.float.subheader_left_icon_end_margin')) }); 490 Image.draggable(false); 491 Image.flexShrink(0); 492 }, Image); 493 }); 494 } 495 }, If); 496 If.pop(); 497 this.observeComponentCreation2((elmtId, isInitialRender) => { 498 Text.create($$.content); 499 __Text__secondaryTitleStyles({ 500 maxLines: DOUBLE_LINE_NUM, 501 fontWeight: FontWeight.Medium, 502 alignment: Alignment.Start, 503 fontColor: this.subHeaderV2Theme.fontSecondaryColor, 504 }); 505 Text.attributeModifier.bind(this)(this.title?.secondaryTitleModifier); 506 Text.flexShrink(1); 507 }, Text); 508 Text.pop(); 509 Flex.pop(); 510 } 511 512 isSuitableAging() { 513 return (this.fontSize >= MIN_FONT_SIZE) && ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW) || 514 this.operationType === SubHeaderV2OperationType.BUTTON) && this.operationItems !== undefined && 515 (this.operationItems?.length > 0) && this.operationItems[0].content !== ''; 516 } 517 518 isLeftAreaAccessibilityGroup() { 519 if (this.titleBuilder || this.title?.secondaryTitle) { 520 return true; 521 } 522 if (this.select) { 523 return false; 524 } 525 return true; 526 } 527 528 infoChange(monitor) { 529 monitor.dirty.forEach((path) => { 530 if ('select' === path) { 531 this.selectedIndex = monitor.value(path)?.now?.selectedIndex; 532 this.selectedContent = monitor.value(path)?.now?.selectedContent; 533 } 534 }); 535 } 536 537 SelectStyle(selectParam, parent = null) { 538 this.observeComponentCreation2((elmtId, isInitialRender) => { 539 Select.create(selectParam.params.options); 540 Select.height('auto'); 541 Select.width('auto'); 542 Select.selected(this.selectedIndex); 543 Select.value(this.selectedContent); 544 Select.defaultFocus(this.select?.defaultFocus); 545 Select.onSelect((index, value) => { 546 this.selectedIndex = index; 547 if (value) { 548 this.selectedContent = value; 549 } 550 if (selectParam.params.onSelect) { 551 selectParam.params.onSelect(index, value); 552 } 553 }); 554 Select.font({ 555 size: `${getResourceValue('sys.float.Body_L')}fp`, 556 weight: FontWeight.Medium, 557 }); 558 }, Select); 559 Select.pop(); 560 } 561 562 SubTitleStyle($$, parent = null) { 563 this.observeComponentCreation2((elmtId, isInitialRender) => { 564 Column.create(); 565 Column.width('100%'); 566 Column.padding({ 567 end: LengthMetrics.vp(getResourceValue('sys.float.padding_level0')), 568 top: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 569 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 570 bottom: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 571 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 572 }); 573 Column.alignItems(HorizontalAlign.Start); 574 }, Column); 575 this.observeComponentCreation2((elmtId, isInitialRender) => { 576 Text.create($$.content); 577 __Text__primaryTitleStyles({ 578 fontWeight: getResourceValue('sys.float.subheader_title_font_weight'), 579 maxLines: DOUBLE_LINE_NUM, 580 alignment: Alignment.Start, 581 fontColor: this.subHeaderV2Theme.fontPrimaryColor, 582 }); 583 Text.attributeModifier.bind(this)(this.title?.primaryTitleModifier); 584 }, Text); 585 Text.pop(); 586 this.observeComponentCreation2((elmtId, isInitialRender) => { 587 Text.create($$.subContent); 588 __Text__secondaryTitleStyles({ 589 maxLines: DOUBLE_LINE_NUM, 590 fontWeight: getResourceValue('sys.float.subheader_subtitle_font_weight'), 591 alignment: Alignment.Start, 592 fontColor: this.subHeaderV2Theme.fontSecondaryColor, 593 }); 594 Text.margin({ 595 top: getResourceValue('sys.float.subheader_titles_space'), 596 }); 597 Text.attributeModifier.bind(this)(this.title?.secondaryTitleModifier); 598 }, Text); 599 Text.pop(); 600 Column.pop(); 601 } 602 603 SecondTitleStyle($$, parent = null) { 604 this.observeComponentCreation2((elmtId, isInitialRender) => { 605 Text.create($$.content); 606 __Text__secondaryTitleStyles({ 607 maxLines: DOUBLE_LINE_NUM, 608 fontWeight: FontWeight.Medium, 609 alignment: Alignment.Start, 610 fontColor: this.subHeaderV2Theme.fontSecondaryColor, 611 }); 612 Text.attributeModifier.bind(this)(this.title?.secondaryTitleModifier); 613 Text.padding({ 614 end: LengthMetrics.vp(getResourceValue('sys.float.padding_level6')), 615 top: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 616 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 617 bottom: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 618 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 619 }); 620 }, Text); 621 Text.pop(); 622 } 623 624 PrimaryTitleStyle($$, parent = null) { 625 this.observeComponentCreation2((elmtId, isInitialRender) => { 626 Text.create($$.content); 627 __Text__primaryTitleStyles({ 628 fontWeight: getResourceValue('sys.float.subheader_title_font_weight'), 629 maxLines: DOUBLE_LINE_NUM, 630 alignment: Alignment.Start, 631 fontColor: this.subHeaderV2Theme.fontPrimaryColor, 632 }); 633 Text.attributeModifier.bind(this)(this.title?.primaryTitleModifier); 634 Text.padding({ 635 end: LengthMetrics.vp(getResourceValue('sys.float.padding_level0')), 636 top: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 637 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 638 bottom: this.fontSize >= MIN_FONT_SIZE ? LengthMetrics.vp(getResourceValue('sys.float.padding_level0')) 639 : LengthMetrics.vp(getResourceValue('sys.float.subheader_content_padding')), 640 }); 641 }, Text); 642 Text.pop(); 643 } 644 645 leftArea(parent = null) { 646 this.observeComponentCreation2((elmtId, isInitialRender) => { 647 If.create(); 648 if (this.titleBuilder) { 649 this.ifElseBranchUpdateFunction(0, () => { 650 this.titleBuilder.bind(this)(); 651 }); 652 } else if (this.title?.secondaryTitle && this.icon) { 653 this.ifElseBranchUpdateFunction(1, () => { 654 this.IconSecondaryTitleStyle.bind(this)(makeBuilderParameterProxy('IconSecondaryTitleStyle', { 655 content: () => this.title?.secondaryTitle, 656 iconOptions: () => (this['__icon'] ? this['__icon'] : this['icon']) 657 })); 658 }); 659 } else if (this.title?.secondaryTitle && this.title?.primaryTitle) { 660 this.ifElseBranchUpdateFunction(2, () => { 661 this.SubTitleStyle.bind(this)(makeBuilderParameterProxy('SubTitleStyle', 662 { content: () => this.title?.primaryTitle, subContent: () => this.title?.secondaryTitle })); 663 }); 664 } else if (this.title?.secondaryTitle) { 665 this.ifElseBranchUpdateFunction(3, () => { 666 this.SecondTitleStyle.bind(this)(makeBuilderParameterProxy('SecondTitleStyle', 667 { content: () => this.title?.secondaryTitle })); 668 }); 669 } else if (this.select) { 670 this.ifElseBranchUpdateFunction(4, () => { 671 this.SelectStyle.bind(this)(makeBuilderParameterProxy('SelectStyle', 672 { params: () => (this['__select'] ? this['__select'] : this['select']) })); 673 }); 674 } else if (this.title?.primaryTitle) { 675 this.ifElseBranchUpdateFunction(5, () => { 676 this.PrimaryTitleStyle.bind(this)(makeBuilderParameterProxy('PrimaryTitleStyle', 677 { content: () => this.title?.primaryTitle })); 678 }); 679 } else { 680 this.ifElseBranchUpdateFunction(6, () => { 681 // 其他不支持场景 682 this.dummyFunction.bind(this)(); 683 }); 684 } 685 }, If); 686 If.pop(); 687 } 688 689 isRightAreaExists() { 690 if (this.operationItems && this.operationItems.length > 0) { 691 return true; 692 } 693 if (this.operationType === SubHeaderV2OperationType.LOADING) { 694 return true; 695 } 696 return false; 697 } 698 699 getRightAreaMaxWidth() { 700 if (this.operationType === SubHeaderV2OperationType.ICON_GROUP && 701 (this.operationItems && this.operationItems.length > 0)) { 702 return '100%'; 703 } 704 return MAX_RIGHT_WIDTH; 705 } 706 707 getRightAreaMinWidth() { 708 if (this.operationItems && this.operationItems.length > 0) { 709 return MIN_HOT_AREA_LENGTH; 710 } 711 return 0; 712 } 713 714 getAccessibilityDescription() { 715 if (!this.operationItems || this.operationItems.length <= 0) { 716 return ''; 717 } 718 if (this.operationItems[0]?.accessibilityDescription && 719 this.operationItems[0]?.accessibilityDescription !== '') { 720 return this.operationItems[0]?.accessibilityDescription; 721 } 722 return ''; 723 } 724 725 leftIconMargin() { 726 if (this.titleBuilder) { 727 return LengthMetrics.vp(0); 728 } 729 if (this.icon && Util.isSymbolResource(this.icon)) { 730 return this.ageing ? 731 LengthMetrics.vp(this.symbolWidth) : 732 LengthMetrics.vp(0); 733 } else { 734 return (this.ageing && this.icon) ? LengthMetrics.vp(LEFT_ICON_SIZE_NUMBER + 735 LEFT_TEXT_NUMBER) : LengthMetrics.vp(0); 736 } 737 } 738 739 onMeasureSize(selfLayoutInfo, children, constraint) { 740 let result = { width: selfLayoutInfo.width, height: selfLayoutInfo.height }; 741 let context = this.getUIContext().getHostContext(); 742 this.fontSize = this.updateFontScale(); 743 if (this.isSuitableAging()) { 744 this.ageing = true; 745 this.subHeaderModifier.isAgeing = this.ageing; 746 } else { 747 this.ageing = false; 748 this.subHeaderModifier.isAgeing = this.ageing; 749 } 750 children.forEach((child) => { 751 constraint.minHeight = Math.min(Number(this.getMinHeight()), Number(constraint.maxHeight)); 752 result.height = child.measure(constraint).height; 753 result.width = Number(constraint.maxWidth); 754 }); 755 return result; 756 } 757 758 ButtonStyle(parent = null) { 759 this.observeComponentCreation2((elmtId, isInitialRender) => { 760 If.create(); 761 if (this.operationItems) { 762 this.ifElseBranchUpdateFunction(0, () => { 763 this.observeComponentCreation2((elmtId, isInitialRender) => { 764 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 765 Button.focusable(true); 766 Button.focusBox({ 767 margin: { value: INDEX_ZERO, unit: LengthUnit.VP }, 768 strokeColor: ColorMetrics.resourceColor(this.subHeaderV2Theme.borderFocusColor), 769 strokeWidth: LengthMetrics.vp(getResourceValue('sys.float.outline_extra_larger')), 770 }); 771 Button.padding({ 772 start: LengthMetrics.vp(getResourceValue('sys.float.padding_level1')), 773 end: LengthMetrics.vp(getResourceValue('sys.float.padding_level1')), 774 top: LengthMetrics.vp(getResourceValue('sys.float.padding_level2')), 775 bottom: LengthMetrics.vp(getResourceValue('sys.float.padding_level2')), 776 }); 777 Button.margin({ 778 start: this.ageing ? 779 LengthMetrics.vp(LengthMetrics.vp(getResourceValue('sys.float.padding_level0')).value + 780 this.leftIconMargin().value) : 781 LengthMetrics.vp(LengthMetrics.vp(getResourceValue('sys.float.padding_level4')).value + 782 this.leftIconMargin().value), 783 bottom: LengthMetrics.vp(this.ageing ? getResourceValue('sys.float.padding_level0') : 784 getResourceValue('sys.float.padding_level2')), 785 }); 786 Button.backgroundColor(this.buttonBgColor); 787 Button.constraintSize({ minHeight: OPERATE_ITEM_LENGTH }); 788 Button.align(Alignment.End); 789 Button.borderRadius(getResourceValue('sys.float.corner_radius_level4')); 790 Button.onHover((isHover) => { 791 if (isHover) { 792 this.buttonBgColor = this.subHeaderV2Theme.textArrowHoverBgColor; 793 } else { 794 this.buttonBgColor = { 795 'id': -1, 796 'type': 10001, 797 params: ['sys.color.ohos_id_color_sub_background_transparent'], 798 'bundleName': '__harDefaultBundleName__', 799 'moduleName': '__harDefaultModuleName__', 800 }; 801 } 802 }); 803 ViewStackProcessor.visualState('pressed'); 804 Button.backgroundColor({ 805 'id': -1, 806 'type': 10001, 807 params: ['sys.color.interactive_pressed'], 808 'bundleName': '__harDefaultBundleName__', 809 'moduleName': '__harDefaultModuleName__', 810 }); 811 ViewStackProcessor.visualState('disabled'); 812 Button.opacity(getResourceValue('sys.float.interactive_disable')); 813 ViewStackProcessor.visualState(); 814 }, Button); 815 this.observeComponentCreation2((elmtId, isInitialRender) => { 816 Text.create(this.operationItems[0].content); 817 __Text__secondaryTitleStyles({ 818 fontWeight: FontWeight.Medium, 819 maxLines: DOUBLE_LINE_NUM, 820 fontColor: this.subHeaderV2Theme.fontButtonColor, 821 }); 822 Text.defaultFocus(this.operationItems[0].defaultFocus); 823 Text.focusable(true); 824 }, Text); 825 Text.pop(); 826 Button.pop(); 827 }); 828 } else { 829 this.ifElseBranchUpdateFunction(1, () => { 830 }); 831 } 832 }, If); 833 If.pop(); 834 } 835 836 getTextArrowPaddingLeft() { 837 if (this.operationItems && this.operationItems.length > 0 && this.operationItems[0].content) { 838 return LengthMetrics.vp(getResourceValue('sys.float.padding_level1')); 839 } 840 return LengthMetrics.vp(getResourceValue('sys.float.padding_level0')); 841 } 842 843 getTextArrowMarginRight() { 844 if (this.operationItems && this.operationItems.length > 0 && this.operationItems[0].content) { 845 return LengthMetrics.vp(PADDING_LEVEL_2 + ARROW_ICON_WIDTH); 846 } 847 return LengthMetrics.vp(ARROW_ICON_WIDTH); 848 } 849 850 TextStyle(parent = null) { 851 this.observeComponentCreation2((elmtId, isInitialRender) => { 852 Row.create(); 853 Row.attributeModifier.bind(this)(this.subHeaderModifier); 854 Row.alignItems(VerticalAlign.Center); 855 Row.focusable(true); 856 Row.constraintSize({ minHeight: OPERATE_ITEM_LENGTH }); 857 Row.padding({ 858 start: this.getTextArrowPaddingLeft(), 859 top: this.ageing ? LengthMetrics.vp(0) : LengthMetrics.vp(getResourceValue('sys.float.padding_level2')), 860 bottom: this.ageing ? LengthMetrics.vp(0) : 861 LengthMetrics.vp(getResourceValue('sys.float.padding_level2')), 862 }); 863 }, Row); 864 this.observeComponentCreation2((elmtId, isInitialRender) => { 865 If.create(); 866 if (this.operationItems?.[0]) { 867 this.ifElseBranchUpdateFunction(0, () => { 868 this.observeComponentCreation2((elmtId, isInitialRender) => { 869 Text.create(this.operationItems[0].content); 870 __Text__secondaryTitleStyles({ 871 maxLines: DOUBLE_LINE_NUM, 872 fontWeight: FontWeight.Regular, 873 alignment: Alignment.End, 874 fontColor: this.subHeaderV2Theme.fontSecondaryColor, 875 }); 876 Text.focusable(true); 877 Text.defaultFocus(this.operationItems[0].defaultFocus); 878 Text.margin({ 879 end: this.getTextArrowMarginRight(), 880 }); 881 }, Text); 882 Text.pop(); 883 }); 884 } else { 885 this.ifElseBranchUpdateFunction(1, () => { 886 }); 887 } 888 }, If); 889 If.pop(); 890 Row.pop(); 891 } 892 893 ArrowStyle(parent = null) { 894 this.observeComponentCreation2((elmtId, isInitialRender) => { 895 Row.create(); 896 Row.justifyContent(FlexAlign.End); 897 }, Row); 898 this.observeComponentCreation2((elmtId, isInitialRender) => { 899 SymbolGlyph.create({ 900 'id': -1, 901 'type': 40000, 902 params: ['sys.symbol.chevron_right'], 903 'bundleName': '__harDefaultBundleName__', 904 'moduleName': '__harDefaultModuleName__', 905 }); 906 SymbolGlyph.fontSize(RIGHT_SINGLE_ICON_SIZE); 907 SymbolGlyph.fontColor([this.subHeaderV2Theme.iconArrowColor]); 908 SymbolGlyph.draggable(false); 909 SymbolGlyph.width(ARROW_ICON_WIDTH); 910 SymbolGlyph.height(OPERATE_ITEM_LENGTH); 911 }, SymbolGlyph); 912 Row.pop(); 913 } 914 915 TextArrowStyle(parent = null) { 916 this.observeComponentCreation2((elmtId, isInitialRender) => { 917 If.create(); 918 if (this.operationItems?.[0] && this.operationItems[0] && this.operationItems[0].content && 919 this.operationItems[0].content.toString().length > 0) { 920 this.ifElseBranchUpdateFunction(0, () => { 921 this.observeComponentCreation2((elmtId, isInitialRender) => { 922 Stack.create(); 923 Stack.focusable(true); 924 Stack.align(this.ageing ? Alignment.Start : Alignment.End); 925 Stack.margin({ 926 start: LengthMetrics.vp(this.ageing ? getResourceValue('sys.float.padding_level0') : 927 getResourceValue('sys.float.padding_level4')), 928 bottom: LengthMetrics.vp(this.ageing ? getResourceValue('sys.float.padding_level0') : 929 getResourceValue('sys.float.padding_level2')), 930 }); 931 }, Stack); 932 this.observeComponentCreation2((elmtId, isInitialRender) => { 933 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 934 Button.padding(INDEX_ZERO); 935 Button.margin({ start: this.leftIconMargin() }); 936 Button.backgroundColor(this.textArrowBgColor); 937 Button.focusBox({ 938 margin: { value: INDEX_ZERO, unit: LengthUnit.VP }, 939 strokeColor: ColorMetrics.resourceColor(this.subHeaderV2Theme.borderFocusColor), 940 strokeWidth: LengthMetrics.vp(getResourceValue('sys.float.outline_extra_larger')), 941 }); 942 Button.borderRadius(getResourceValue('sys.float.corner_radius_level4')); 943 ViewStackProcessor.visualState('pressed'); 944 Button.backgroundColor({ 945 'id': -1, 946 'type': 10001, 947 params: ['sys.color.interactive_pressed'], 948 'bundleName': '__harDefaultBundleName__', 949 'moduleName': '__harDefaultModuleName__', 950 }); 951 ViewStackProcessor.visualState('disabled'); 952 Button.opacity(getResourceValue('sys.float.interactive_disable')); 953 ViewStackProcessor.visualState(); 954 Button.onHover((isHover) => { 955 if (isHover) { 956 this.textArrowBgColor = this.subHeaderV2Theme.textArrowHoverBgColor; 957 } else { 958 this.textArrowBgColor = { 959 'id': -1, 960 'type': 10001, 961 params: ['sys.color.ohos_id_color_sub_background_transparent'], 962 'bundleName': '__harDefaultBundleName__', 963 'moduleName': '__harDefaultModuleName__', 964 }; 965 } 966 }); 967 }, Button); 968 { 969 this.observeComponentCreation2((elmtId, isInitialRender) => { 970 if (isInitialRender) { 971 let componentCall = new TextArrowLayout(this, { 972 textArrowBuilder: () => { 973 this.observeComponentCreation2((elmtId, isInitialRender) => { 974 ForEach.create(); 975 const forEachItemGenFunction = _item => { 976 const index = _item; 977 this.observeComponentCreation2((elmtId, isInitialRender) => { 978 If.create(); 979 if (index === INDEX_ZERO) { 980 this.ifElseBranchUpdateFunction(0, () => { 981 this.TextStyle.bind(this)(); 982 }); 983 } else { 984 this.ifElseBranchUpdateFunction(1, () => { 985 this.ArrowStyle.bind(this)(); 986 }); 987 } 988 }, If); 989 If.pop(); 990 }; 991 this.forEachUpdateFunction(elmtId, [INDEX_ZERO, INDEX_ONE], 992 forEachItemGenFunction); 993 }, ForEach); 994 ForEach.pop(); 995 } 996 }, undefined, elmtId, () => { 997 }, { page: 'library/src/main/ets/components/MainPage.ets', line: 750, col: 11 }); 998 ViewPU.create(componentCall); 999 let paramsLambda = () => { 1000 return { 1001 textArrowBuilder: () => { 1002 this.observeComponentCreation2((elmtId, isInitialRender) => { 1003 ForEach.create(); 1004 const forEachItemGenFunction = _item => { 1005 const index = _item; 1006 this.observeComponentCreation2((elmtId, isInitialRender) => { 1007 If.create(); 1008 if (index === INDEX_ZERO) { 1009 this.ifElseBranchUpdateFunction(0, () => { 1010 this.TextStyle.bind(this)(); 1011 }); 1012 } else { 1013 this.ifElseBranchUpdateFunction(1, () => { 1014 this.ArrowStyle.bind(this)(); 1015 }); 1016 } 1017 }, If); 1018 If.pop(); 1019 }; 1020 this.forEachUpdateFunction(elmtId, [INDEX_ZERO, INDEX_ONE], 1021 forEachItemGenFunction); 1022 }, ForEach); 1023 ForEach.pop(); 1024 } 1025 }; 1026 }; 1027 componentCall.paramsGenerator_ = paramsLambda; 1028 } else { 1029 this.updateStateVarsOfChildByElmtId(elmtId, {}); 1030 } 1031 }, { name: 'TextArrowLayout' }); 1032 } 1033 Button.pop(); 1034 Stack.pop(); 1035 }); 1036 } else { 1037 this.ifElseBranchUpdateFunction(1, () => { 1038 this.observeComponentCreation2((elmtId, isInitialRender) => { 1039 Row.create(); 1040 Row.focusable(true); 1041 Row.constraintSize({ minWidth: this.getRightAreaMinWidth() }); 1042 Row.justifyContent(FlexAlign.End); 1043 }, Row); 1044 this.observeComponentCreation2((elmtId, isInitialRender) => { 1045 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 1046 Button.width(ARROW_ICON_WIDTH); 1047 Button.height(OPERATE_ITEM_LENGTH); 1048 Button.backgroundColor(this.textArrowBgColor); 1049 Button.focusBox({ 1050 margin: { value: INDEX_ZERO, unit: LengthUnit.VP }, 1051 strokeColor: ColorMetrics.resourceColor(this.subHeaderV2Theme.borderFocusColor), 1052 strokeWidth: LengthMetrics.vp(getResourceValue('sys.float.outline_extra_larger')), 1053 }); 1054 Button.borderRadius(getResourceValue('sys.float.corner_radius_level4')); 1055 ViewStackProcessor.visualState('pressed'); 1056 Button.backgroundColor({ 1057 'id': -1, 1058 'type': 10001, 1059 params: ['sys.color.interactive_pressed'], 1060 'bundleName': '__harDefaultBundleName__', 1061 'moduleName': '__harDefaultModuleName__', 1062 }); 1063 ViewStackProcessor.visualState('disabled'); 1064 Button.opacity(getResourceValue('sys.float.interactive_disable')); 1065 ViewStackProcessor.visualState(); 1066 Button.onHover((isHover) => { 1067 if (isHover) { 1068 this.textArrowBgColor = this.subHeaderV2Theme.textArrowHoverBgColor; 1069 } else { 1070 this.textArrowBgColor = { 1071 'id': -1, 1072 'type': 10001, 1073 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1074 'bundleName': '__harDefaultBundleName__', 1075 'moduleName': '__harDefaultModuleName__', 1076 }; 1077 } 1078 }); 1079 Button.focusable(true); 1080 Button.margin({ 1081 start: LengthMetrics.vp(this.ageing ? getResourceValue('sys.float.padding_level0') : 1082 getResourceValue('sys.float.padding_level4')), 1083 bottom: LengthMetrics.vp(this.ageing ? getResourceValue('sys.float.padding_level0') : 1084 getResourceValue('sys.float.padding_level2')), 1085 }); 1086 }, Button); 1087 this.observeComponentCreation2((elmtId, isInitialRender) => { 1088 SymbolGlyph.create({ 1089 'id': -1, 1090 'type': 40000, 1091 params: ['sys.symbol.chevron_right'], 1092 'bundleName': '__harDefaultBundleName__', 1093 'moduleName': '__harDefaultModuleName__', 1094 }); 1095 SymbolGlyph.fontSize(RIGHT_SINGLE_ICON_SIZE); 1096 SymbolGlyph.fontColor([this.subHeaderV2Theme.iconArrowColor]); 1097 SymbolGlyph.draggable(false); 1098 SymbolGlyph.focusable(true); 1099 SymbolGlyph.width(ARROW_ICON_WIDTH); 1100 SymbolGlyph.height(OPERATE_ITEM_LENGTH); 1101 }, SymbolGlyph); 1102 Button.pop(); 1103 Row.pop(); 1104 }); 1105 } 1106 }, If); 1107 If.pop(); 1108 } 1109 1110 IconGroupStyle(parent = null) { 1111 this.observeComponentCreation2((elmtId, isInitialRender) => { 1112 Row.create(); 1113 Row.justifyContent(FlexAlign.End); 1114 Row.focusable(true); 1115 }, Row); 1116 this.observeComponentCreation2((elmtId, isInitialRender) => { 1117 ForEach.create(); 1118 const forEachItemGenFunction = (_item, index) => { 1119 const item = _item; 1120 this.observeComponentCreation2((elmtId, isInitialRender) => { 1121 If.create(); 1122 if (index <= INDEX_TWO) { 1123 this.ifElseBranchUpdateFunction(0, () => { 1124 this.observeComponentCreation2((elmtId, isInitialRender) => { 1125 __Common__.create(); 1126 __Common__.margin({ 1127 start: LengthMetrics.vp(getResourceValue('sys.float.padding_level4')), 1128 bottom: LengthMetrics.vp(getResourceValue('sys.float.padding_level3')), 1129 }); 1130 }, __Common__); 1131 { 1132 this.observeComponentCreation2((elmtId, isInitialRender) => { 1133 if (isInitialRender) { 1134 let componentCall = new SingleIconStyle(this, { 1135 item: { 1136 iconOptions: this.operationItems?.[index].content, 1137 action: this.operationItems?.[index].action, 1138 defaultFocus: this.operationItems?.[index].defaultFocus, 1139 accessibilityLevel: this.operationItems?.[index].accessibilityLevel, 1140 accessibilityText: this.operationItems?.[index].accessibilityText, 1141 accessibilityDescription: this.operationItems?.[index].accessibilityDescription, 1142 }, 1143 isSingleIcon: this.operationItems?.length === SINGLE_ICON_NUMBER, 1144 }, undefined, elmtId, () => { 1145 }, { 1146 page: 'library/src/main/ets/components/MainPage.ets', 1147 line: 839, 1148 col: 11 1149 }); 1150 ViewV2.create(componentCall); 1151 let paramsLambda = () => { 1152 return { 1153 item: { 1154 iconOptions: this.operationItems?.[index].content, 1155 action: this.operationItems?.[index].action, 1156 defaultFocus: this.operationItems?.[index].defaultFocus, 1157 accessibilityLevel: this.operationItems?.[index].accessibilityLevel, 1158 accessibilityText: this.operationItems?.[index].accessibilityText, 1159 accessibilityDescription: this.operationItems?.[index].accessibilityDescription, 1160 }, 1161 isSingleIcon: this.operationItems?.length === SINGLE_ICON_NUMBER 1162 }; 1163 }; 1164 componentCall.paramsGenerator_ = paramsLambda; 1165 } else { 1166 this.updateStateVarsOfChildByElmtId(elmtId, { 1167 item: { 1168 iconOptions: this.operationItems?.[index].content, 1169 action: this.operationItems?.[index].action, 1170 defaultFocus: this.operationItems?.[index].defaultFocus, 1171 accessibilityLevel: this.operationItems?.[index].accessibilityLevel, 1172 accessibilityText: this.operationItems?.[index].accessibilityText, 1173 accessibilityDescription: this.operationItems?.[index].accessibilityDescription, 1174 }, 1175 isSingleIcon: this.operationItems?.length === SINGLE_ICON_NUMBER 1176 }); 1177 } 1178 }, { name: 'SingleIconStyle' }); 1179 } 1180 __Common__.pop(); 1181 }); 1182 } else { 1183 this.ifElseBranchUpdateFunction(1, () => { 1184 }); 1185 } 1186 }, If); 1187 If.pop(); 1188 }; 1189 this.forEachUpdateFunction(elmtId, this.operationItems, forEachItemGenFunction, (item, index) => { 1190 return `${index}`; 1191 }, true, true); 1192 }, ForEach); 1193 ForEach.pop(); 1194 Row.pop(); 1195 } 1196 1197 rightArea(parent = null) { 1198 this.observeComponentCreation2((elmtId, isInitialRender) => { 1199 If.create(); 1200 if (this.operationType === SubHeaderV2OperationType.BUTTON && 1201 (this.operationItems && this.operationItems.length > 0)) { 1202 this.ifElseBranchUpdateFunction(0, () => { 1203 this.ButtonStyle.bind(this)(); 1204 }); 1205 } else { 1206 this.ifElseBranchUpdateFunction(1, () => { 1207 }); 1208 } 1209 }, If); 1210 If.pop(); 1211 this.observeComponentCreation2((elmtId, isInitialRender) => { 1212 If.create(); 1213 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW && 1214 (this.operationItems && this.operationItems.length > 0)) { 1215 this.ifElseBranchUpdateFunction(0, () => { 1216 this.TextArrowStyle.bind(this)(); 1217 }); 1218 } else { 1219 this.ifElseBranchUpdateFunction(1, () => { 1220 }); 1221 } 1222 }, If); 1223 If.pop(); 1224 this.observeComponentCreation2((elmtId, isInitialRender) => { 1225 If.create(); 1226 if (this.operationType === SubHeaderV2OperationType.ICON_GROUP && 1227 (this.operationItems && this.operationItems.length > 0)) { 1228 this.ifElseBranchUpdateFunction(0, () => { 1229 this.IconGroupStyle.bind(this)(); 1230 }); 1231 } else { 1232 this.ifElseBranchUpdateFunction(1, () => { 1233 }); 1234 } 1235 }, If); 1236 If.pop(); 1237 this.observeComponentCreation2((elmtId, isInitialRender) => { 1238 If.create(); 1239 if (this.operationType === SubHeaderV2OperationType.LOADING) { 1240 this.ifElseBranchUpdateFunction(0, () => { 1241 this.LoadingProcessStyle.bind(this)(); 1242 }); 1243 } else { 1244 this.ifElseBranchUpdateFunction(1, () => { 1245 }); 1246 } 1247 }, If); 1248 If.pop(); 1249 this.observeComponentCreation2((elmtId, isInitialRender) => { 1250 If.create(); 1251 if (this.operationType === undefined && (this.operationItems && this.operationItems.length > 0)) { 1252 this.ifElseBranchUpdateFunction(0, () => { 1253 this.ButtonStyle.bind(this)(); 1254 }); 1255 } else { 1256 this.ifElseBranchUpdateFunction(1, () => { 1257 }); 1258 } 1259 }, If); 1260 If.pop(); 1261 } 1262 1263 rightAreaParent(parent = null) { 1264 this.observeComponentCreation2((elmtId, isInitialRender) => { 1265 If.create(); 1266 if (this.operationType === SubHeaderV2OperationType.BUTTON || 1267 this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1268 this.ifElseBranchUpdateFunction(0, () => { 1269 this.observeComponentCreation2((elmtId, isInitialRender) => { 1270 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 1271 Button.focusable(this.operationItems ? true : false); 1272 Button.margin(INDEX_ZERO); 1273 Button.padding(INDEX_ZERO); 1274 Button.align(Alignment.BottomEnd); 1275 Button.onKeyEvent((event) => { 1276 if (!event) { 1277 return; 1278 } 1279 if ((event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER) && 1280 event.type === KeyType.Down) { 1281 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1282 this.operationType === SubHeaderV2OperationType.BUTTON) && 1283 this.operationItems && this.operationItems.length > 0 && 1284 this.operationItems[0].action) { 1285 this.operationItems[0].action(); 1286 } 1287 event.stopPropagation(); 1288 } 1289 }); 1290 Button.onClick(() => { 1291 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1292 this.operationType === SubHeaderV2OperationType.BUTTON) && 1293 this.operationItems && this.operationItems.length > 0 && this.operationItems[0].action) { 1294 this.operationItems[0].action(); 1295 } 1296 }); 1297 Button.onTouch((event) => { 1298 if (event.type === TouchType.Down) { 1299 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1300 this.textArrowBgColor = { 1301 'id': -1, 1302 'type': 10001, 1303 params: ['sys.color.interactive_pressed'], 1304 'bundleName': '__harDefaultBundleName__', 1305 'moduleName': '__harDefaultModuleName__', 1306 }; 1307 } 1308 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1309 this.buttonBgColor = { 1310 'id': -1, 1311 'type': 10001, 1312 params: ['sys.color.interactive_pressed'], 1313 'bundleName': '__harDefaultBundleName__', 1314 'moduleName': '__harDefaultModuleName__', 1315 }; 1316 } 1317 } 1318 if (event.type === TouchType.Up || event.type === TouchType.Cancel) { 1319 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1320 this.textArrowBgColor = { 1321 'id': -1, 1322 'type': 10001, 1323 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1324 'bundleName': '__harDefaultBundleName__', 1325 'moduleName': '__harDefaultModuleName__', 1326 }; 1327 } 1328 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1329 this.buttonBgColor = { 1330 'id': -1, 1331 'type': 10001, 1332 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1333 'bundleName': '__harDefaultBundleName__', 1334 'moduleName': '__harDefaultModuleName__', 1335 }; 1336 } 1337 } 1338 }); 1339 Button.constraintSize({ 1340 maxWidth: this.getRightAreaMaxWidth(), 1341 minWidth: this.getRightAreaMinWidth(), 1342 minHeight: MIN_HOT_AREA_LENGTH, 1343 }); 1344 Button.flexShrink(0); 1345 Button.accessibilityLevel(this.operationType === SubHeaderV2OperationType.BUTTON || 1346 this.operationType === SubHeaderV2OperationType.TEXT_ARROW ? 1347 this.getRightAreaAccessibilityLevel() : 'no'); 1348 Button.hoverEffect(HoverEffect.None); 1349 Button.backgroundColor({ 1350 'id': -1, 1351 'type': 10001, 1352 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1353 'bundleName': '__harDefaultBundleName__', 1354 'moduleName': '__harDefaultModuleName__', 1355 }); 1356 Button.accessibilityGroup(true); 1357 Button.accessibilityText(this.getRightAreaAccessibilityText()); 1358 Button.accessibilityDescription(this.getAccessibilityDescription()); 1359 }, Button); 1360 this.rightArea.bind(this)(); 1361 Button.pop(); 1362 }); 1363 } else { 1364 this.ifElseBranchUpdateFunction(1, () => { 1365 this.observeComponentCreation2((elmtId, isInitialRender) => { 1366 Row.create(); 1367 Row.focusable(this.operationItems && this.operationType !== SubHeaderV2OperationType.LOADING ? 1368 true : false); 1369 Row.justifyContent(FlexAlign.End); 1370 Row.alignItems(VerticalAlign.Bottom); 1371 Row.onKeyEvent((event) => { 1372 if (!event) { 1373 return; 1374 } 1375 if ((event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER) && 1376 event.type === KeyType.Down) { 1377 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1378 this.operationType === SubHeaderV2OperationType.BUTTON) && 1379 this.operationItems && this.operationItems.length > 0 && 1380 this.operationItems[0].action) { 1381 this.operationItems[0].action(); 1382 } 1383 event.stopPropagation(); 1384 } 1385 }); 1386 Row.onClick(() => { 1387 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1388 this.operationType === SubHeaderV2OperationType.BUTTON) && 1389 this.operationItems && this.operationItems.length > 0 && this.operationItems[0].action) { 1390 this.operationItems[0].action(); 1391 } 1392 }); 1393 Row.onTouch((event) => { 1394 if (event.type === TouchType.Down) { 1395 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1396 this.textArrowBgColor = { 1397 'id': -1, 1398 'type': 10001, 1399 params: ['sys.color.interactive_pressed'], 1400 'bundleName': '__harDefaultBundleName__', 1401 'moduleName': '__harDefaultModuleName__', 1402 }; 1403 } 1404 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1405 this.buttonBgColor = { 1406 'id': -1, 1407 'type': 10001, 1408 params: ['sys.color.interactive_pressed'], 1409 'bundleName': '__harDefaultBundleName__', 1410 'moduleName': '__harDefaultModuleName__', 1411 }; 1412 } 1413 } 1414 if (event.type === TouchType.Up || event.type === TouchType.Cancel) { 1415 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1416 this.textArrowBgColor = { 1417 'id': -1, 1418 'type': 10001, 1419 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1420 'bundleName': '__harDefaultBundleName__', 1421 'moduleName': '__harDefaultModuleName__', 1422 }; 1423 } 1424 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1425 this.buttonBgColor = { 1426 'id': -1, 1427 'type': 10001, 1428 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1429 'bundleName': '__harDefaultBundleName__', 1430 'moduleName': '__harDefaultModuleName__', 1431 }; 1432 } 1433 } 1434 }); 1435 Row.constraintSize({ 1436 maxWidth: this.getRightAreaMaxWidth(), 1437 minWidth: this.getRightAreaMinWidth(), 1438 minHeight: MIN_HOT_AREA_LENGTH, 1439 }); 1440 Row.flexShrink(0); 1441 Row.accessibilityLevel(this.operationType === SubHeaderV2OperationType.BUTTON || 1442 this.operationType === SubHeaderV2OperationType.TEXT_ARROW ? 1443 this.getRightAreaAccessibilityLevel() : 'no'); 1444 }, Row); 1445 this.rightArea.bind(this)(); 1446 Row.pop(); 1447 }); 1448 } 1449 }, If); 1450 If.pop(); 1451 } 1452 1453 rightAreaParentAging(parent = null) { 1454 this.observeComponentCreation2((elmtId, isInitialRender) => { 1455 If.create(); 1456 if (this.operationType === SubHeaderV2OperationType.BUTTON || 1457 this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1458 this.ifElseBranchUpdateFunction(0, () => { 1459 this.observeComponentCreation2((elmtId, isInitialRender) => { 1460 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 1461 Button.focusable(this.operationItems ? true : false); 1462 Button.align(Alignment.Start); 1463 Button.onKeyEvent((event) => { 1464 if (!event) { 1465 return; 1466 } 1467 if ((event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER) && 1468 event.type === KeyType.Down) { 1469 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1470 this.operationType === SubHeaderV2OperationType.BUTTON) && 1471 this.operationItems && this.operationItems.length > 0 && 1472 this.operationItems[0].action) { 1473 this.operationItems[0].action(); 1474 } 1475 event.stopPropagation(); 1476 } 1477 }); 1478 Button.onClick(() => { 1479 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1480 this.operationType === SubHeaderV2OperationType.BUTTON) && 1481 this.operationItems && this.operationItems.length > 0 && this.operationItems[0].action) { 1482 this.operationItems[0].action(); 1483 } 1484 }); 1485 Button.onTouch((event) => { 1486 if (event.type === TouchType.Down) { 1487 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1488 this.textArrowBgColor = { 1489 'id': -1, 1490 'type': 10001, 1491 params: ['sys.color.interactive_pressed'], 1492 'bundleName': '__harDefaultBundleName__', 1493 'moduleName': '__harDefaultModuleName__', 1494 }; 1495 } 1496 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1497 this.buttonBgColor = { 1498 'id': -1, 1499 'type': 10001, 1500 params: ['sys.color.interactive_pressed'], 1501 'bundleName': '__harDefaultBundleName__', 1502 'moduleName': '__harDefaultModuleName__', 1503 }; 1504 } 1505 } 1506 if (event.type === TouchType.Up || event.type === TouchType.Cancel) { 1507 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1508 this.textArrowBgColor = { 1509 'id': -1, 1510 'type': 10001, 1511 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1512 'bundleName': '__harDefaultBundleName__', 1513 'moduleName': '__harDefaultModuleName__', 1514 }; 1515 } 1516 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1517 this.buttonBgColor = { 1518 'id': -1, 1519 'type': 10001, 1520 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1521 'bundleName': '__harDefaultBundleName__', 1522 'moduleName': '__harDefaultModuleName__', 1523 }; 1524 } 1525 } 1526 }); 1527 Button.margin({ 1528 bottom: getResourceValue('sys.float.padding_level4'), 1529 }); 1530 Button.padding({ 1531 // 'sys.float.margin_left' id,value: 16vp 1532 start: LengthMetrics.vp(getResourceValue('sys.float.margin_left') - PADDING_LEFT), 1533 // 'sys.float.margin_right' id,value: 16vp 1534 end: LengthMetrics.vp(getResourceValue('sys.float.margin_right')), 1535 }); 1536 Button.accessibilityLevel(this.operationType === SubHeaderV2OperationType.BUTTON || 1537 this.operationType === SubHeaderV2OperationType.TEXT_ARROW ? 1538 this.getRightAreaAccessibilityLevel() : 'no'); 1539 Button.backgroundColor({ 1540 'id': -1, 1541 'type': 10001, 1542 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1543 'bundleName': '__harDefaultBundleName__', 1544 'moduleName': '__harDefaultModuleName__', 1545 }); 1546 Button.hoverEffect(HoverEffect.None); 1547 Button.accessibilityGroup(true); 1548 Button.accessibilityText(this.getRightAreaAccessibilityText()); 1549 Button.accessibilityDescription(this.getAccessibilityDescription()); 1550 }, Button); 1551 this.rightArea.bind(this)(); 1552 Button.pop(); 1553 }); 1554 } else { 1555 this.ifElseBranchUpdateFunction(1, () => { 1556 this.observeComponentCreation2((elmtId, isInitialRender) => { 1557 Row.create(); 1558 Row.focusable(this.operationItems && this.operationType !== SubHeaderV2OperationType.LOADING ? 1559 true : false); 1560 Row.justifyContent(FlexAlign.Start); 1561 Row.onKeyEvent((event) => { 1562 if (!event) { 1563 return; 1564 } 1565 if ((event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER) && 1566 event.type === KeyType.Down) { 1567 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1568 this.operationType === SubHeaderV2OperationType.BUTTON) && 1569 this.operationItems && this.operationItems.length > 0 && 1570 this.operationItems[0].action) { 1571 this.operationItems[0].action(); 1572 } 1573 event.stopPropagation(); 1574 } 1575 }); 1576 Row.onClick(() => { 1577 if ((this.operationType === SubHeaderV2OperationType.TEXT_ARROW || 1578 this.operationType === SubHeaderV2OperationType.BUTTON) && 1579 this.operationItems && this.operationItems.length > 0 && this.operationItems[0].action) { 1580 this.operationItems[0].action(); 1581 } 1582 }); 1583 Row.onTouch((event) => { 1584 if (event.type === TouchType.Down) { 1585 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1586 this.textArrowBgColor = { 1587 'id': -1, 1588 'type': 10001, 1589 params: ['sys.color.interactive_pressed'], 1590 'bundleName': '__harDefaultBundleName__', 1591 'moduleName': '__harDefaultModuleName__', 1592 }; 1593 } 1594 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1595 this.buttonBgColor = { 1596 'id': -1, 1597 'type': 10001, 1598 params: ['sys.color.interactive_pressed'], 1599 'bundleName': '__harDefaultBundleName__', 1600 'moduleName': '__harDefaultModuleName__', 1601 }; 1602 } 1603 } 1604 if (event.type === TouchType.Up || event.type === TouchType.Cancel) { 1605 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW) { 1606 this.textArrowBgColor = { 1607 'id': -1, 1608 'type': 10001, 1609 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1610 'bundleName': '__harDefaultBundleName__', 1611 'moduleName': '__harDefaultModuleName__', 1612 }; 1613 } 1614 if (this.operationType === SubHeaderV2OperationType.BUTTON) { 1615 this.buttonBgColor = { 1616 'id': -1, 1617 'type': 10001, 1618 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1619 'bundleName': '__harDefaultBundleName__', 1620 'moduleName': '__harDefaultModuleName__', 1621 }; 1622 } 1623 } 1624 }); 1625 Row.margin({ 1626 bottom: getResourceValue('sys.float.padding_level4'), 1627 }); 1628 Row.padding({ 1629 // 'sys.float.margin_left' id,value: 16vp 1630 start: LengthMetrics.vp(getResourceValue('sys.float.margin_left') - PADDING_LEFT), 1631 // 'sys.float.margin_right' id,value: 16vp 1632 end: LengthMetrics.vp(getResourceValue('sys.float.margin_right')), 1633 }); 1634 Row.accessibilityLevel(this.operationType === SubHeaderV2OperationType.BUTTON || 1635 this.operationType === SubHeaderV2OperationType.TEXT_ARROW ? 1636 this.getRightAreaAccessibilityLevel() : 'no'); 1637 }, Row); 1638 this.rightArea.bind(this)(); 1639 Row.pop(); 1640 }); 1641 } 1642 }, If); 1643 If.pop(); 1644 } 1645 1646 getRightAreaAccessibilityText() { 1647 if (!this.operationItems || this.operationItems?.length <= 0) { 1648 return ''; 1649 } 1650 if (this.operationItems[0]?.accessibilityText && this.operationItems[0]?.accessibilityText !== '') { 1651 return this.operationItems[0].accessibilityText; 1652 } else { 1653 if (this.operationType === SubHeaderV2OperationType.TEXT_ARROW && 1654 this.operationItems[0]?.content.toString().length <= 0) { 1655 // 播报:更多、more等, 使用的字段是:sys.string.ohos_toolbar_more 1656 return Util.getStringByResource(125833704, ''); 1657 } 1658 } 1659 return ''; 1660 } 1661 1662 getMinHeight() { 1663 if (this.title?.secondaryTitle && this.icon) { 1664 return getResourceValue('sys.float.subheader_single_subtitle_height'); 1665 } else if (this.title?.secondaryTitle && this.title?.primaryTitle) { 1666 return getResourceValue('sys.float.subheader_double_height'); 1667 } else if (this.title?.primaryTitle || this.select) { 1668 return getResourceValue('sys.float.subheader_single_title_height'); 1669 } 1670 return getResourceValue('sys.float.subheader_single_subtitle_height'); 1671 } 1672 1673 getAreaPadding() { 1674 let padding = {}; 1675 if (!this.titleBuilder && ((this.title?.secondaryTitle && this.icon) || 1676 (!this.title?.primaryTitle && this.title?.secondaryTitle))) { 1677 padding = { 1678 start: LengthMetrics.vp(getResourceValue('sys.float.subheader_single_subtitle_padding')), 1679 end: LengthMetrics.vp(getResourceValue('sys.float.subheader_single_subtitle_padding')), 1680 }; 1681 } else if (this.select) { 1682 padding = { 1683 top: LengthMetrics.vp(getResourceValue('sys.float.subheader_select_padding')), 1684 bottom: LengthMetrics.vp(getResourceValue('sys.float.subheader_select_padding')), 1685 }; 1686 } 1687 return padding; 1688 } 1689 1690 initialRender() { 1691 this.observeComponentCreation2((elmtId, isInitialRender) => { 1692 If.create(); 1693 if (this.isSuitableAging()) { 1694 this.ifElseBranchUpdateFunction(0, () => { 1695 this.observeComponentCreation2((elmtId, isInitialRender) => { 1696 Column.create(); 1697 Column.constraintSize({ minHeight: this.getMinHeight() }); 1698 Column.padding(this.getAreaPadding()); 1699 Column.alignItems(HorizontalAlign.Start); 1700 }, Column); 1701 this.observeComponentCreation2((elmtId, isInitialRender) => { 1702 Row.create(); 1703 Row.margin({ 1704 top: LengthMetrics.vp(getResourceValue('sys.float.padding_level8')), 1705 bottom: LengthMetrics.vp(getResourceValue('sys.float.padding_level1')), 1706 }); 1707 Row.padding({ 1708 start: LengthMetrics.vp(getResourceValue('sys.float.margin_left')), 1709 end: LengthMetrics.vp(getResourceValue('sys.float.margin_right')), 1710 }); 1711 Row.width('100%'); 1712 Row.accessibilityGroup(this.isLeftAreaAccessibilityGroup()); 1713 Row.accessibilityDescription(this.select ? '' : Util.getStringByResource(125834353, '')); 1714 }, Row); 1715 this.leftArea.bind(this)(); 1716 Row.pop(); 1717 this.observeComponentCreation2((elmtId, isInitialRender) => { 1718 If.create(); 1719 if (this.isRightAreaExists()) { 1720 this.ifElseBranchUpdateFunction(0, () => { 1721 this.rightAreaParentAging.bind(this)(); 1722 }); 1723 } else { 1724 this.ifElseBranchUpdateFunction(1, () => { 1725 }); 1726 } 1727 }, If); 1728 If.pop(); 1729 Column.pop(); 1730 }); 1731 } else { 1732 this.ifElseBranchUpdateFunction(1, () => { 1733 this.observeComponentCreation2((elmtId, isInitialRender) => { 1734 Flex.create({ direction: FlexDirection.Row, alignItems: ItemAlign.End }); 1735 Flex.constraintSize({ minHeight: this.getMinHeight() }); 1736 Flex.margin(this.subHeaderMargin); 1737 Flex.padding(this.getAreaPadding()); 1738 }, Flex); 1739 this.observeComponentCreation2((elmtId, isInitialRender) => { 1740 Row.create(); 1741 Row.margin({ 1742 top: this.fontSize >= MIN_FONT_SIZE ? getResourceValue('sys.float.padding_level8') : '', 1743 bottom: this.fontSize >= MIN_FONT_SIZE ? getResourceValue('sys.float.padding_level4') : '', 1744 }); 1745 Row.width('100%'); 1746 Row.flexShrink(1); 1747 Row.accessibilityGroup(this.isLeftAreaAccessibilityGroup()); 1748 Row.accessibilityDescription(this.select ? '' : Util.getStringByResource(125834353, '')); 1749 }, Row); 1750 this.leftArea.bind(this)(); 1751 Row.pop(); 1752 this.observeComponentCreation2((elmtId, isInitialRender) => { 1753 If.create(); 1754 if (this.isRightAreaExists()) { 1755 this.ifElseBranchUpdateFunction(0, () => { 1756 this.rightAreaParent.bind(this)(); 1757 }); 1758 } else { 1759 this.ifElseBranchUpdateFunction(1, () => { 1760 }); 1761 } 1762 }, If); 1763 If.pop(); 1764 Flex.pop(); 1765 }); 1766 } 1767 }, If); 1768 If.pop(); 1769 } 1770 1771 getRightAreaAccessibilityLevel() { 1772 if (this.operationItems[0].accessibilityLevel && this.operationItems[0].accessibilityLevel !== '') { 1773 return this.operationItems[0].accessibilityLevel; 1774 } 1775 return 'yes'; 1776 } 1777 1778 LoadingProcessStyle(parent = null) { 1779 this.observeComponentCreation2((elmtId, isInitialRender) => { 1780 Row.create(); 1781 Row.justifyContent(FlexAlign.End); 1782 Row.padding({ 1783 top: getResourceValue('sys.float.padding_level2'), 1784 bottom: getResourceValue('sys.float.padding_level2'), 1785 }); 1786 Row.margin({ 1787 start: LengthMetrics.vp(getResourceValue('sys.float.padding_level4')), 1788 }); 1789 }, Row); 1790 this.observeComponentCreation2((elmtId, isInitialRender) => { 1791 LoadingProgress.create(); 1792 LoadingProgress.width(OPERATE_ITEM_LENGTH); 1793 LoadingProgress.height(OPERATE_ITEM_LENGTH); 1794 LoadingProgress.color({ 1795 'id': -1, 1796 'type': 10001, 1797 params: ['sys.color.icon_secondary'], 1798 'bundleName': '__harDefaultBundleName__', 1799 'moduleName': '__harDefaultModuleName__', 1800 }); 1801 }, LoadingProgress); 1802 Row.pop(); 1803 } 1804 1805 dummyFunction(parent = null) { 1806 this.observeComponentCreation2((elmtId, isInitialRender) => { 1807 Row.create(); 1808 }, Row); 1809 Row.pop(); 1810 } 1811 1812 updateStateVars(params) { 1813 if (params === undefined) { 1814 return; 1815 } 1816 if ('icon' in params) { 1817 this.updateParam('icon', params.icon); 1818 } 1819 if ('title' in params) { 1820 this.updateParam('title', params.title); 1821 } 1822 if ('select' in params) { 1823 this.updateParam('select', params.select); 1824 } 1825 if ('operationType' in params) { 1826 this.updateParam('operationType', params.operationType); 1827 } 1828 if ('operationItems' in params) { 1829 this.updateParam('operationItems', params.operationItems); 1830 } 1831 } 1832 1833 rerender() { 1834 this.updateDirtyElements(); 1835 } 1836} 1837__decorate([ 1838 Param 1839], SubHeaderV2.prototype, 'icon', void 0); 1840__decorate([ 1841 Param 1842], SubHeaderV2.prototype, 'title', void 0); 1843__decorate([ 1844 Param 1845], SubHeaderV2.prototype, 'select', void 0); 1846__decorate([ 1847 Param 1848], SubHeaderV2.prototype, 'operationType', void 0); 1849__decorate([ 1850 Param 1851], SubHeaderV2.prototype, 'operationItems', void 0); 1852__decorate([ 1853 Local 1854], SubHeaderV2.prototype, 'fontSize', void 0); 1855__decorate([ 1856 Local 1857], SubHeaderV2.prototype, 'ageing', void 0); 1858__decorate([ 1859 Local 1860], SubHeaderV2.prototype, 'textArrowBgColor', void 0); 1861__decorate([ 1862 Local 1863], SubHeaderV2.prototype, 'buttonBgColor', void 0); 1864__decorate([ 1865 Local 1866], SubHeaderV2.prototype, 'selectedIndex', void 0); 1867__decorate([ 1868 Local 1869], SubHeaderV2.prototype, 'selectedContent', void 0); 1870__decorate([ 1871 Local 1872], SubHeaderV2.prototype, 'symbolWidth', void 0); 1873__decorate([ 1874 Local 1875], SubHeaderV2.prototype, 'subHeaderModifier', void 0); 1876__decorate([ 1877 Provider('subHeaderV2Theme') 1878], SubHeaderV2.prototype, 'subHeaderV2Theme', void 0); 1879__decorate([ 1880 Monitor('select') 1881], SubHeaderV2.prototype, 'infoChange', null); 1882 1883class SymbolGlyphChild extends ViewV2 { 1884 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { 1885 super(parent, elmtId, extraInfo); 1886 this.initParam('icon', (params && 'icon' in params) ? params.icon : undefined); 1887 this.initParam('fontColor', (params && 'fontColor' in params) ? params.fontColor : undefined); 1888 this.changeSymbolWidth = 'changeSymbolWidth' in params ? params.changeSymbolWidth : () => { 1889 }; 1890 this.result = { 1891 width: 0, 1892 height: 0 1893 }; 1894 this.finalizeConstruction(); 1895 } 1896 1897 onMeasureSize(selfLayoutInfo, children, constraint) { 1898 children.forEach((child) => { 1899 this.result = child.measure(constraint); 1900 }); 1901 console.log(`zzzz Child onMeasureSize ${JSON.stringify(this.result)}`); 1902 this.changeSymbolWidth(this.result); 1903 return this.result; 1904 } 1905 1906 initialRender() { 1907 this.observeComponentCreation2((elmtId, isInitialRender) => { 1908 Column.create(); 1909 }, Column); 1910 this.observeComponentCreation2((elmtId, isInitialRender) => { 1911 SymbolGlyph.create(this.icon); 1912 SymbolGlyph.fontSize(getResourceValue('sys.float.subheader_left_icon_size')); 1913 SymbolGlyph.fontColor(this.fontColor); 1914 SymbolGlyph.attributeModifier.bind(this)(this.icon); 1915 SymbolGlyph.margin({ end: LengthMetrics.vp(getResourceValue('sys.float.subheader_left_icon_end_margin')) }); 1916 SymbolGlyph.flexShrink(0); 1917 }, SymbolGlyph); 1918 Column.pop(); 1919 } 1920 1921 updateStateVars(params) { 1922 if (params === undefined) { 1923 return; 1924 } 1925 if ('icon' in params) { 1926 this.updateParam('icon', params.icon); 1927 } 1928 if ('fontColor' in params) { 1929 this.updateParam('fontColor', params.fontColor); 1930 } 1931 } 1932 1933 rerender() { 1934 this.updateDirtyElements(); 1935 } 1936} 1937 1938__decorate([ 1939 Param 1940], SymbolGlyphChild.prototype, 'icon', void 0); 1941__decorate([ 1942 Param 1943], SymbolGlyphChild.prototype, 'fontColor', void 0); 1944__decorate([ 1945 Event 1946], SymbolGlyphChild.prototype, 'changeSymbolWidth', void 0); 1947 1948class SingleIconStyle extends ViewV2 { 1949 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { 1950 super(parent, elmtId, extraInfo); 1951 this.bgColor = { 1952 'id': -1, 1953 'type': 10001, 1954 params: ['sys.color.ohos_id_color_sub_background_transparent'], 1955 'bundleName': '__harDefaultBundleName__', 1956 'moduleName': '__harDefaultModuleName__', 1957 }; 1958 this.isFocus = false; 1959 this.initParam('item', (params && 'item' in params) ? params.item : null); 1960 this.subHeaderTheme = new SubHeaderTheme(); 1961 this.initParam('isSingleIcon', (params && 'isSingleIcon' in params) ? params.isSingleIcon : true); 1962 this.finalizeConstruction(); 1963 } 1964 1965 getRightIconAccessibilityText() { 1966 if (this.item?.accessibilityText) { 1967 return this.item.accessibilityText; 1968 } 1969 return ''; 1970 } 1971 1972 getRightIconAccessibilityLevel() { 1973 if (this.item?.accessibilityLevel && this.item?.accessibilityLevel !== '') { 1974 return this.item.accessibilityLevel; 1975 } 1976 return 'auto'; 1977 } 1978 1979 getRightIconAccessibilityDescription() { 1980 if (this.item?.accessibilityDescription && this.item?.accessibilityDescription !== '') { 1981 return this.item?.accessibilityDescription; 1982 } 1983 return ''; 1984 } 1985 1986 initialRender() { 1987 this.observeComponentCreation2((elmtId, isInitialRender) => { 1988 If.create(); 1989 if (this.item && this.item.iconOptions) { 1990 this.ifElseBranchUpdateFunction(0, () => { 1991 this.observeComponentCreation2((elmtId, isInitialRender) => { 1992 Button.createWithChild({ type: ButtonType.Normal, stateEffect: false }); 1993 Button.focusable(true); 1994 Button.defaultFocus(this.item.defaultFocus); 1995 Button.width(SINGLE_ICON_ZONE_SIZE); 1996 Button.height(SINGLE_ICON_ZONE_SIZE); 1997 Button.align(Alignment.Center); 1998 Button.backgroundColor(this.bgColor); 1999 Button.borderRadius(getResourceValue('sys.float.corner_radius_level4')); 2000 Button.accessibilityLevel(this.getRightIconAccessibilityLevel()); 2001 Button.accessibilityText(this.getRightIconAccessibilityText()); 2002 Button.accessibilityDescription(this.getRightIconAccessibilityDescription()); 2003 Button.focusBox({ 2004 margin: { value: INDEX_ZERO, unit: LengthUnit.VP }, 2005 strokeColor: ColorMetrics.resourceColor(this.subHeaderTheme.borderFocusColor), 2006 strokeWidth: LengthMetrics.vp(getResourceValue('sys.float.outline_extra_larger')), 2007 }); 2008 ViewStackProcessor.visualState('pressed'); 2009 Button.backgroundColor({ 2010 'id': -1, 2011 'type': 10001, 2012 params: ['sys.color.interactive_pressed'], 2013 'bundleName': '__harDefaultBundleName__', 2014 'moduleName': '__harDefaultModuleName__', 2015 }); 2016 ViewStackProcessor.visualState('disabled'); 2017 Button.opacity(getResourceValue('sys.float.interactive_disable')); 2018 ViewStackProcessor.visualState(); 2019 Button.onTouch((event) => { 2020 if (event.type === TouchType.Down || TouchType.Cancel) { 2021 this.bgColor = { 2022 'id': -1, 2023 'type': 10001, 2024 params: ['sys.color.interactive_pressed'], 2025 'bundleName': '__harDefaultBundleName__', 2026 'moduleName': '__harDefaultModuleName__', 2027 }; 2028 } 2029 if (event.type === TouchType.Up) { 2030 this.bgColor = { 2031 'id': -1, 2032 'type': 10001, 2033 params: ['sys.color.ohos_id_color_sub_background_transparent'], 2034 'bundleName': '__harDefaultBundleName__', 2035 'moduleName': '__harDefaultModuleName__', 2036 }; 2037 } 2038 }); 2039 Button.onHover((isHover) => { 2040 if (isHover) { 2041 this.bgColor = { 2042 'id': -1, 2043 'type': 10001, 2044 params: ['sys.color.interactive_hover'], 2045 'bundleName': '__harDefaultBundleName__', 2046 'moduleName': '__harDefaultModuleName__', 2047 }; 2048 } else { 2049 this.bgColor = { 2050 'id': -1, 2051 'type': 10001, 2052 params: ['sys.color.ohos_id_color_sub_background_transparent'], 2053 'bundleName': '__harDefaultBundleName__', 2054 'moduleName': '__harDefaultModuleName__', 2055 }; 2056 } 2057 }); 2058 Button.responseRegion(this.iconResponseRegion()); 2059 Button.onClick((event) => { 2060 if (this.item?.action) { 2061 this.item?.action(); 2062 } 2063 }); 2064 }, Button); 2065 this.IconZone.bind(this)(); 2066 Button.pop(); 2067 }); 2068 } else { 2069 this.ifElseBranchUpdateFunction(1, () => { 2070 }); 2071 } 2072 }, If); 2073 If.pop(); 2074 } 2075 2076 iconResponseRegion() { 2077 if (this.isSingleIcon) { 2078 return { 2079 x: SINGLE_ICON_REGION_X, 2080 y: ICON_REGION_Y, 2081 width: MIN_HOT_AREA_LENGTH, 2082 height: MIN_HOT_AREA_LENGTH, 2083 }; 2084 } 2085 return { 2086 x: ICON_REGION_X, 2087 y: ICON_REGION_Y, 2088 width: MULTI_ICON_REGION_WIDTH, 2089 height: MIN_HOT_AREA_LENGTH, 2090 }; 2091 } 2092 2093 IconZone(parent = null) { 2094 this.observeComponentCreation2((elmtId, isInitialRender) => { 2095 If.create(); 2096 if (this.item && this.item.iconOptions) { 2097 this.ifElseBranchUpdateFunction(0, () => { 2098 this.observeComponentCreation2((elmtId, isInitialRender) => { 2099 If.create(); 2100 if (Util.isSymbolResource(this.item.iconOptions)) { 2101 this.ifElseBranchUpdateFunction(0, () => { 2102 this.observeComponentCreation2((elmtId, isInitialRender) => { 2103 SymbolGlyph.create(this.item.iconOptions); 2104 SymbolGlyph.fontSize(RIGHT_SINGLE_ICON_SIZE); 2105 SymbolGlyph.fontColor([this.subHeaderTheme.rightIconColor]); 2106 SymbolGlyph.attributeModifier.bind(this)(this.item.iconOptions); 2107 SymbolGlyph.focusable(true); 2108 }, SymbolGlyph); 2109 }); 2110 } else { 2111 this.ifElseBranchUpdateFunction(1, () => { 2112 this.observeComponentCreation2((elmtId, isInitialRender) => { 2113 Image.create(this.item?.iconOptions); 2114 Image.fillColor(this.subHeaderTheme.rightIconColor); 2115 Image.width(RIGHT_SINGLE_ICON_SIZE); 2116 Image.height(RIGHT_SINGLE_ICON_SIZE); 2117 Image.focusable(true); 2118 Image.draggable(false); 2119 }, Image); 2120 }); 2121 } 2122 }, If); 2123 If.pop(); 2124 }); 2125 } else { 2126 this.ifElseBranchUpdateFunction(1, () => { 2127 }); 2128 } 2129 }, If); 2130 If.pop(); 2131 } 2132 2133 updateStateVars(params) { 2134 if (params === undefined) { 2135 return; 2136 } 2137 if ('item' in params) { 2138 this.updateParam('item', params.item); 2139 } 2140 if ('isSingleIcon' in params) { 2141 this.updateParam('isSingleIcon', params.isSingleIcon); 2142 } 2143 } 2144 2145 rerender() { 2146 this.updateDirtyElements(); 2147 } 2148} 2149 2150__decorate([ 2151 Local 2152], SingleIconStyle.prototype, 'bgColor', void 0); 2153__decorate([ 2154 Local 2155], SingleIconStyle.prototype, 'isFocus', void 0); 2156__decorate([ 2157 Param 2158], SingleIconStyle.prototype, 'item', void 0); 2159__decorate([ 2160 Consumer('subHeaderV2Theme') 2161], SingleIconStyle.prototype, 'subHeaderTheme', void 0); 2162__decorate([ 2163 Param 2164], SingleIconStyle.prototype, 'isSingleIcon', void 0); 2165 2166class Util { 2167 /** 2168 * 是否symbol资源 2169 * @param resourceStr 资源 2170 * @returns true:symbol资源;false:非symbol资源 2171 */ 2172 static isSymbolResource(resourceStr) { 2173 if (!Util.isResourceType(resourceStr)) { 2174 return false; 2175 } 2176 if (resourceStr instanceof SymbolGlyphModifier) { 2177 return resourceStr instanceof SymbolGlyphModifier; 2178 } 2179 let resource = resourceStr; 2180 return resource.type === RESOURCE_TYPE_SYMBOL; 2181 } 2182 2183 /** 2184 * 是否Resource类型 2185 * @param resource 资源 2186 * @returns true:Resource类型;false:非Resource类型 2187 */ 2188 static isResourceType(resource) { 2189 if (!resource) { 2190 return false; 2191 } 2192 if (typeof resource === 'string' || typeof resource === 'undefined') { 2193 return false; 2194 } 2195 return true; 2196 } 2197 2198 /** 2199 * get resource size 2200 * 2201 * @param resourceName resource id 2202 * @returns resource size 2203 */ 2204 static getNumberByResource(resourceId, defaultNumber) { 2205 try { 2206 let resourceNumber = resourceManager.getSystemResourceManager().getNumber(resourceId); 2207 if (resourceNumber === 0) { 2208 return defaultNumber; 2209 } else { 2210 return resourceNumber; 2211 } 2212 } catch (error) { 2213 let code = error.code; 2214 let message = error.message; 2215 hilog.error(0x3900, 'Ace', `SubHeader getNumberByResource error, code: ${code}, message: ${message}`); 2216 return defaultNumber; 2217 } 2218 } 2219 2220 /** 2221 * get resource string 2222 * 2223 * @param resourceId resource id 2224 * @param defaultString default value 2225 * @returns resource string 2226 */ 2227 static getStringByResource(resourceId, defaultString) { 2228 try { 2229 let resourceString = getContext().resourceManager.getStringSync(resourceId); 2230 if (resourceString === '') { 2231 return defaultString; 2232 } else { 2233 return resourceString; 2234 } 2235 } catch (error) { 2236 let code = error.code; 2237 let message = error.message; 2238 hilog.error(0x3900, 'Ace', `SubHeader getStringByResource error, code: ${code}, message: ${message}`); 2239 return ''; 2240 } 2241 } 2242 2243 static numberToSize(fontSize) { 2244 if (typeof fontSize === 'string') { 2245 const fontSizeNumber = parseInt(fontSize); 2246 return fontSizeNumber; 2247 } else if (typeof fontSize === 'number') { 2248 return fontSize; 2249 } else { 2250 return getContext().resourceManager.getNumber(fontSize); 2251 } 2252 } 2253 2254 static symbolFontSize(fontSize) { 2255 return Util.numberToSize(fontSize) + 'vp'; 2256 } 2257} 2258 2259const RESOURCE_CACHE_MAP = new HashMap(); 2260// padding_level0: 125830919, 0 2261RESOURCE_CACHE_MAP.set('sys.float.padding_level0', { resourceId: 125830919, defaultValue: 0 }); 2262// padding_level1: 125830920, 2 2263RESOURCE_CACHE_MAP.set('sys.float.padding_level1', { resourceId: 125830920, defaultValue: 2 }); 2264// padding_level2: 125830921, 4 2265RESOURCE_CACHE_MAP.set('sys.float.padding_level2', { resourceId: 125830921, defaultValue: 4 }); 2266// padding_level3: 125830922, 6 2267RESOURCE_CACHE_MAP.set('sys.float.padding_level3', { resourceId: 125830922, defaultValue: 6 }); 2268// padding_level4: 125830923, 8 2269RESOURCE_CACHE_MAP.set('sys.float.padding_level4', { resourceId: 125830923, defaultValue: 8 }); 2270// padding_level6: 125830925, 12 2271RESOURCE_CACHE_MAP.set('sys.float.padding_level6', { resourceId: 125830925, defaultValue: 12 }); 2272// padding_level8: 125830927, 16 2273RESOURCE_CACHE_MAP.set('sys.float.padding_level8', { resourceId: 125830927, defaultValue: 16 }); 2274// margin_left: 125830936, 16 2275RESOURCE_CACHE_MAP.set('sys.float.margin_left', { resourceId: 125830936, defaultValue: 16 }); 2276// margin_right: 125830937, 16 2277RESOURCE_CACHE_MAP.set('sys.float.margin_right', { resourceId: 125830937, defaultValue: 16 }); 2278// outline_extra_larger: 125830951, 2 2279RESOURCE_CACHE_MAP.set('sys.float.outline_extra_larger', { resourceId: 125830951, defaultValue: 2 }); 2280// corner_radius_level4: 125830909, 8 2281RESOURCE_CACHE_MAP.set('sys.float.corner_radius_level4', { resourceId: 125830909, defaultValue: 8 }); 2282// Subtitle_S: 125830969, 14 2283RESOURCE_CACHE_MAP.set('sys.float.Subtitle_S', { resourceId: 125830969, defaultValue: 14 }); 2284// subheader_title_font_size: 125834265, 18 2285RESOURCE_CACHE_MAP.set('sys.float.subheader_title_font_size', { resourceId: 125834265, defaultValue: 18 }); 2286// Body_L: 125830970, 16 2287RESOURCE_CACHE_MAP.set('sys.float.Body_L', { resourceId: 125830970, defaultValue: 16 }); 2288// interactive_disable: 125831067, 0.4 2289RESOURCE_CACHE_MAP.set('sys.float.interactive_disable', { resourceId: 125831067, defaultValue: 0.4 }); 2290// subheader_single_title_height: 125834252 56 2291RESOURCE_CACHE_MAP.set('sys.float.subheader_single_title_height', { resourceId: 125834252, defaultValue: 56 }); 2292// subheader_single_subtitle_height: 125834253 56 2293RESOURCE_CACHE_MAP.set('sys.float.subheader_single_subtitle_height', { resourceId: 125834253, defaultValue: 56 }); 2294// subheader_double_height: 125834254 72 2295RESOURCE_CACHE_MAP.set('sys.float.subheader_double_height', { resourceId: 125834254, defaultValue: 72 }); 2296// subheader_title_font_weight: 125834255 700 2297RESOURCE_CACHE_MAP.set('sys.float.subheader_title_font_weight', { resourceId: 125834255, defaultValue: 700 }); 2298// subheader_left_icon_size: 125835678, 16 2299RESOURCE_CACHE_MAP.set('sys.float.subheader_left_icon_size', { resourceId: 125835678, defaultValue: 16 }); 2300// subheader_content_margin_start: 125835679, margin_left, 16 2301RESOURCE_CACHE_MAP.set('sys.float.subheader_content_margin_start', { resourceId: 125835679, defaultValue: 16 }); 2302// subheader_content_margin_end: 125835680, margin_right, 16 2303RESOURCE_CACHE_MAP.set('sys.float.subheader_content_margin_end', { resourceId: 125835680, defaultValue: 16 }); 2304// subheader_content_padding: 125835681, padding_level4, 8 2305RESOURCE_CACHE_MAP.set('sys.float.subheader_content_padding', { resourceId: 125835681, defaultValue: 8 }); 2306// subheader_single_subtitle_padding: 125835682, padding_level6, 12 2307RESOURCE_CACHE_MAP.set('sys.float.subheader_single_subtitle_padding', { resourceId: 125835682, defaultValue: 12 }); 2308// subheader_select_padding: 125835683, padding_level2, 4 2309RESOURCE_CACHE_MAP.set('sys.float.subheader_select_padding', { resourceId: 125835683, defaultValue: 4 }); 2310// subheader_left_icon_end_margin: 125835684, padding_level4, 8 2311RESOURCE_CACHE_MAP.set('sys.float.subheader_left_icon_end_margin', { resourceId: 125835684, defaultValue: 8 }); 2312// subheader_subtitle_font_weight: 125835685, regular , 400 2313RESOURCE_CACHE_MAP.set('sys.float.subheader_subtitle_font_weight', { resourceId: 125835685, defaultValue: 400 }); 2314// subheader_titles_space: 125835686, padding_level1, 2 2315RESOURCE_CACHE_MAP.set('sys.float.subheader_titles_space', { resourceId: 125835686, defaultValue: 2 }); 2316 2317function getResourceValue(resourceName) { 2318 if (RESOURCE_CACHE_MAP.hasKey(resourceName)) { 2319 let resourceValue = RESOURCE_CACHE_MAP.get(resourceName).resourceValue; 2320 if (typeof resourceValue === 'number') { 2321 return resourceValue; 2322 } else { 2323 resourceValue = Util.getNumberByResource(RESOURCE_CACHE_MAP.get(resourceName).resourceId, 2324 RESOURCE_CACHE_MAP.get(resourceName).defaultValue); 2325 RESOURCE_CACHE_MAP.get(resourceName).resourceValue = resourceValue; 2326 return resourceValue; 2327 } 2328 } 2329 return 0; 2330} 2331 2332class TextArrowLayout extends ViewPU { 2333 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 2334 super(parent, __localStorage, elmtId, extraInfo); 2335 if (typeof paramsLambda === 'function') { 2336 this.paramsGenerator_ = paramsLambda; 2337 } 2338 this.textArrowBuilder = this.doNothingBuilder; 2339 this.setInitiallyProvidedValue(params); 2340 this.finalizeConstruction(); 2341 } 2342 2343 setInitiallyProvidedValue(params) { 2344 if (params.textArrowBuilder !== undefined) { 2345 this.textArrowBuilder = params.textArrowBuilder; 2346 } 2347 } 2348 2349 updateStateVars(params) { 2350 } 2351 2352 purgeVariableDependenciesOnElmtId(rmElmtId) { 2353 } 2354 2355 aboutToBeDeleted() { 2356 SubscriberManager.Get().delete(this.id__()); 2357 this.aboutToBeDeletedInternal(); 2358 } 2359 2360 doNothingBuilder(parent = null) { 2361 } 2362 2363 onPlaceChildren(selfLayoutInfo, children, constraint) { 2364 let currentX = 0; 2365 let currentY = 0; 2366 for (let index = 0; index < children.length; index++) { 2367 let child = children[index]; 2368 child.layout({ x: currentX, y: currentY }); 2369 } 2370 } 2371 2372 onMeasureSize(selfLayoutInfo, children, constraint) { 2373 let textArrowWidth = ARROW_ICON_WIDTH; 2374 let textArrowHeight = OPERATE_ITEM_LENGTH; 2375 let textChild = children[INDEX_ZERO]; 2376 let textConstraint = { 2377 minWidth: Math.max(textArrowWidth, Number(constraint.minWidth)), 2378 maxWidth: constraint.maxWidth, 2379 minHeight: Math.max(textArrowHeight, Number(constraint.minHeight)), 2380 maxHeight: constraint.maxHeight, 2381 }; 2382 let textMeasureResult = textChild.measure(textConstraint); 2383 textArrowWidth = Math.max(textArrowWidth, textMeasureResult.width); 2384 textArrowHeight = Math.max(textArrowHeight, textMeasureResult.height); 2385 let arrowChild = children[INDEX_ONE]; 2386 let arrowConstraint = { 2387 minWidth: textArrowWidth, 2388 maxWidth: textArrowWidth, 2389 minHeight: textArrowHeight, 2390 maxHeight: textArrowHeight, 2391 }; 2392 arrowChild.measure(arrowConstraint); 2393 return { width: textArrowWidth, height: textArrowHeight }; 2394 } 2395 2396 initialRender() { 2397 this.textArrowBuilder.bind(this)(); 2398 } 2399 2400 rerender() { 2401 this.updateDirtyElements(); 2402 } 2403} 2404 2405export default { 2406 SubHeaderV2Title, 2407 SubHeaderV2Select, 2408 SubHeaderV2, 2409 SubHeaderV2OperationType, 2410 SubHeaderV2OperationItem 2411};