diff --git a/advanced_ui_component/dialog/interfaces/dialog.js b/advanced_ui_component/dialog/interfaces/dialog.js index a97b68a544da00ac671cc77f610075f51a0b5a25..43809df8b08704ddd352ba14265fe534bd11e77b 100644 --- a/advanced_ui_component/dialog/interfaces/dialog.js +++ b/advanced_ui_component/dialog/interfaces/dialog.js @@ -18,6 +18,14 @@ const hilog = requireNapi('hilog'); const measure = requireNapi('measure'); const resourceManager = requireNapi('resourceManager'); +if (!('finalizeConstruction' in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { }); +} +export class CustomThemeImpl { + constructor(x21) { + this.colors = x21; + } +} const TITLE_MAX_LINES = 2; const HORIZON_BUTTON_MAX_COUNT = 2; const VERTICAL_BUTTON_MAX_COUNT = 4; @@ -43,12 +51,11 @@ const KEYCODE_UP = 2012; const KEYCODE_DOWN = 2013; const IGNORE_KEY_EVENT_TYPE = 1; const FIRST_ITEM_INDEX = 0; - export class TipsDialog extends ViewPU { - constructor(k19, l19, m19, n19 = -1, o19 = undefined, p19) { - super(k19, m19, n19, p19); - if (typeof o19 === 'function') { - this.paramsGenerator_ = o19; + constructor(r21, s21, t21, u21 = -1, v21 = undefined, w21) { + super(r21, t21, u21, w21); + if (typeof v21 === 'function') { + this.paramsGenerator_ = v21; } this.controller = undefined; this.imageRes = null; @@ -67,70 +74,85 @@ export class TipsDialog extends ViewPU { this.__checkBoxHeight = new ObservedPropertySimplePU(0, this, 'checkBoxHeight'); this.buttonHeight = 0; this.contentScroller = new Scroller(); - this.setInitiallyProvidedValue(l19); + this.__fontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'fontColorWithTheme'); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(s21); this.finalizeConstruction(); } - setInitiallyProvidedValue(j19) { - if (j19.controller !== undefined) { - this.controller = j19.controller; + setInitiallyProvidedValue(q21) { + if (q21.controller !== undefined) { + this.controller = q21.controller; + } + if (q21.imageRes !== undefined) { + this.imageRes = q21.imageRes; } - if (j19.imageRes !== undefined) { - this.imageRes = j19.imageRes; + if (q21.imageSize !== undefined) { + this.imageSize = q21.imageSize; } - if (j19.imageSize !== undefined) { - this.imageSize = j19.imageSize; + if (q21.title !== undefined) { + this.title = q21.title; } - if (j19.title !== undefined) { - this.title = j19.title; + if (q21.content !== undefined) { + this.content = q21.content; } - if (j19.content !== undefined) { - this.content = j19.content; + if (q21.checkAction !== undefined) { + this.checkAction = q21.checkAction; } - if (j19.checkAction !== undefined) { - this.checkAction = j19.checkAction; + if (q21.checkTips !== undefined) { + this.checkTips = q21.checkTips; } - if (j19.checkTips !== undefined) { - this.checkTips = j19.checkTips; + if (q21.isChecked !== undefined) { + this.isChecked = q21.isChecked; } - if (j19.isChecked !== undefined) { - this.isChecked = j19.isChecked; + if (q21.primaryButton !== undefined) { + this.primaryButton = q21.primaryButton; } - if (j19.primaryButton !== undefined) { - this.primaryButton = j19.primaryButton; + if (q21.secondaryButton !== undefined) { + this.secondaryButton = q21.secondaryButton; } - if (j19.secondaryButton !== undefined) { - this.secondaryButton = j19.secondaryButton; + if (q21.buttons !== undefined) { + this.buttons = q21.buttons; } - if (j19.buttons !== undefined) { - this.buttons = j19.buttons; + if (q21.imageSizeHeight !== undefined) { + this.imageSizeHeight = q21.imageSizeHeight; } - if (j19.imageSizeHeight !== undefined) { - this.imageSizeHeight = j19.imageSizeHeight; + if (q21.textAlignment !== undefined) { + this.textAlignment = q21.textAlignment; } - if (j19.textAlignment !== undefined) { - this.textAlignment = j19.textAlignment; + if (q21.marginOffset !== undefined) { + this.marginOffset = q21.marginOffset; } - if (j19.marginOffset !== undefined) { - this.marginOffset = j19.marginOffset; + if (q21.checkBoxHeight !== undefined) { + this.checkBoxHeight = q21.checkBoxHeight; } - if (j19.checkBoxHeight !== undefined) { - this.checkBoxHeight = j19.checkBoxHeight; + if (q21.buttonHeight !== undefined) { + this.buttonHeight = q21.buttonHeight; } - if (j19.buttonHeight !== undefined) { - this.buttonHeight = j19.buttonHeight; + if (q21.contentScroller !== undefined) { + this.contentScroller = q21.contentScroller; } - if (j19.contentScroller !== undefined) { - this.contentScroller = j19.contentScroller; + if (q21.fontColorWithTheme !== undefined) { + this.fontColorWithTheme = q21.fontColorWithTheme; + } + if (q21.theme !== undefined) { + this.theme = q21.theme; } } - updateStateVars(i19) { + updateStateVars(p21) { } - purgeVariableDependenciesOnElmtId(h19) { - this.__imageSize.purgeDependencyOnElmtId(h19); - this.__isChecked.purgeDependencyOnElmtId(h19); - this.__imageSizeHeight.purgeDependencyOnElmtId(h19); - this.__textAlignment.purgeDependencyOnElmtId(h19); - this.__checkBoxHeight.purgeDependencyOnElmtId(h19); + purgeVariableDependenciesOnElmtId(o21) { + this.__imageSize.purgeDependencyOnElmtId(o21); + this.__isChecked.purgeDependencyOnElmtId(o21); + this.__imageSizeHeight.purgeDependencyOnElmtId(o21); + this.__textAlignment.purgeDependencyOnElmtId(o21); + this.__checkBoxHeight.purgeDependencyOnElmtId(o21); + this.__fontColorWithTheme.purgeDependencyOnElmtId(o21); } aboutToBeDeleted() { this.__imageSize.aboutToBeDeleted(); @@ -138,100 +160,110 @@ export class TipsDialog extends ViewPU { this.__imageSizeHeight.aboutToBeDeleted(); this.__textAlignment.aboutToBeDeleted(); this.__checkBoxHeight.aboutToBeDeleted(); + this.__fontColorWithTheme.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - setController(g19) { - this.controller = g19; + setController(n21) { + this.controller = n21; } get imageSize() { return this.__imageSize.get(); } - set imageSize(f19) { - this.__imageSize.set(f19); + set imageSize(m21) { + this.__imageSize.set(m21); } get isChecked() { return this.__isChecked.get(); } - set isChecked(e19) { - this.__isChecked.set(e19); + set isChecked(l21) { + this.__isChecked.set(l21); } get imageSizeHeight() { return this.__imageSizeHeight.get(); } - set imageSizeHeight(d19) { - this.__imageSizeHeight.set(d19); + set imageSizeHeight(k21) { + this.__imageSizeHeight.set(k21); } get textAlignment() { return this.__textAlignment.get(); } - set textAlignment(c19) { - this.__textAlignment.set(c19); + set textAlignment(j21) { + this.__textAlignment.set(j21); } get checkBoxHeight() { return this.__checkBoxHeight.get(); } - set checkBoxHeight(b19) { - this.__checkBoxHeight.set(b19); + set checkBoxHeight(i21) { + this.__checkBoxHeight.set(i21); + } + get fontColorWithTheme() { + return this.__fontColorWithTheme.get(); + } + set fontColorWithTheme(h21) { + this.__fontColorWithTheme.set(h21); } initialRender() { + this.observeComponentCreation2((f21, g21) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); { - this.observeComponentCreation((v18, w18) => { - ViewStackProcessor.StartGetAccessRecordingFor(v18); - if (w18) { - let x18 = new CustomDialogComponent(this, { + this.observeComponentCreation2((z20, a21) => { + if (a21) { + let b21 = new CustomDialogComponent(this, { controller: this.controller, contentBuilder: () => { this.contentBuilder(); }, buttons: this.buttons, - }, undefined, v18, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 65 }); - ViewPU.create(x18); - let y18 = () => { + theme: this.theme, + }, undefined, z20, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', + line: 82, col: 7 }); + ViewPU.create(b21); + let c21 = () => { return { controller: this.controller, contentBuilder: () => { this.contentBuilder(); }, - buttons: this.buttons + buttons: this.buttons, + theme: this.theme, }; }; - x18.paramsGenerator_ = y18; + b21.paramsGenerator_ = c21; } else { - this.updateStateVarsOfChildByElmtId(v18, {}); + this.updateStateVarsOfChildByElmtId(z20, {}); } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, { name: 'CustomDialogComponent' }); } + WithTheme.pop(); } - contentBuilder(d18 = null) { - this.observeComponentCreation((s18, t18) => { - ViewStackProcessor.StartGetAccessRecordingFor(s18); + contentBuilder(g20 = null) { + this.observeComponentCreation2((v20, w20) => { Column.create(); - if (!t18) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Column); this.imagePart.bind(this)(); - this.observeComponentCreation((l18, m18) => { - ViewStackProcessor.StartGetAccessRecordingFor(l18); + this.observeComponentCreation2((o20, p20) => { If.create(); if (this.title != null || this.content != null) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation((q18, r18) => { - ViewStackProcessor.StartGetAccessRecordingFor(q18); + this.observeComponentCreation2((t20, u20) => { Column.create(); - Column.padding({ top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '', 'moduleName': '' } }); + Column.padding({ + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + } + }); Column.constraintSize({ maxHeight: `calc(100% - ${this.checkBoxHeight}vp - ${this.imageSizeHeight}vp - ${this.buttonHeight}vp)` }); - if (!r18) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Column); this.textPart.bind(this)(); Column.pop(); }); @@ -240,14 +272,9 @@ export class TipsDialog extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!m18) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); - this.observeComponentCreation((h18, i18) => { - ViewStackProcessor.StartGetAccessRecordingFor(h18); + this.observeComponentCreation2((k20, l20) => { If.create(); if (this.checkTips != null) { this.ifElseBranchUpdateFunction(0, () => { @@ -258,153 +285,166 @@ export class TipsDialog extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!i18) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); Column.pop(); } - checkBoxPart(m17, n17 = null) { - this.observeComponentCreation((y17, z17) => { - ViewStackProcessor.StartGetAccessRecordingFor(y17); + checkBoxPart(p19, q19 = null) { + this.observeComponentCreation2((b20, c20) => { Row.create(); - Row.padding({ top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '', 'moduleName': '' } }); + Row.padding({ + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + } + }); Row.constraintSize({ minHeight: CHECKBOX_CONTAINER_HEIGHT }); Row.width('100%'); - Row.onAreaChange((b18, c18) => { - this.checkBoxHeight = Number(c18.height); + Row.onAreaChange((e20, f20) => { + this.checkBoxHeight = Number(f20.height); }); - if (!z17) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((u17, v17) => { - ViewStackProcessor.StartGetAccessRecordingFor(u17); + }, Row); + this.observeComponentCreation2((x19, y19) => { Checkbox.create({ name: 'checkbox', group: 'checkboxGroup' }); Checkbox.select(this.isChecked); - Checkbox.onChange((x17) => { - this.isChecked = x17; + Checkbox.onChange((a20) => { + this.isChecked = a20; if (this.checkAction) { - this.checkAction(x17); + this.checkAction(a20); } }); - Checkbox.margin({ right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '', 'moduleName': '' } }); - if (!v17) { - Checkbox.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Checkbox.margin({ + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level4'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + } + }); + }, Checkbox); Checkbox.pop(); - this.observeComponentCreation((r17, s17) => { - ViewStackProcessor.StartGetAccessRecordingFor(r17); - Text.create(m17); - Text.fontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Body_M'], 'bundleName': '', 'moduleName': '' }); + this.observeComponentCreation2((u19, v19) => { + Text.create(p19); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_M'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(FontWeight.Regular); - Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '', 'moduleName': '' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.maxLines(CONTENT_MAX_LINES); Text.layoutWeight(1); Text.focusable(false); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); + Text.key('advanced_tipsDialog_checkboxPart_text'); Text.onClick(() => { this.isChecked = !this.isChecked; if (this.checkAction) { this.checkAction(this.isChecked); } }); - if (!s17) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Text); Text.pop(); Row.pop(); } - imagePart(c17 = null) { - this.observeComponentCreation((h17, i17) => { - ViewStackProcessor.StartGetAccessRecordingFor(h17); + imagePart(f19 = null) { + this.observeComponentCreation2((k19, l19) => { Column.create(); Column.width('100%'); Column.constraintSize({ maxHeight: `calc(100% - ${this.checkBoxHeight}vp - ${this.buttonHeight}vp - ${TEXT_MIN_HEIGHT}vp + ${this.marginOffset}vp)` }); - Column.onAreaChange((k17, l17) => { - this.imageSizeHeight = Number(l17.height); + Column.onAreaChange((n19, o19) => { + this.imageSizeHeight = Number(o19.height); }); - if (!i17) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((f17, g17) => { - ViewStackProcessor.StartGetAccessRecordingFor(f17); + }, Column); + this.observeComponentCreation2((i19, j19) => { Image.create(this.imageRes); - Image.size(this.imageSize); + Image.size(ObservedObject.GetRawObject(this.imageSize)); Image.objectFit(ImageFit.Contain); - Image.borderRadius({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level6'], 'bundleName': '', 'moduleName': '' }); + Image.borderRadius({ + 'id': -1, + 'type': 10002, + params: ['sys.float.corner_radius_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Image.constraintSize({ maxWidth: '100%', maxHeight: `calc(100% - ${this.checkBoxHeight}vp - ${this.buttonHeight}vp - ${TEXT_MIN_HEIGHT}vp + ${this.marginOffset}vp)` }); - if (!g17) { - Image.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Image); Column.pop(); } - textPart(w15 = null) { - this.observeComponentCreation((a17, b17) => { - ViewStackProcessor.StartGetAccessRecordingFor(a17); + textPart(x17 = null) { + this.observeComponentCreation2((d19, e19) => { Scroll.create(this.contentScroller); Scroll.margin({ right: `${this.marginOffset}vp` }); - if (!b17) { - Scroll.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((y16, z16) => { - ViewStackProcessor.StartGetAccessRecordingFor(y16); + }, Scroll); + this.observeComponentCreation2((b19, c19) => { Column.create(); - Column.margin({ right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '', 'moduleName': '' } }); - if (!z16) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((o16, p16) => { - ViewStackProcessor.StartGetAccessRecordingFor(o16); + Column.margin({ + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + } + }); + }, Column); + this.observeComponentCreation2((r18, s18) => { If.create(); if (this.title != null) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation((w16, x16) => { - ViewStackProcessor.StartGetAccessRecordingFor(w16); + this.observeComponentCreation2((z18, a19) => { Row.create(); - Row.padding({ bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level8'], 'bundleName': '', 'moduleName': '' } }); - if (!x16) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((u16, v16) => { - ViewStackProcessor.StartGetAccessRecordingFor(u16); + Row.padding({ + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + } }); + }, Row); + this.observeComponentCreation2((x18, y18) => { Text.create(this.title); - Text.fontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Title_S'], 'bundleName': '', 'moduleName': '' }); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Title_S'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(FontWeight.Medium); - Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '', 'moduleName': '' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.textAlign(TextAlign.Center); Text.maxLines(CONTENT_MAX_LINES); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.minFontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Body_L'], 'bundleName': '', 'moduleName': '' }); - Text.maxFontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Title_S'], 'bundleName': '', 'moduleName': '' }); + Text.minFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Text.maxFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Title_S'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.width('100%'); - if (!v16) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Text.key('advanced_tipsDialog_textPart_title'); + }, Text); Text.pop(); Row.pop(); }); @@ -413,48 +453,40 @@ export class TipsDialog extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!p16) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); - this.observeComponentCreation((b16, c16) => { - ViewStackProcessor.StartGetAccessRecordingFor(b16); + this.observeComponentCreation2((c18, d18) => { If.create(); if (this.content != null) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation((m16, n16) => { - ViewStackProcessor.StartGetAccessRecordingFor(m16); + this.observeComponentCreation2((p18, q18) => { Row.create(); - if (!n16) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((h16, i16) => { - ViewStackProcessor.StartGetAccessRecordingFor(h16); + }, Row); + this.observeComponentCreation2((i18, j18) => { Text.create(this.content); Text.focusable(true); Text.defaultFocus(!(this.primaryButton || this.secondaryButton)); - Text.fontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Body_L'], 'bundleName': '', 'moduleName': '' }); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(FontWeight.Medium); - Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '', 'moduleName': '' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.textAlign(this.textAlignment); Text.width('100%'); - Text.onAreaChange((k16, l16) => { - this.getTextAlign(Number(l16.width)); + Text.key('advanced_tipsDialog_textPart_content'); + Text.onKeyEvent((o18) => { + if (o18) { + resolveKeyEvent(o18, this.contentScroller); + } }); - Text.onKeyEvent((f17) => { - if (f17) { - resolveKeyEvent(f17, this.contentScroller); - } + Text.onAreaChange((m18, n18) => { + this.getTextAlign(Number(n18.width)); }); - if (!i16) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Text); Text.pop(); Row.pop(); }); @@ -463,36 +495,52 @@ export class TipsDialog extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!c16) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); Column.pop(); Scroll.pop(); } aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; this.initButtons(); this.initMargin(); } - getTextAlign(t15) { - let u15 = measure.measureTextSize({ + getTextAlign(u17) { + let v17 = measure.measureTextSize({ textContent: this.content, - fontSize: { 'id': -1, 'type': 10002, params: ['sys.float.Body_L'], 'bundleName': '', 'moduleName': '' }, - constraintWidth: t15, + fontSize: { + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + constraintWidth: u17, }); - let v15 = measure.measureTextSize({ + let w17 = measure.measureTextSize({ textContent: this.content, - fontSize: { 'id': -1, 'type': 10002, params: ['sys.float.Body_L'], 'bundleName': '', 'moduleName': '' }, + fontSize: { + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); - if (this.getTextHeight(u15) <= this.getTextHeight(v15)) { + if (this.getTextHeight(v17) <= this.getTextHeight(w17)) { this.textAlignment = TextAlign.Center; } } - getTextHeight(s15) { - if (s15 && s15.height !== null && s15.height !== undefined) { - return Number(s15.height); + getTextHeight(t17) { + if (t17 && t17.height !== null && t17.height !== undefined) { + return Number(t17.height); } return 0; } @@ -513,9 +561,9 @@ export class TipsDialog extends ViewPU { if (!this.buttons || this.buttons.length === 0) { return 0; } - let r15 = getNumberByResource('alert_button_top_padding'); - r15 += BUTTON_DEFAULT_HEIGHT + getNumberByResource('alert_button_bottom_padding_horizontal'); - return r15; + let s17 = getNumberByResource('alert_button_top_padding'); + s17 += BUTTON_DEFAULT_HEIGHT + getNumberByResource('alert_button_bottom_padding_horizontal'); + return s17; } initMargin() { this.marginOffset = 0 - getNumberByResource('padding_level8'); @@ -524,12 +572,11 @@ export class TipsDialog extends ViewPU { this.updateDirtyElements(); } } - export class SelectDialog extends ViewPU { - constructor(j15, k15, l15, m15 = -1, n15 = undefined, o15) { - super(j15, l15, m15, o15); - if (typeof n15 === 'function') { - this.paramsGenerator_ = n15; + constructor(i17, j17, k17, l17 = -1, m17 = undefined, n17) { + super(i17, k17, l17, n17); + if (typeof m17 === 'function') { + this.paramsGenerator_ = m17; } this.title = ''; this.content = ''; @@ -539,18 +586,34 @@ export class SelectDialog extends ViewPU { this.buttons = []; this.contentPadding = undefined; this.contentBuilder = this.buildContent; + this.__fontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'fontColorWithTheme'); + this.__dividerColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.comp_divider'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'dividerColorWithTheme'); + this.theme = new CustomThemeImpl({}); this.controller = new CustomDialogController({ builder: () => { - let p15 = new CustomContentDialog(this, { + let o17 = new CustomContentDialog(this, { primaryTitle: this.title, contentBuilder: () => { this.contentBuilder(); }, buttons: this.buttons, - }, undefined, -1, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 254 }); - p15.setController(this.controller); - ViewPU.create(p15); - let q15 = () => { + }, undefined, -1, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 288, col: 14 }); + o17.setController(this.controller); + ViewPU.create(o17); + let p17 = () => { return { primaryTitle: this.title, contentBuilder: () => { @@ -559,105 +622,134 @@ export class SelectDialog extends ViewPU { buttons: this.buttons }; }; - p15.paramsGenerator_ = q15; + o17.paramsGenerator_ = p17; } }, this); this.contentScroller = new Scroller(); - this.setInitiallyProvidedValue(k15); + this.setInitiallyProvidedValue(j17); this.finalizeConstruction(); } - setInitiallyProvidedValue(i15) { - if (i15.title !== undefined) { - this.title = i15.title; + setInitiallyProvidedValue(h17) { + if (h17.title !== undefined) { + this.title = h17.title; } - if (i15.content !== undefined) { - this.content = i15.content; + if (h17.content !== undefined) { + this.content = h17.content; } - if (i15.selectedIndex !== undefined) { - this.selectedIndex = i15.selectedIndex; + if (h17.selectedIndex !== undefined) { + this.selectedIndex = h17.selectedIndex; } - if (i15.confirm !== undefined) { - this.confirm = i15.confirm; + if (h17.confirm !== undefined) { + this.confirm = h17.confirm; } - if (i15.radioContent !== undefined) { - this.radioContent = i15.radioContent; + if (h17.radioContent !== undefined) { + this.radioContent = h17.radioContent; } - if (i15.buttons !== undefined) { - this.buttons = i15.buttons; + if (h17.buttons !== undefined) { + this.buttons = h17.buttons; } - if (i15.contentPadding !== undefined) { - this.contentPadding = i15.contentPadding; + if (h17.contentPadding !== undefined) { + this.contentPadding = h17.contentPadding; } - if (i15.contentBuilder !== undefined) { - this.contentBuilder = i15.contentBuilder; + if (h17.contentBuilder !== undefined) { + this.contentBuilder = h17.contentBuilder; } - if (i15.controller !== undefined) { - this.controller = i15.controller; + if (h17.fontColorWithTheme !== undefined) { + this.fontColorWithTheme = h17.fontColorWithTheme; } - if (i15.contentScroller !== undefined) { - this.contentScroller = i15.contentScroller; + if (h17.dividerColorWithTheme !== undefined) { + this.dividerColorWithTheme = h17.dividerColorWithTheme; + } + if (h17.theme !== undefined) { + this.theme = h17.theme; + } + if (h17.controller !== undefined) { + this.controller = h17.controller; + } + if (h17.contentScroller !== undefined) { + this.contentScroller = h17.contentScroller; } } - updateStateVars(h15) { + updateStateVars(g17) { } - purgeVariableDependenciesOnElmtId(g15) { + purgeVariableDependenciesOnElmtId(f17) { + this.__fontColorWithTheme.purgeDependencyOnElmtId(f17); + this.__dividerColorWithTheme.purgeDependencyOnElmtId(f17); } aboutToBeDeleted() { + this.__fontColorWithTheme.aboutToBeDeleted(); + this.__dividerColorWithTheme.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - setController(f15) { - this.controller = f15; + get fontColorWithTheme() { + return this.__fontColorWithTheme.get(); + } + set fontColorWithTheme(e17) { + this.__fontColorWithTheme.set(e17); + } + get dividerColorWithTheme() { + return this.__dividerColorWithTheme.get(); + } + set dividerColorWithTheme(d17) { + this.__dividerColorWithTheme.set(d17); } - buildContent(s12 = null) { - this.observeComponentCreation((d15, e15) => { - ViewStackProcessor.StartGetAccessRecordingFor(d15); - Scroll.create(); + setController(c17) { + this.controller = c17; + } + buildContent(n14 = null) { + this.observeComponentCreation2((a17, b17) => { + Scroll.create(this.contentScroller); Scroll.scrollBar(BarState.Auto); - if (!e15) { - Scroll.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((b15, c15) => { - ViewStackProcessor.StartGetAccessRecordingFor(b15); + }, Scroll); + this.observeComponentCreation2((y16, z16) => { Column.create(); - if (!c15) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((r14, s14) => { - ViewStackProcessor.StartGetAccessRecordingFor(r14); + }, Column); + this.observeComponentCreation2((o16, p16) => { If.create(); if (this.content) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation((z14, a15) => { - ViewStackProcessor.StartGetAccessRecordingFor(z14); + this.observeComponentCreation2((w16, x16) => { Row.create(); Row.padding({ - left: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level12'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level12'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level12'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level12'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level4'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); Row.width('100%'); - if (!a15) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((x14, y14) => { - ViewStackProcessor.StartGetAccessRecordingFor(x14); + }, Row); + this.observeComponentCreation2((u16, v16) => { Text.create(this.content); - Text.fontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Body_M'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_M'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(FontWeight.Regular); - Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - if (!y14) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Text.key('advanced_selectDialog_content'); + }, Text); Text.pop(); Row.pop(); }); @@ -666,188 +758,207 @@ export class SelectDialog extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!s14) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); - this.observeComponentCreation((p14, q14) => { - ViewStackProcessor.StartGetAccessRecordingFor(p14); - List.create({ space: 1, scroller: this.contentScroller }); + this.observeComponentCreation2((l16, m16) => { + List.create({ space: 1 }); List.width('100%'); List.clip(false); List.onFocus(() => { - this.contentScroller.scrollToIndex(FIRST_ITEM_INDEX); - focusControl.requestFocus(String(FIRST_ITEM_INDEX)); + this.contentScroller.scrollEdge(Edge.Top); + focusControl.requestFocus(String(FIRST_ITEM_INDEX)); }); List.defaultFocus(this.buttons?.length == 0 ? true : false); - if (!q14) { - List.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((y12, z12) => { - ViewStackProcessor.StartGetAccessRecordingFor(y12); + }, List); + this.observeComponentCreation2((t14, u14) => { ForEach.create(); - const a13 = (c13, d13) => { - const e13 = c13; + const v14 = (x14, y14) => { + const z14 = x14; { - const f13 = (n14, o14) => { - ViewStackProcessor.StartGetAccessRecordingFor(n14); - g13(n14, o14); - if (!o14) { + const a15 = (j16, k16) => { + ViewStackProcessor.StartGetAccessRecordingFor(j16); + b15(j16, k16); + if (!k16) { ListItem.pop(); } ViewStackProcessor.StopGetAccessRecording(); }; - const g13 = (l14, m14) => { - ListItem.create(h13, true); + const b15 = (h16, i16) => { + ListItem.create(c15, true); }; - const h13 = (l13, m13) => { - f13(l13, m13); - this.updateFuncByElmtId.set(l13, f13); - this.observeComponentCreation((j14, k14) => { - ViewStackProcessor.StartGetAccessRecordingFor(j14); + const c15 = (g15, h15) => { + a15(g15, h15); + this.observeComponentCreation2((f16, g16) => { Column.create(); Column.padding({ - left: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); - if (!k14) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((g14, h14) => { - ViewStackProcessor.StartGetAccessRecordingFor(g14); + }, Column); + this.observeComponentCreation2((c16, d16) => { Button.createWithChild(); Button.type(ButtonType.Normal); - Button.borderRadius({ 'id': -1, 'type': 10002, params: ['sys.float.corner_radius_level8'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + Button.borderRadius({ + 'id': -1, + 'type': 10002, + params: ['sys.float.corner_radius_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Button.buttonStyle(ButtonStyleMode.TEXTUAL); Button.padding({ - left: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); Button.onClick(() => { - e13.action && e13.action(); + z14.action && z14.action(); this.controller.close(); }); - if (!h14) { - Button.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((e14, f14) => { - ViewStackProcessor.StartGetAccessRecordingFor(e14); + }, Button); + this.observeComponentCreation2((a16, b16) => { Row.create(); Row.constraintSize({ minHeight: LIST_MIN_HEIGHT }); Row.clip(false); Row.padding({ - top: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - bottom: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level4'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level4'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level4'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + }); + }, Row); + this.observeComponentCreation2((y15, z15) => { + Text.create(z14.title); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); - if (!f14) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((c14, d14) => { - ViewStackProcessor.StartGetAccessRecordingFor(c14); - Text.create(e13.title); - Text.fontSize({ 'id': -1, 'type': 10002, params: ['sys.float.Body_L'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); Text.fontWeight(FontWeight.Medium); - Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.layoutWeight(1); - if (!d14) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Text.key('advanced_selectDialog_content'); + }, Text); Text.pop(); - this.observeComponentCreation((a14, b14) => { - ViewStackProcessor.StartGetAccessRecordingFor(a14); + this.observeComponentCreation2((v15, w15) => { Radio.create({ value: 'item.title', group: 'radioGroup' }); Radio.size({ width: CHECKBOX_CONTAINER_LENGTH, height: CHECKBOX_CONTAINER_LENGTH }); - Radio.checked(this.selectedIndex === d13); + Radio.checked(this.selectedIndex === y14); Radio.hitTestBehavior(HitTestMode.None); - Radio.id(String(d13)); + Radio.id(String(y14)); Radio.onFocus(() => { - if (d13 == FIRST_ITEM_INDEX) { - this.contentScroller.scrollToIndex(FIRST_ITEM_INDEX); - } + if (y14 === FIRST_ITEM_INDEX) { + this.contentScroller.scrollEdge(Edge.Top); + } + else if (y14 === this.radioContent.length - 1) { + this.contentScroller.scrollEdge(Edge.Bottom); + } }); - if (!b14) { - Radio.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Radio); Row.pop(); Button.pop(); - this.observeComponentCreation((t13, u13) => { - ViewStackProcessor.StartGetAccessRecordingFor(t13); + this.observeComponentCreation2((o15, p15) => { If.create(); - if (d13 < this.radioContent.length - 1) { + if (y14 && y14 < this.radioContent.length - 1) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation((y13, z13) => { - ViewStackProcessor.StartGetAccessRecordingFor(y13); + this.observeComponentCreation2((t15, u15) => { Divider.create(); - Divider.color({ 'id': -1, 'type': 10001, params: ['sys.color.comp_divider'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + Divider.color(ObservedObject.GetRawObject(this.dividerColorWithTheme)); Divider.padding({ - left: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }, - right: { 'id': -1, 'type': 10002, params: ['sys.float.padding_level6'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level6'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); - if (!z13) { - Divider.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Divider.key('advanced_selectDialog_divider'); + }, Divider); }); } else { this.ifElseBranchUpdateFunction(1, () => { }); } - if (!u13) { - If.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, If); If.pop(); Column.pop(); ListItem.pop(); }; - this.observeComponentCreation(f13); + this.observeComponentCreation2(b15, ListItem); ListItem.pop(); } }; - this.forEachUpdateFunction(y12, this.radioContent, a13, undefined, true, false); - if (!z12) { - ForEach.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + this.forEachUpdateFunction(t14, this.radioContent, v14, undefined, true, false); + }, ForEach); ForEach.pop(); List.pop(); Column.pop(); Scroll.pop(); } initialRender() { + this.observeComponentCreation2((l14, m14) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); { - this.observeComponentCreation((m12, n12) => { - ViewStackProcessor.StartGetAccessRecordingFor(m12); - if (n12) { - let o12 = new CustomDialogComponent(this, { + this.observeComponentCreation2((f14, g14) => { + if (g14) { + let h14 = new CustomDialogComponent(this, { controller: this.controller, primaryTitle: this.title, contentBuilder: () => { this.contentBuilder(); }, buttons: this.buttons, - contentAreaPadding: this.contentPadding - }, undefined, m12, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 332 }); - ViewPU.create(o12); - let p12 = () => { + contentAreaPadding: this.contentPadding, + theme: this.theme, + }, undefined, f14, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 376, col: 7 }); + ViewPU.create(h14); + let i14 = () => { return { controller: this.controller, primaryTitle: this.title, @@ -855,19 +966,36 @@ export class SelectDialog extends ViewPU { this.contentBuilder(); }, buttons: this.buttons, - contentAreaPadding: this.contentPadding + contentAreaPadding: this.contentPadding, + theme: this.theme, }; }; - o12.paramsGenerator_ = p12; + h14.paramsGenerator_ = i14; } else { - this.updateStateVarsOfChildByElmtId(m12, {}); + this.updateStateVarsOfChildByElmtId(f14, {}); } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, { name: 'CustomDialogComponent' }); } + WithTheme.pop(); } aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.dividerColorWithTheme = this.theme.colors?.compDivider ? + this.theme.colors.compDivider : { + 'id': -1, + 'type': 10001, + params: ['sys.color.comp_divider'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; this.initContentPadding(); this.initButtons(); } @@ -904,391 +1032,443 @@ export class SelectDialog extends ViewPU { this.updateDirtyElements(); } } - export class ConfirmDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; + constructor(x13, y13, z13, a14 = -1, b14 = undefined, c14) { + super(x13, z13, a14, c14); + if (typeof b14 === 'function') { + this.paramsGenerator_ = b14; + } + this.controller = undefined; this.title = ''; this.content = ''; this.checkTips = ''; - this.__isChecked = new ObservedPropertySimplePU(!1, this, 'isChecked'); + this.__isChecked = new ObservedPropertySimplePU(false, this, 'isChecked'); this.primaryButton = { value: '' }; this.secondaryButton = { value: '' }; - this.setInitiallyProvidedValue(o); + this.__fontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'fontColorWithTheme'); + this.__checkboxFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'checkboxFontColorWithTheme'); + this.__buttonFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'buttonFontColorWithTheme'); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(y13); + this.finalizeConstruction(); } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.content && (this.content = e.content); - void 0 !== e.checkTips && (this.checkTips = e.checkTips); - void 0 !== e.isChecked && (this.isChecked = e.isChecked); - void 0 !== e.primaryButton && (this.primaryButton = e.primaryButton); - void 0 !== e.secondaryButton && (this.secondaryButton = e.secondaryButton); + setInitiallyProvidedValue(w13) { + if (w13.controller !== undefined) { + this.controller = w13.controller; + } + if (w13.title !== undefined) { + this.title = w13.title; + } + if (w13.content !== undefined) { + this.content = w13.content; + } + if (w13.checkTips !== undefined) { + this.checkTips = w13.checkTips; + } + if (w13.isChecked !== undefined) { + this.isChecked = w13.isChecked; + } + if (w13.primaryButton !== undefined) { + this.primaryButton = w13.primaryButton; + } + if (w13.secondaryButton !== undefined) { + this.secondaryButton = w13.secondaryButton; + } + if (w13.fontColorWithTheme !== undefined) { + this.fontColorWithTheme = w13.fontColorWithTheme; + } + if (w13.checkboxFontColorWithTheme !== undefined) { + this.checkboxFontColorWithTheme = w13.checkboxFontColorWithTheme; + } + if (w13.buttonFontColorWithTheme !== undefined) { + this.buttonFontColorWithTheme = w13.buttonFontColorWithTheme; + } + if (w13.theme !== undefined) { + this.theme = w13.theme; + } } - - updateStateVars(e) { + updateStateVars(v13) { } - - purgeVariableDependenciesOnElmtId(e) { - this.__isChecked.purgeDependencyOnElmtId(e); + purgeVariableDependenciesOnElmtId(u13) { + this.__isChecked.purgeDependencyOnElmtId(u13); + this.__fontColorWithTheme.purgeDependencyOnElmtId(u13); + this.__checkboxFontColorWithTheme.purgeDependencyOnElmtId(u13); + this.__buttonFontColorWithTheme.purgeDependencyOnElmtId(u13); } - aboutToBeDeleted() { this.__isChecked.aboutToBeDeleted(); + this.__fontColorWithTheme.aboutToBeDeleted(); + this.__checkboxFontColorWithTheme.aboutToBeDeleted(); + this.__buttonFontColorWithTheme.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - - setController(e) { - this.controller = e; + setController(t13) { + this.controller = t13; } - get isChecked() { return this.__isChecked.get(); } - - set isChecked(e) { - this.__isChecked.set(e); + set isChecked(s13) { + this.__isChecked.set(s13); + } + get fontColorWithTheme() { + return this.__fontColorWithTheme.get(); + } + set fontColorWithTheme(r13) { + this.__fontColorWithTheme.set(r13); + } + get checkboxFontColorWithTheme() { + return this.__checkboxFontColorWithTheme.get(); + } + set checkboxFontColorWithTheme(q13) { + this.__checkboxFontColorWithTheme.set(q13); + } + get buttonFontColorWithTheme() { + return this.__buttonFontColorWithTheme.get(); + } + set buttonFontColorWithTheme(p13) { + this.__buttonFontColorWithTheme.set(p13); } - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((n13, o13) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); + this.observeComponentCreation2((l13, m13) => { Column.create(); Column.backgroundBlurStyle(BlurStyle.Thick); Column.borderRadius({ - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); Column.margin({ left: { - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }, right: { - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }, bottom: { - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', } }); Column.backgroundColor({ - id: -1, - type: 10001, + 'id': -1, + 'type': 10001, params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + }, Column); + this.observeComponentCreation2((j13, k13) => { Row.create(); Row.padding({ left: 24, right: 24, top: 24 }); Row.constraintSize({ minHeight: 56 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + }, Row); + this.observeComponentCreation2((h13, i13) => { Text.create(this.title); Text.fontSize({ - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_text_size_dialog_tittle'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); Text.fontWeight(FontWeight.Medium); Text.maxLines(CONTENT_MAX_LINES); Text.minFontSize(15); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.textAlign(TextAlign.Start); Text.width('100%'); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + Text.key('advanced_confirmDialog_title'); + }, Text); Text.pop(); Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((x12, y12) => { If.create(); - this.content ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - Row.width('100%'); - Row.constraintSize({ minHeight: 36 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.focusable(true); - Text.defaultFocus(!(this.primaryButton?.value || this.secondaryButton?.value)); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body1'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(CONTENT_MAX_LINES); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body3'], - bundleName: '', - moduleName: '' - }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + if (this.content) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((f13, g13) => { + Row.create(); + Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); + Row.width('100%'); + Row.constraintSize({ minHeight: 36 }); + }, Row); + this.observeComponentCreation2((d13, e13) => { + Text.create(this.content); + Text.focusable(true); + Text.defaultFocus(!(this.primaryButton?.value || this.secondaryButton?.value)); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_text_size_body1'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Text.fontWeight(FontWeight.Medium); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); + Text.maxLines(CONTENT_MAX_LINES); + Text.textOverflow({ overflow: TextOverflow.Ellipsis }); + Text.minFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_text_size_body3'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Text.key('advanced_confirmDialog_content'); + }, Text); + Text.pop(); + Row.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((v12, w12) => { Row.create(); Row.height(CHECKBOX_CONTAINER_HEIGHT); Row.width('100%'); Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + }, Row); + this.observeComponentCreation2((r12, s12) => { Checkbox.create({ name: 'checkbox', group: 'checkboxGroup' }); Checkbox.select(this.isChecked); - Checkbox.onChange((e => { - this.isChecked = e; - })); + Checkbox.onChange((u12) => { + this.isChecked = u12; + }); Checkbox.margin({ left: 0, right: 8 }); - o || Checkbox.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + }, Checkbox); Checkbox.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((o12, p12) => { Text.create(this.checkTips); Text.fontSize({ - id: -1, - type: 10002, + 'id': -1, + 'type': 10002, params: ['sys.float.ohos_id_text_size_body2'], - bundleName: '', - moduleName: '' + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); + Text.fontColor(ObservedObject.GetRawObject(this.checkboxFontColorWithTheme)); Text.maxLines(CONTENT_MAX_LINES); Text.layoutWeight(1); Text.focusable(false); - Text.onClick((() => { + Text.textOverflow({ overflow: TextOverflow.Ellipsis }); + Text.key('advanced_confirmDialog_checkboxText'); + Text.onClick(() => { this.isChecked = !this.isChecked; - })); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + }); + }, Text); Text.pop(); Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((m12, n12) => { Row.create(); Row.width('100%'); Row.padding({ left: 16, right: 16, top: 16, bottom: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + }, Row); + this.observeComponentCreation2((e12, f12) => { If.create(); - this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.primaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.defaultFocus(true); - Button.backgroundColor(this.primaryButton.background ? this.primaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.primaryButton.action && this.primaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + if (this.primaryButton?.value) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((j12, k12) => { + Button.createWithLabel(this.primaryButton.value); + Button.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_text_size_button1'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Button.fontWeight(FontWeight.Medium); + Button.layoutWeight(1); + Button.defaultFocus(true); + Button.backgroundColor(this.primaryButton.background ? this.primaryButton.background : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_background_transparent'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Button.fontColor(this.primaryButton.fontColor ? + this.primaryButton.fontColor : this.buttonFontColorWithTheme); + Button.key('advanced_confirmDialog_primaryButton'); + Button.onClick(() => { + if (this.primaryButton?.action) + this.primaryButton.action(); + this.controller.close(); + }); + }, Button); + Button.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((p11, q11) => { If.create(); - this.secondaryButton.value && this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(DIVIDER_CONTAINER_WIDTH); - Column.alignItems(HorizontalAlign.Center); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.background ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.width(DIVIDER_WIDTH); - Divider.height(DIVIDER_HEIGHT); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' + if (this.secondaryButton?.value && this.primaryButton?.value) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((c12, d12) => { + Column.create(); + Column.width(DIVIDER_CONTAINER_WIDTH); + Column.alignItems(HorizontalAlign.Center); + }, Column); + this.observeComponentCreation2((v11, w11) => { + If.create(); + if (!this.secondaryButton.background) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((a12, b12) => { + Divider.create(); + Divider.width(DIVIDER_WIDTH); + Divider.height(DIVIDER_HEIGHT); + Divider.color({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_list_separator'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Divider.vertical(true); + }, Divider); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { }); - Divider.vertical(!0); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + } + }, If); + If.pop(); + Column.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); + this.observeComponentCreation2((h11, i11) => { If.create(); - this.secondaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.secondaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.defaultFocus(true); - Button.backgroundColor(this.secondaryButton.background ? this.secondaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.secondaryButton.action && this.secondaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); + if (this.secondaryButton?.value) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((m11, n11) => { + Button.createWithLabel(this.secondaryButton.value); + Button.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_text_size_button1'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Button.fontWeight(FontWeight.Medium); + Button.layoutWeight(1); + Button.defaultFocus(true); + Button.backgroundColor(this.secondaryButton.background ? this.secondaryButton.background : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_background_transparent'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Button.fontColor(this.secondaryButton?.fontColor ? + this.secondaryButton.fontColor : this.buttonFontColorWithTheme); + Button.key('advanced_confirmDialog_secondaryButton'); + Button.onClick(() => { + if (this.secondaryButton?.action) + this.secondaryButton.action(); + this.controller.close(); + }); + }, Button); + Button.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); If.pop(); Row.pop(); Column.pop(); + WithTheme.pop(); } + aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.checkboxFontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.buttonFontColorWithTheme = this.theme.colors?.fontEmphasize ? + this.theme.colors.fontEmphasize : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + } rerender() { this.updateDirtyElements(); } } - export class AlertDialog extends ViewPU { - constructor(n9, o9, p9, q9 = -1, r9 = undefined, s9) { - super(n9, p9, q9, s9); - if (typeof r9 === 'function') { - this.paramsGenerator_ = r9; + constructor(p10, q10, r10, s10 = -1, t10 = undefined, u10) { + super(p10, r10, s10, u10); + if (typeof t10 === 'function') { + this.paramsGenerator_ = t10; } this.controller = undefined; this.primaryTitle = undefined; @@ -1299,62 +1479,87 @@ export class AlertDialog extends ViewPU { this.buttons = undefined; this.__textAlign = new ObservedPropertySimplePU(TextAlign.Start, this, 'textAlign'); this.contentScroller = new Scroller(); - this.setInitiallyProvidedValue(o9); + this.__fontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'fontColorWithTheme'); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(q10); this.finalizeConstruction(); } - setInitiallyProvidedValue(m9) { - if (m9.controller !== undefined) { - this.controller = m9.controller; + setInitiallyProvidedValue(o10) { + if (o10.controller !== undefined) { + this.controller = o10.controller; + } + if (o10.primaryTitle !== undefined) { + this.primaryTitle = o10.primaryTitle; + } + if (o10.secondaryTitle !== undefined) { + this.secondaryTitle = o10.secondaryTitle; } - if (m9.primaryTitle !== undefined) { - this.primaryTitle = m9.primaryTitle; + if (o10.content !== undefined) { + this.content = o10.content; } - if (m9.secondaryTitle !== undefined) { - this.secondaryTitle = m9.secondaryTitle; + if (o10.primaryButton !== undefined) { + this.primaryButton = o10.primaryButton; } - if (m9.content !== undefined) { - this.content = m9.content; + if (o10.secondaryButton !== undefined) { + this.secondaryButton = o10.secondaryButton; } - if (m9.primaryButton !== undefined) { - this.primaryButton = m9.primaryButton; + if (o10.buttons !== undefined) { + this.buttons = o10.buttons; } - if (m9.secondaryButton !== undefined) { - this.secondaryButton = m9.secondaryButton; + if (o10.textAlign !== undefined) { + this.textAlign = o10.textAlign; } - if (m9.buttons !== undefined) { - this.buttons = m9.buttons; + if (o10.contentScroller !== undefined) { + this.contentScroller = o10.contentScroller; } - if (m9.textAlign !== undefined) { - this.textAlign = m9.textAlign; + if (o10.fontColorWithTheme !== undefined) { + this.fontColorWithTheme = o10.fontColorWithTheme; } - if (m9.contentScroller !== undefined) { - this.contentScroller = m9.contentScroller; + if (o10.theme !== undefined) { + this.theme = o10.theme; } } - updateStateVars(l9) { + updateStateVars(n10) { } - purgeVariableDependenciesOnElmtId(k9) { - this.__textAlign.purgeDependencyOnElmtId(k9); + purgeVariableDependenciesOnElmtId(m10) { + this.__textAlign.purgeDependencyOnElmtId(m10); + this.__fontColorWithTheme.purgeDependencyOnElmtId(m10); } aboutToBeDeleted() { this.__textAlign.aboutToBeDeleted(); + this.__fontColorWithTheme.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - setController(j9) { - this.controller = j9; + setController(l10) { + this.controller = l10; } get textAlign() { return this.__textAlign.get(); } - set textAlign(i9) { - this.__textAlign.set(i9); + set textAlign(k10) { + this.__textAlign.set(k10); + } + get fontColorWithTheme() { + return this.__fontColorWithTheme.get(); + } + set fontColorWithTheme(j10) { + this.__fontColorWithTheme.set(j10); } initialRender() { + this.observeComponentCreation2((h10, i10) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); { - this.observeComponentCreation2((c9, d9) => { - if (d9) { - let e9 = new CustomDialogComponent(this, { + this.observeComponentCreation2((b10, c10) => { + if (c10) { + let d10 = new CustomDialogComponent(this, { primaryTitle: this.primaryTitle, secondaryTitle: this.secondaryTitle, controller: this.controller, @@ -1362,9 +1567,11 @@ export class AlertDialog extends ViewPU { this.AlertDialogContentBuilder(); }, buttons: this.buttons, - }, undefined, c9, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 58 }); - ViewPU.create(e9); - let f9 = () => { + theme: this.theme, + }, undefined, b10, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 568, col: 7 }); + ViewPU.create(d10); + let e10 = () => { return { primaryTitle: this.primaryTitle, secondaryTitle: this.secondaryTitle, @@ -1372,43 +1579,60 @@ export class AlertDialog extends ViewPU { contentBuilder: () => { this.AlertDialogContentBuilder(); }, - buttons: this.buttons + buttons: this.buttons, + theme: this.theme, }; }; - e9.paramsGenerator_ = f9; + d10.paramsGenerator_ = e10; } else { - this.updateStateVarsOfChildByElmtId(c9, {}); + this.updateStateVarsOfChildByElmtId(b10, {}); } }, { name: 'CustomDialogComponent' }); } + WithTheme.pop(); } - AlertDialogContentBuilder(o8 = null) { - this.observeComponentCreation2((z8, a9) => { + AlertDialogContentBuilder(k9 = null) { + this.observeComponentCreation2((x9, y9) => { Column.create(); Column.margin({ right: `${this.getMargin()}vp`, }); }, Column); - this.observeComponentCreation2((x8, y8) => { + this.observeComponentCreation2((v9, w9) => { Scroll.create(this.contentScroller); Scroll.width('100%'); }, Scroll); - this.observeComponentCreation2((s8, t8) => { + this.observeComponentCreation2((o9, p9) => { Text.create(this.content); Text.focusable(true); Text.defaultFocus(!(this.primaryButton || this.secondaryButton)); - Text.fontSize({ id: -1, type: 10002, params: ['sys.float.Body_L'], bundleName: '', moduleName: '' }); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(this.getFontWeight()); - Text.fontColor({ id: -1, type: 10001, params: ['sys.color.font_primary'], bundleName: '', moduleName: '' }); - Text.margin({ right: { id: -1, type: 10002, params: ['sys.float.padding_level8'], bundleName: '', moduleName: '' }, }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); + Text.margin({ + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level8'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + }); Text.width(`calc(100% - ${getNumberByResource('padding_level8')}vp)`); Text.textAlign(this.textAlign); - Text.onAreaChange((v8, w8) => { - this.getTextAlign(Number(w8.width)); + Text.key('advanced_alertDialog_content'); + Text.onAreaChange((t9, u9) => { + this.getTextAlign(Number(u9.width)); }); - Text.onKeyEvent((y8) => { - if (y8) { - resolveKeyEvent(y8, this.contentScroller); - } + Text.onKeyEvent((s9) => { + if (s9) { + resolveKeyEvent(s9, this.contentScroller); + } }); }, Text); Text.pop(); @@ -1416,25 +1640,45 @@ export class AlertDialog extends ViewPU { Column.pop(); } aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; this.initButtons(); } - getTextAlign(l8) { - let m8 = measure.measureTextSize({ + getTextAlign(h9) { + let i9 = measure.measureTextSize({ textContent: this.content, - fontSize: { id: -1, type: 10002, params: ['sys.float.Body_L'], bundleName: '', moduleName: '' }, - constraintWidth: l8, + fontSize: { + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + constraintWidth: h9, }); - let n8 = measure.measureTextSize({ + let j9 = measure.measureTextSize({ textContent: this.content, - fontSize: { id: -1, type: 10002, params: ['sys.float.Body_L'], bundleName: '', moduleName: '' }, + fontSize: { + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); - if (this.getTextHeight(m8) <= this.getTextHeight(n8)) { + if (this.getTextHeight(i9) <= this.getTextHeight(j9)) { this.textAlign = TextAlign.Center; } } - getTextHeight(k8) { - if (k8 && k8.height !== null && k8.height !== undefined) { - return Number(k8.height); + getTextHeight(g9) { + if (g9 && g9.height !== null && g9.height !== undefined) { + return Number(g9.height); } return 0; } @@ -1463,15 +1707,11 @@ export class AlertDialog extends ViewPU { this.updateDirtyElements(); } } - -if (!('finalizeConstruction' in ViewPU.prototype)) { - Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { }); -} export class CustomContentDialog extends ViewPU { - constructor(e8, f8, g8, h8 = -1, i8 = undefined, j8) { - super(e8, g8, h8, j8); - if (typeof i8 === 'function') { - this.paramsGenerator_ = i8; + constructor(a9, b9, c9, d9 = -1, e9 = undefined, f9) { + super(a9, c9, d9, f9); + if (typeof e9 === 'function') { + this.paramsGenerator_ = e9; } this.controller = undefined; this.primaryTitle = undefined; @@ -1479,45 +1719,52 @@ export class CustomContentDialog extends ViewPU { this.contentBuilder = undefined; this.contentAreaPadding = undefined; this.buttons = undefined; - this.setInitiallyProvidedValue(f8); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(b9); this.finalizeConstruction(); } - setInitiallyProvidedValue(d8) { - if (d8.controller !== undefined) { - this.controller = d8.controller; + setInitiallyProvidedValue(z8) { + if (z8.controller !== undefined) { + this.controller = z8.controller; + } + if (z8.primaryTitle !== undefined) { + this.primaryTitle = z8.primaryTitle; } - if (d8.primaryTitle !== undefined) { - this.primaryTitle = d8.primaryTitle; + if (z8.secondaryTitle !== undefined) { + this.secondaryTitle = z8.secondaryTitle; } - if (d8.secondaryTitle !== undefined) { - this.secondaryTitle = d8.secondaryTitle; + if (z8.contentBuilder !== undefined) { + this.contentBuilder = z8.contentBuilder; } - if (d8.contentBuilder !== undefined) { - this.contentBuilder = d8.contentBuilder; + if (z8.contentAreaPadding !== undefined) { + this.contentAreaPadding = z8.contentAreaPadding; } - if (d8.contentAreaPadding !== undefined) { - this.contentAreaPadding = d8.contentAreaPadding; + if (z8.buttons !== undefined) { + this.buttons = z8.buttons; } - if (d8.buttons !== undefined) { - this.buttons = d8.buttons; + if (z8.theme !== undefined) { + this.theme = z8.theme; } } - updateStateVars(c8) { + updateStateVars(y8) { } - purgeVariableDependenciesOnElmtId(b8) { + purgeVariableDependenciesOnElmtId(x8) { } aboutToBeDeleted() { SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - setController(a8) { - this.controller = a8; + setController(w8) { + this.controller = w8; } initialRender() { + this.observeComponentCreation2((u8, v8) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); { - this.observeComponentCreation2((u7, v7) => { - if (v7) { - let w7 = new CustomDialogContentComponent(this, { + this.observeComponentCreation2((o8, p8) => { + if (p8) { + let q8 = new CustomDialogContentComponent(this, { controller: this.controller, primaryTitle: this.primaryTitle, secondaryTitle: this.secondaryTitle, @@ -1526,9 +1773,11 @@ export class CustomContentDialog extends ViewPU { }, contentAreaPadding: this.contentAreaPadding, buttons: this.buttons, - }, undefined, u7, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 151 }); - ViewPU.create(w7); - let x7 = () => { + theme: this.theme, + }, undefined, o8, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 674, col: 7 }); + ViewPU.create(q8); + let r8 = () => { return { controller: this.controller, primaryTitle: this.primaryTitle, @@ -1537,26 +1786,28 @@ export class CustomContentDialog extends ViewPU { this.contentBuilder(); }, contentAreaPadding: this.contentAreaPadding, - buttons: this.buttons + buttons: this.buttons, + theme: this.theme, }; }; - w7.paramsGenerator_ = x7; + q8.paramsGenerator_ = r8; } else { - this.updateStateVarsOfChildByElmtId(u7, {}); + this.updateStateVarsOfChildByElmtId(o8, {}); } }, { name: 'CustomDialogContentComponent' }); } + WithTheme.pop(); } rerender() { this.updateDirtyElements(); } } class CustomDialogContentComponent extends ViewPU { - constructor(n7, o7, p7, q7 = -1, r7 = undefined, s7) { - super(n7, p7, q7, s7); - if (typeof r7 === 'function') { - this.paramsGenerator_ = r7; + constructor(g8, h8, i8, j8 = -1, k8 = undefined, l8) { + super(g8, i8, j8, l8); + if (typeof k8 === 'function') { + this.paramsGenerator_ = k8; } this.controller = undefined; this.primaryTitle = undefined; @@ -1565,65 +1816,144 @@ class CustomDialogContentComponent extends ViewPU { this.buttons = undefined; this.contentAreaPadding = undefined; this.keyIndex = 0; + this.__primaryFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'primaryFontColorWithTheme'); + this.__secondaryFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'secondaryFontColorWithTheme'); + this.__buttonFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'buttonFontColorWithTheme'); + this.__errorButtonFontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'errorButtonFontColorWithTheme'); + this.theme = new CustomThemeImpl({}); this.titleHeight = 0; this.__contentMaxHeight = new ObservedPropertySimplePU('', this, 'contentMaxHeight'); - this.setInitiallyProvidedValue(o7); + this.setInitiallyProvidedValue(h8); this.finalizeConstruction(); } - setInitiallyProvidedValue(m7) { - if (m7.controller !== undefined) { - this.controller = m7.controller; + setInitiallyProvidedValue(f8) { + if (f8.controller !== undefined) { + this.controller = f8.controller; + } + if (f8.primaryTitle !== undefined) { + this.primaryTitle = f8.primaryTitle; + } + if (f8.secondaryTitle !== undefined) { + this.secondaryTitle = f8.secondaryTitle; } - if (m7.primaryTitle !== undefined) { - this.primaryTitle = m7.primaryTitle; + if (f8.contentBuilder !== undefined) { + this.contentBuilder = f8.contentBuilder; } - if (m7.secondaryTitle !== undefined) { - this.secondaryTitle = m7.secondaryTitle; + if (f8.buttons !== undefined) { + this.buttons = f8.buttons; } - if (m7.contentBuilder !== undefined) { - this.contentBuilder = m7.contentBuilder; + if (f8.contentAreaPadding !== undefined) { + this.contentAreaPadding = f8.contentAreaPadding; } - if (m7.buttons !== undefined) { - this.buttons = m7.buttons; + if (f8.keyIndex !== undefined) { + this.keyIndex = f8.keyIndex; } - if (m7.contentAreaPadding !== undefined) { - this.contentAreaPadding = m7.contentAreaPadding; + if (f8.primaryFontColorWithTheme !== undefined) { + this.primaryFontColorWithTheme = f8.primaryFontColorWithTheme; } - if (m7.keyIndex !== undefined) { - this.keyIndex = m7.keyIndex; + if (f8.secondaryFontColorWithTheme !== undefined) { + this.secondaryFontColorWithTheme = f8.secondaryFontColorWithTheme; } - if (m7.titleHeight !== undefined) { - this.titleHeight = m7.titleHeight; + if (f8.buttonFontColorWithTheme !== undefined) { + this.buttonFontColorWithTheme = f8.buttonFontColorWithTheme; } - if (m7.contentMaxHeight !== undefined) { - this.contentMaxHeight = m7.contentMaxHeight; + if (f8.errorButtonFontColorWithTheme !== undefined) { + this.errorButtonFontColorWithTheme = f8.errorButtonFontColorWithTheme; + } + if (f8.theme !== undefined) { + this.theme = f8.theme; + } + if (f8.titleHeight !== undefined) { + this.titleHeight = f8.titleHeight; + } + if (f8.contentMaxHeight !== undefined) { + this.contentMaxHeight = f8.contentMaxHeight; } } - updateStateVars(l7) { + updateStateVars(e8) { } - purgeVariableDependenciesOnElmtId(k7) { - this.__contentMaxHeight.purgeDependencyOnElmtId(k7); + purgeVariableDependenciesOnElmtId(d8) { + this.__primaryFontColorWithTheme.purgeDependencyOnElmtId(d8); + this.__secondaryFontColorWithTheme.purgeDependencyOnElmtId(d8); + this.__buttonFontColorWithTheme.purgeDependencyOnElmtId(d8); + this.__errorButtonFontColorWithTheme.purgeDependencyOnElmtId(d8); + this.__contentMaxHeight.purgeDependencyOnElmtId(d8); } aboutToBeDeleted() { + this.__primaryFontColorWithTheme.aboutToBeDeleted(); + this.__secondaryFontColorWithTheme.aboutToBeDeleted(); + this.__buttonFontColorWithTheme.aboutToBeDeleted(); + this.__errorButtonFontColorWithTheme.aboutToBeDeleted(); this.__contentMaxHeight.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - defaultContentBuilder(j7 = null) { + get primaryFontColorWithTheme() { + return this.__primaryFontColorWithTheme.get(); + } + set primaryFontColorWithTheme(c8) { + this.__primaryFontColorWithTheme.set(c8); + } + get secondaryFontColorWithTheme() { + return this.__secondaryFontColorWithTheme.get(); + } + set secondaryFontColorWithTheme(b8) { + this.__secondaryFontColorWithTheme.set(b8); + } + get buttonFontColorWithTheme() { + return this.__buttonFontColorWithTheme.get(); + } + set buttonFontColorWithTheme(a8) { + this.__buttonFontColorWithTheme.set(a8); + } + get errorButtonFontColorWithTheme() { + return this.__errorButtonFontColorWithTheme.get(); + } + set errorButtonFontColorWithTheme(z7) { + this.__errorButtonFontColorWithTheme.set(z7); + } + defaultContentBuilder(y7 = null) { } get contentMaxHeight() { return this.__contentMaxHeight.get(); } - set contentMaxHeight(i7) { - this.__contentMaxHeight.set(i7); + set contentMaxHeight(x7) { + this.__contentMaxHeight.set(x7); } initialRender() { - this.observeComponentCreation2((g7, h7) => { + this.observeComponentCreation2((v7, w7) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); + this.observeComponentCreation2((t7, u7) => { Column.create(); Column.width('100%'); }, Column); this.buildTitles.bind(this)(); - this.observeComponentCreation2((e7, f7) => { + this.observeComponentCreation2((r7, s7) => { Column.create(); Column.padding(this.getContentPadding()); Column.constraintSize({ maxHeight: this.contentMaxHeight, }); @@ -1632,9 +1962,10 @@ class CustomDialogContentComponent extends ViewPU { Column.pop(); this.buildButtons.bind(this)(); Column.pop(); + WithTheme.pop(); } - buildTitles(y5 = null) { - this.observeComponentCreation2((x6, y6) => { + buildTitles(k6 = null) { + this.observeComponentCreation2((j7, k7) => { Column.create(); Column.constraintSize({ minHeight: this.getTitleAreaMinHeight(), @@ -1642,39 +1973,58 @@ class CustomDialogContentComponent extends ViewPU { Column.justifyContent(FlexAlign.Center); Column.width('100%'); Column.padding(this.getTitleAreaPadding()); - Column.onAreaChange((a7, b7) => { - this.titleHeight = Number(b7.height); + Column.onAreaChange((m7, n7) => { + this.titleHeight = Number(n7.height); this.contentMaxHeight = `calc(100% - ${this.titleHeight}vp - ${this.getButtonsHeight()}vp)`; }); }, Column); - this.observeComponentCreation2((v6, w6) => { + this.observeComponentCreation2((h7, i7) => { Row.create(); Row.width('100%'); }, Row); - this.observeComponentCreation2((t6, u6) => { + this.observeComponentCreation2((f7, g7) => { Text.create(this.primaryTitle); Text.fontWeight(FontWeight.Bold); - Text.fontColor({ id: -1, type: 10001, params: ['sys.color.font_primary'], bundleName: '', moduleName: '' }); + Text.fontColor(ObservedObject.GetRawObject(this.primaryFontColorWithTheme)); Text.textAlign(this.getTitleTextAlign()); - Text.maxFontSize({ id: -1, type: 10002, params: ['sys.float.Title_S'], bundleName: '', moduleName: '' }); - Text.minFontSize({ id: -1, type: 10002, params: ['sys.float.Body_L'], bundleName: '', moduleName: '' }); + Text.maxFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Title_S'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Text.minFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.maxLines(TITLE_MAX_LINES); Text.heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); Text.width('100%'); + Text.key('advanced_dialog_primaryTitle'); }, Text); Text.pop(); Row.pop(); - this.observeComponentCreation2((j6, k6) => { + this.observeComponentCreation2((v6, w6) => { If.create(); if (this.primaryTitle && this.secondaryTitle) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((r6, s6) => { + this.observeComponentCreation2((d7, e7) => { Row.create(); }, Row); - this.observeComponentCreation2((p6, q6) => { + this.observeComponentCreation2((b7, c7) => { Divider.create(); - Divider.margin({ id: -1, type: 10002, params: ['sys.float.padding_level1'], bundleName: '', moduleName: '' }); + Divider.margin({ + 'id': -1, + 'type': 10002, + params: ['sys.float.padding_level1'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Divider.color(Color.Transparent); }, Divider); Row.pop(); @@ -1686,28 +2036,41 @@ class CustomDialogContentComponent extends ViewPU { } }, If); If.pop(); - this.observeComponentCreation2((h6, i6) => { + this.observeComponentCreation2((t6, u6) => { Row.create(); Row.width('100%'); }, Row); - this.observeComponentCreation2((f6, g6) => { + this.observeComponentCreation2((r6, s6) => { Text.create(this.secondaryTitle); Text.fontWeight(FontWeight.Regular); - Text.fontColor({ id: -1, type: 10001, params: ['sys.color.font_secondary'], bundleName: '', moduleName: '' }); + Text.fontColor(ObservedObject.GetRawObject(this.secondaryFontColorWithTheme)); Text.textAlign(this.getTitleTextAlign()); - Text.maxFontSize({ id: -1, type: 10002, params: ['sys.float.Subtitle_S'], bundleName: '', moduleName: '' }); - Text.minFontSize({ id: -1, type: 10002, params: ['sys.float.Body_S'], bundleName: '', moduleName: '' }); + Text.maxFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Subtitle_S'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Text.minFontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_S'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.maxLines(TITLE_MAX_LINES); Text.heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); Text.width('100%'); + Text.key('advanced_dialog_secondaryTitle'); }, Text); Text.pop(); Row.pop(); Column.pop(); } - buildButtons(u5 = null) { - this.observeComponentCreation2((w5, x5) => { + buildButtons(g6 = null) { + this.observeComponentCreation2((i6, j6) => { Column.create(); Column.width('100%'); Column.padding(this.getOperationAreaPadding()); @@ -1716,49 +2079,62 @@ class CustomDialogContentComponent extends ViewPU { this.buildVerticalAlignButtons.bind(this)(); Column.pop(); } - buildSingleButton(z4, a5 = null) { - this.observeComponentCreation2((c5, d5) => { + buildSingleButton(h5, i5 = null) { + this.observeComponentCreation2((k5, l5) => { If.create(); - if (this.isNewPropertiesHighPriority(z4)) { + if (this.isNewPropertiesHighPriority(h5)) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((s5, t5) => { - Button.createWithLabel(z4.value); - __Button__setButtonProperties(z4, this.controller); - Button.role(z4.role ?? ButtonRole.NORMAL); + this.observeComponentCreation2((e6, f6) => { + Button.createWithLabel(h5.value); + __Button__setButtonProperties(h5, this.controller); + Button.role(h5.role ?? ButtonRole.NORMAL); Button.key(`advanced_dialog_button_${this.keyIndex++}`); }, Button); Button.pop(); }); } - else if (z4.background !== undefined && z4.fontColor !== undefined) { + else if (h5.background !== undefined && h5.fontColor !== undefined) { this.ifElseBranchUpdateFunction(1, () => { - this.observeComponentCreation2((o5, p5) => { - Button.createWithLabel(z4.value); - __Button__setButtonProperties(z4, this.controller); - Button.backgroundColor(z4.background); - Button.fontColor(z4.fontColor); + this.observeComponentCreation2((a6, b6) => { + Button.createWithLabel(h5.value); + __Button__setButtonProperties(h5, this.controller); + Button.backgroundColor(h5.background); + Button.fontColor(h5.fontColor); Button.key(`advanced_dialog_button_${this.keyIndex++}`); }, Button); Button.pop(); }); } - else if (z4.background !== undefined) { + else if (h5.background !== undefined) { this.ifElseBranchUpdateFunction(2, () => { - this.observeComponentCreation2((k5, l5) => { - Button.createWithLabel(z4.value); - __Button__setButtonProperties(z4, this.controller); - Button.backgroundColor(z4.background); + this.observeComponentCreation2((w5, x5) => { + Button.createWithLabel(h5.value); + __Button__setButtonProperties(h5, this.controller); + Button.backgroundColor(h5.background); Button.key(`advanced_dialog_button_${this.keyIndex++}`); }, Button); Button.pop(); }); } - else { + else if (h5.background !== undefined && h5.fontColor === undefined || '') { this.ifElseBranchUpdateFunction(3, () => { - this.observeComponentCreation2((g5, h5) => { - Button.createWithLabel(z4.value); - __Button__setButtonProperties(z4, this.controller); - Button.fontColor(z4.fontColor); + this.observeComponentCreation2((s5, t5) => { + Button.createWithLabel(h5.value); + __Button__setButtonProperties(h5, this.controller); + Button.backgroundColor(h5.background); + Button.fontColor(h5.role === ButtonRole.ERROR ? + this.errorButtonFontColorWithTheme : this.buttonFontColorWithTheme); + Button.key(`advanced_dialog_button_${this.keyIndex++}`); + }, Button); + Button.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(4, () => { + this.observeComponentCreation2((o5, p5) => { + Button.createWithLabel(h5.value); + __Button__setButtonProperties(h5, this.controller); + Button.fontColor(h5.fontColor); Button.key(`advanced_dialog_button_${this.keyIndex++}`); }, Button); Button.pop(); @@ -1767,28 +2143,58 @@ class CustomDialogContentComponent extends ViewPU { }, If); If.pop(); } - buildHorizontalAlignButtons(i4 = null) { - this.observeComponentCreation2((k4, l4) => { + buildHorizontalAlignButtons(q4 = null) { + this.observeComponentCreation2((s4, t4) => { If.create(); if (this.buttons && this.buttons.length > 0 && this.buttons.length <= HORIZON_BUTTON_MAX_COUNT) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((x4, y4) => { + this.observeComponentCreation2((f5, g5) => { Row.create(); }, Row); this.buildSingleButton.bind(this)(this.buttons[0]); - this.observeComponentCreation2((q4, r4) => { + this.observeComponentCreation2((y4, z4) => { If.create(); if (this.buttons.length === HORIZON_BUTTON_MAX_COUNT) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((v4, w4) => { + this.observeComponentCreation2((d5, e5) => { Divider.create(); - Divider.width({ id: -1, type: 10002, params: ['sys.float.alert_divider_width'], bundleName: '', moduleName: '' }); - Divider.height({ id: -1, type: 10002, params: ['sys.float.alert_divider_height'], bundleName: '', moduleName: '' }); - Divider.color({ id: -1, type: 10001, params: ['sys.color.alert_divider_color'], bundleName: '', moduleName: '' }); + Divider.width({ + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_divider_width'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Divider.height({ + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_divider_height'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + Divider.color({ + 'id': -1, + 'type': 10001, + params: ['sys.color.alert_divider_color'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Divider.vertical(true); Divider.margin({ - left: { id: -1, type: 10002, params: ['sys.float.alert_button_horizontal_space'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_button_horizontal_space'], bundleName: '', moduleName: '' }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_horizontal_space'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_horizontal_space'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }); }, Divider); this.buildSingleButton.bind(this)(this.buttons[HORIZON_BUTTON_MAX_COUNT - 1]); @@ -1810,21 +2216,22 @@ class CustomDialogContentComponent extends ViewPU { }, If); If.pop(); } - buildVerticalAlignButtons(p3 = null) { - this.observeComponentCreation2((r3, s3) => { + buildVerticalAlignButtons(x3 = null) { + this.observeComponentCreation2((z3, a4) => { If.create(); if (this.buttons && this.isVerticalAlignButton()) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((g4, h4) => { + this.observeComponentCreation2((o4, p4) => { Column.create(); }, Column); - this.observeComponentCreation2((x3, y3) => { + this.observeComponentCreation2((f4, g4) => { ForEach.create(); - const z3 = (d4, e4) => { - const f4 = d4; - this.buildButtonWithDivider.bind(this)(e4); + const h4 = (l4, m4) => { + const n4 = l4; + this.buildButtonWithDivider.bind(this)(m4); }; - this.forEachUpdateFunction(x3, this.buttons.slice(0, VERTICAL_BUTTON_MAX_COUNT), z3, (c4) => c4.value.toString(), true, false); + this.forEachUpdateFunction(f4, this.buttons.slice(0, VERTICAL_BUTTON_MAX_COUNT), h4, + (k4) => k4.value.toString(), true, false); }, ForEach); ForEach.pop(); Column.pop(); @@ -1837,23 +2244,29 @@ class CustomDialogContentComponent extends ViewPU { }, If); If.pop(); } - buildButtonWithDivider(x2, y2 = null) { - this.observeComponentCreation2((a3, b3) => { + buildButtonWithDivider(f3, g3 = null) { + this.observeComponentCreation2((i3, j3) => { If.create(); - if (this.buttons && this.buttons[x2]) { + if (this.buttons && this.buttons[f3]) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((n3, o3) => { + this.observeComponentCreation2((v3, w3) => { Row.create(); }, Row); - this.buildSingleButton.bind(this)(this.buttons[x2]); + this.buildSingleButton.bind(this)(this.buttons[f3]); Row.pop(); - this.observeComponentCreation2((g3, h3) => { + this.observeComponentCreation2((o3, p3) => { If.create(); - if (x2 < Math.min(this.buttons.length, VERTICAL_BUTTON_MAX_COUNT) - 1) { + if (f3 < Math.min(this.buttons.length, VERTICAL_BUTTON_MAX_COUNT) - 1) { this.ifElseBranchUpdateFunction(0, () => { - this.observeComponentCreation2((l3, m3) => { + this.observeComponentCreation2((t3, u3) => { Row.create(); - Row.height({ id: -1, type: 10002, params: ['sys.float.alert_button_vertical_space'], bundleName: '', moduleName: '' }); + Row.height({ + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_vertical_space'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); }, Row); Row.pop(); }); @@ -1881,22 +2294,54 @@ class CustomDialogContentComponent extends ViewPU { this.titleHeight = getNumberByResource('alert_title_secondary_height'); } this.contentMaxHeight = `calc(100% - ${this.titleHeight}vp - ${this.getButtonsHeight()}vp)`; + this.primaryFontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.secondaryFontColorWithTheme = this.theme.colors?.fontSecondary ? + this.theme.colors.fontSecondary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.buttonFontColorWithTheme = this.theme.colors?.fontEmphasize ? + this.theme.colors.fontEmphasize : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.errorButtonFontColorWithTheme = this.theme.colors?.warning ? + this.theme.colors.warning : { + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_text_primary_activated'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; } getButtonsHeight() { if (!this.buttons || this.buttons.length === 0) { return 0; } - let w2 = getNumberByResource('alert_button_top_padding'); + let d3 = getNumberByResource('alert_button_top_padding'); if (this.buttons.length <= HORIZON_BUTTON_MAX_COUNT) { - w2 += BUTTON_DEFAULT_HEIGHT + - getNumberByResource('alert_button_bottom_padding_horizontal'); + d3 += BUTTON_DEFAULT_HEIGHT + + getNumberByResource('alert_button_bottom_padding_horizontal'); } else { - w2 += BUTTON_DEFAULT_HEIGHT * this.buttons.length + + d3 += BUTTON_DEFAULT_HEIGHT * this.buttons.length + (this.buttons.length - 1) * getNumberByResource('alert_button_vertical_space') + - getNumberByResource('alert_button_bottom_padding_vertical'); + getNumberByResource('alert_button_bottom_padding_vertical'); } - return w2; + return d3; } getContentPadding() { if (this.contentAreaPadding) { @@ -1905,42 +2350,126 @@ class CustomDialogContentComponent extends ViewPU { if ((this.primaryTitle || this.secondaryTitle) && this.buttons && this.buttons.length > 0) { return { top: 0, - right: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, bottom: 0, - left: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } else if (this.primaryTitle || this.secondaryTitle) { return { top: 0, - right: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } else if (this.buttons && this.buttons.length > 0) { return { - top: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, bottom: 0, - left: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } else { return { - top: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_content_default_padding'], bundleName: '', moduleName: '' }, + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_content_default_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } } getTitleAreaMinHeight() { if (this.secondaryTitle) { - return { id: -1, type: 10002, params: ['sys.float.alert_title_secondary_height'], bundleName: '', moduleName: '' }; + return { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_secondary_height'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; } else if (this.primaryTitle) { - return { id: -1, type: 10002, params: ['sys.float.alert_title_primary_height'], bundleName: '', moduleName: '' }; + return { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_primary_height'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; } else { return 0; @@ -1949,16 +2478,52 @@ class CustomDialogContentComponent extends ViewPU { getTitleAreaPadding() { if (this.primaryTitle || this.secondaryTitle) { return { - top: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_top'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_right'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_left'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_bottom'], bundleName: '', moduleName: '' }, + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_top'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_right'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_left'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_bottom'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } return { top: 0, - right: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_right'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_title_padding_left'], bundleName: '', moduleName: '' }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_right'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_title_padding_left'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, bottom: 0, }; } @@ -1971,44 +2536,92 @@ class CustomDialogContentComponent extends ViewPU { getOperationAreaPadding() { if (this.isVerticalAlignButton()) { return { - top: { id: -1, type: 10002, params: ['sys.float.alert_button_top_padding'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_right_padding_vertical'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_left_padding_vertical'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.alert_button_bottom_padding_vertical'], bundleName: '', moduleName: '' }, + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_top_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_right_padding_vertical'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_left_padding_vertical'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_bottom_padding_vertical'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } return { - top: { id: -1, type: 10002, params: ['sys.float.alert_button_top_padding'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.alert_right_padding_horizontal'], bundleName: '', moduleName: '' }, - left: { id: -1, type: 10002, params: ['sys.float.alert_left_padding_horizontal'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.alert_button_bottom_padding_horizontal'], bundleName: '', moduleName: '' }, + top: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_top_padding'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_right_padding_horizontal'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_left_padding_horizontal'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.alert_button_bottom_padding_horizontal'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, }; } - isNewPropertiesHighPriority(v2) { - if (v2.role === ButtonRole.ERROR) { + isNewPropertiesHighPriority(c3) { + if (c3.role === ButtonRole.ERROR) { return true; } - if (v2.buttonStyle !== undefined && - v2.buttonStyle !== getNumberByResource('alert_button_style')) { + if (c3.buttonStyle !== undefined && + c3.buttonStyle !== getNumberByResource('alert_button_style')) { return true; } - if (v2.background === undefined && v2.fontColor === undefined) { + if (c3.background === undefined && c3.fontColor === undefined) { return true; } return false; } getTitleTextAlign() { - let u2 = getEnumNumberByResource('alert_title_alignment'); - if (u2 === TextAlign.Start) { + let b3 = getEnumNumberByResource('alert_title_alignment'); + if (b3 === TextAlign.Start) { return TextAlign.Start; } - else if (u2 === TextAlign.Center) { + else if (b3 === TextAlign.Center) { return TextAlign.Center; } - else if (u2 === TextAlign.End) { + else if (b3 === TextAlign.End) { return TextAlign.End; } - else if (u2 === TextAlign.JUSTIFY) { + else if (b3 === TextAlign.JUSTIFY) { return TextAlign.JUSTIFY; } else { @@ -2020,10 +2633,10 @@ class CustomDialogContentComponent extends ViewPU { } } export class CustomDialogComponent extends ViewPU { - constructor(o2, p2, q2, r2 = -1, s2 = undefined, t2) { - super(o2, q2, r2, t2); - if (typeof s2 === 'function') { - this.paramsGenerator_ = s2; + constructor(v2, w2, x2, y2 = -1, z2 = undefined, a3) { + super(v2, x2, y2, a3); + if (typeof z2 === 'function') { + this.paramsGenerator_ = z2; } this.controller = undefined; this.primaryTitle = undefined; @@ -2034,42 +2647,46 @@ export class CustomDialogComponent extends ViewPU { this.screenWidth = 0; this.__columnModifier = new ObservedPropertyObjectPU(new ColumnModifier(), this, 'columnModifier'); this.isFirstInit = true; - this.setInitiallyProvidedValue(p2); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(w2); this.finalizeConstruction(); } - setInitiallyProvidedValue(n2) { - if (n2.controller !== undefined) { - this.controller = n2.controller; + setInitiallyProvidedValue(u2) { + if (u2.controller !== undefined) { + this.controller = u2.controller; + } + if (u2.primaryTitle !== undefined) { + this.primaryTitle = u2.primaryTitle; } - if (n2.primaryTitle !== undefined) { - this.primaryTitle = n2.primaryTitle; + if (u2.secondaryTitle !== undefined) { + this.secondaryTitle = u2.secondaryTitle; } - if (n2.secondaryTitle !== undefined) { - this.secondaryTitle = n2.secondaryTitle; + if (u2.contentBuilder !== undefined) { + this.contentBuilder = u2.contentBuilder; } - if (n2.contentBuilder !== undefined) { - this.contentBuilder = n2.contentBuilder; + if (u2.buttons !== undefined) { + this.buttons = u2.buttons; } - if (n2.buttons !== undefined) { - this.buttons = n2.buttons; + if (u2.contentAreaPadding !== undefined) { + this.contentAreaPadding = u2.contentAreaPadding; } - if (n2.contentAreaPadding !== undefined) { - this.contentAreaPadding = n2.contentAreaPadding; + if (u2.screenWidth !== undefined) { + this.screenWidth = u2.screenWidth; } - if (n2.screenWidth !== undefined) { - this.screenWidth = n2.screenWidth; + if (u2.columnModifier !== undefined) { + this.columnModifier = u2.columnModifier; } - if (n2.columnModifier !== undefined) { - this.columnModifier = n2.columnModifier; + if (u2.isFirstInit !== undefined) { + this.isFirstInit = u2.isFirstInit; } - if (n2.isFirstInit !== undefined) { - this.isFirstInit = n2.isFirstInit; + if (u2.theme !== undefined) { + this.theme = u2.theme; } } - updateStateVars(m2) { + updateStateVars(t2) { } - purgeVariableDependenciesOnElmtId(l2) { - this.__columnModifier.purgeDependencyOnElmtId(l2); + purgeVariableDependenciesOnElmtId(s2) { + this.__columnModifier.purgeDependencyOnElmtId(s2); } aboutToBeDeleted() { this.__columnModifier.aboutToBeDeleted(); @@ -2079,33 +2696,33 @@ export class CustomDialogComponent extends ViewPU { get columnModifier() { return this.__columnModifier.get(); } - set columnModifier(k2) { - this.__columnModifier.set(k2); + set columnModifier(r2) { + this.__columnModifier.set(r2); } initialRender() { - this.observeComponentCreation2((f2, g2) => { + this.observeComponentCreation2((m2, n2) => { Column.create(); - Column.onAreaChange((i2, j2) => { + Column.onAreaChange((p2, q2) => { if (!this.isFirstInit) { return; } if (this.screenWidth > getNumberByResource('alert_container_max_width')) { - this.columnModifier.customStyle = j2.width > getNumberByResource('alert_container_max_width'); + this.columnModifier.customStyle = q2.width > getNumberByResource('alert_container_max_width'); } else { - this.columnModifier.customStyle = j2.width >= this.screenWidth; + this.columnModifier.customStyle = q2.width >= this.screenWidth; } this.isFirstInit = false; }); }, Column); - this.observeComponentCreation2((d2, e2) => { + this.observeComponentCreation2((k2, l2) => { Column.create(); Column.attributeModifier.bind(this)(ObservedObject.GetRawObject(this.columnModifier)); }, Column); { - this.observeComponentCreation2((x1, y1) => { - if (y1) { - let z1 = new CustomDialogContentComponent(this, { + this.observeComponentCreation2((e2, f2) => { + if (f2) { + let g2 = new CustomDialogContentComponent(this, { controller: this.controller, primaryTitle: this.primaryTitle, secondaryTitle: this.secondaryTitle, @@ -2114,9 +2731,11 @@ export class CustomDialogComponent extends ViewPU { }, buttons: this.buttons, contentAreaPadding: this.contentAreaPadding, - }, undefined, x1, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 519 }); - ViewPU.create(z1); - let a2 = () => { + theme: this.theme, + }, undefined, e2, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 1084, col: 9 }); + ViewPU.create(g2); + let h2 = () => { return { controller: this.controller, primaryTitle: this.primaryTitle, @@ -2125,13 +2744,14 @@ export class CustomDialogComponent extends ViewPU { this.contentBuilder(); }, buttons: this.buttons, - contentAreaPadding: this.contentAreaPadding + contentAreaPadding: this.contentAreaPadding, + theme: this.theme, }; }; - z1.paramsGenerator_ = a2; + g2.paramsGenerator_ = h2; } else { - this.updateStateVarsOfChildByElmtId(x1, {}); + this.updateStateVarsOfChildByElmtId(e2, {}); } }, { name: 'CustomDialogContentComponent' }); } @@ -2142,8 +2762,8 @@ export class CustomDialogComponent extends ViewPU { try { this.screenWidth = px2vp(display.getDefaultDisplaySync().width); } - catch (t1) { - hilog.error(0x3900, 'Ace', `CustomDialogComponent getDefaultDisplaySync error: ${JSON.stringify(t1)}`); + catch (a2) { + hilog.error(0x3900, 'Ace', `CustomDialogComponent getDefaultDisplaySync error: ${JSON.stringify(a2)}`); } } rerender() { @@ -2154,189 +2774,265 @@ class ColumnModifier { constructor() { this.customStyle = false; } - applyNormalAttribute(s1) { + applyNormalAttribute(z1) { if (!this.customStyle) { return; } - s1.backgroundBlurStyle(BlurStyle.Thick); - s1.borderRadius({ id: -1, type: 10002, params: ['sys.float.ohos_id_corner_radius_dialog'], bundleName: '', moduleName: '' }); - s1.margin({ - left: { id: -1, type: 10002, params: ['sys.float.ohos_id_dialog_margin_start'], bundleName: '', moduleName: '' }, - right: { id: -1, type: 10002, params: ['sys.float.ohos_id_dialog_margin_end'], bundleName: '', moduleName: '' }, - bottom: { id: -1, type: 10002, params: ['sys.float.ohos_id_dialog_margin_bottom'], bundleName: '', moduleName: '' }, + z1.backgroundBlurStyle(BlurStyle.Thick); + z1.borderRadius({ + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_corner_radius_dialog'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); + z1.margin({ + left: { + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_dialog_margin_start'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + right: { + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_dialog_margin_end'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + bottom: { + 'id': -1, + 'type': 10002, + params: ['sys.float.ohos_id_dialog_margin_bottom'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, + }); + z1.backgroundColor({ + 'id': -1, + 'type': 10001, + params: ['sys.color.ohos_id_color_dialog_bg'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', }); - s1.backgroundColor({ id: -1, type: 10001, params: ['sys.color.ohos_id_color_dialog_bg'], bundleName: '', moduleName: '' }); } } -function __Button__setButtonProperties(p1, q1) { +function __Button__setButtonProperties(w1, x1) { Button.onClick(() => { - if (p1.action) { - p1.action(); + if (w1.action) { + w1.action(); } - q1?.close(); + x1?.close(); }); Button.defaultFocus(true); - Button.buttonStyle(p1.buttonStyle ?? getNumberByResource('alert_button_style')); + Button.buttonStyle(w1.buttonStyle ?? getNumberByResource('alert_button_style')); Button.layoutWeight(BUTTON_LAYOUT_WEIGHT); } -function getNumberByResource(l1) { +function getNumberByResource(s1) { try { - return resourceManager.getSystemResourceManager().getNumberByName(l1); + return resourceManager.getSystemResourceManager().getNumberByName(s1); } - catch (m1) { - let n1 = m1.code; - let o1 = m1.message; - hilog.error(0x3900, 'Ace', `CustomContentDialog getNumberByResource error, code: ${n1}, message: ${o1}`); + catch (t1) { + let u1 = t1.code; + let v1 = t1.message; + hilog.error(0x3900, 'Ace', `CustomContentDialog getNumberByResource error, code: ${u1}, message: ${v1}`); return 0; } } -function getEnumNumberByResource(h1) { +function getEnumNumberByResource(o1) { try { - return getContext().resourceManager.getNumberByName(h1); + return getContext().resourceManager.getNumberByName(o1); } - catch (i1) { - let j1 = i1.code; - let k1 = i1.message; - hilog.error(0x3900, 'Ace', `getEnumNumberByResource error, code: ${j1}, message: ${k1}`); + catch (p1) { + let q1 = p1.code; + let r1 = p1.message; + hilog.error(0x3900, 'Ace', `getEnumNumberByResource error, code: ${q1}, message: ${r1}`); return -1; } } -function resolveKeyEvent(h1, i1) { - if (h1.type == IGNORE_KEY_EVENT_TYPE) { - return; - } - if (h1.keyCode == KEYCODE_UP) { - i1.scrollPage({ next: false }); - h1.stopPropagation(); +function resolveKeyEvent(m1, n1) { + if (m1.type == IGNORE_KEY_EVENT_TYPE) { + return; + } + if (m1.keyCode == KEYCODE_UP) { + n1.scrollPage({ next: false }); + m1.stopPropagation(); + } + else if (m1.keyCode == KEYCODE_DOWN) { + if (n1.isAtEnd()) { + return; } - else if (h1.keyCode == KEYCODE_DOWN) { - if (i1.isAtEnd()) { - return; - } - else { - i1.scrollPage({ next: true }); - h1.stopPropagation(); - } + else { + n1.scrollPage({ next: true }); + m1.stopPropagation(); } + } } export class LoadingDialog extends ViewPU { - constructor(b1, c1, d1, e1 = -1, f1 = undefined, g1) { - super(b1, d1, e1, g1); - if (typeof f1 === 'function') { - this.paramsGenerator_ = f1; + constructor(g1, h1, i1, j1 = -1, k1 = undefined, l1) { + super(g1, i1, j1, l1); + if (typeof k1 === 'function') { + this.paramsGenerator_ = k1; } this.controller = undefined; this.content = ''; - this.setInitiallyProvidedValue(c1); + this.__fontColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'fontColorWithTheme'); + this.__loadingProgressColorWithTheme = new ObservedPropertyObjectPU({ + 'id': -1, + 'type': 10001, + params: ['sys.color.icon_secondary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }, this, 'loadingProgressColorWithTheme'); + this.theme = new CustomThemeImpl({}); + this.setInitiallyProvidedValue(h1); this.finalizeConstruction(); } - setInitiallyProvidedValue(a1) { - if (a1.controller !== undefined) { - this.controller = a1.controller; + setInitiallyProvidedValue(f1) { + if (f1.controller !== undefined) { + this.controller = f1.controller; + } + if (f1.content !== undefined) { + this.content = f1.content; } - if (a1.content !== undefined) { - this.content = a1.content; + if (f1.fontColorWithTheme !== undefined) { + this.fontColorWithTheme = f1.fontColorWithTheme; + } + if (f1.loadingProgressColorWithTheme !== undefined) { + this.loadingProgressColorWithTheme = f1.loadingProgressColorWithTheme; + } + if (f1.theme !== undefined) { + this.theme = f1.theme; } } - updateStateVars(z) { + updateStateVars(e1) { } - purgeVariableDependenciesOnElmtId(y) { + purgeVariableDependenciesOnElmtId(d1) { + this.__fontColorWithTheme.purgeDependencyOnElmtId(d1); + this.__loadingProgressColorWithTheme.purgeDependencyOnElmtId(d1); } aboutToBeDeleted() { + this.__fontColorWithTheme.aboutToBeDeleted(); + this.__loadingProgressColorWithTheme.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - setController(x) { - this.controller = x; + setController(c1) { + this.controller = c1; + } + get fontColorWithTheme() { + return this.__fontColorWithTheme.get(); + } + set fontColorWithTheme(b1) { + this.__fontColorWithTheme.set(b1); + } + get loadingProgressColorWithTheme() { + return this.__loadingProgressColorWithTheme.get(); + } + set loadingProgressColorWithTheme(a1) { + this.__loadingProgressColorWithTheme.set(a1); } initialRender() { - this.observeComponentCreation((v, w) => { - ViewStackProcessor.StartGetAccessRecordingFor(v); + this.observeComponentCreation2((y, z) => { Column.create(); - if (!w) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, Column); + this.observeComponentCreation2((w, x) => { + WithTheme.create({ theme: this.theme }); + }, WithTheme); { - this.observeComponentCreation((p, q) => { - ViewStackProcessor.StartGetAccessRecordingFor(p); - if (q) { - let r = new CustomDialogComponent(this, { + this.observeComponentCreation2((q, r) => { + if (r) { + let s = new CustomDialogComponent(this, { controller: this.controller, contentBuilder: () => { this.contentBuilder(); }, - }, undefined, p, () => { }, { page: 'library/src/main/ets/components/mainpage/MainPage.ets', line: 758 }); - ViewPU.create(r); - let s = () => { + theme: this.theme, + }, undefined, q, () => { + }, { page: 'library/src/main/ets/components/mainpage/dialog.ets', line: 1221, col: 9 }); + ViewPU.create(s); + let t = () => { return { controller: this.controller, contentBuilder: () => { this.contentBuilder(); - } + }, + theme: this.theme, }; }; - r.paramsGenerator_ = s; + s.paramsGenerator_ = t; } else { - this.updateStateVarsOfChildByElmtId(p, {}); + this.updateStateVarsOfChildByElmtId(q, {}); } - ViewStackProcessor.StopGetAccessRecording(); - }); + }, { name: 'CustomDialogComponent' }); } + WithTheme.pop(); Column.pop(); } contentBuilder(a = null) { - this.observeComponentCreation((l, m) => { - ViewStackProcessor.StartGetAccessRecordingFor(l); + this.observeComponentCreation2((l, m) => { Column.create(); - if (!m) { - Column.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((j, k) => { - ViewStackProcessor.StartGetAccessRecordingFor(j); + }, Column); + this.observeComponentCreation2((j, k) => { Row.create(); Row.constraintSize({ minHeight: LOADING_MIN_HEIGHT }); - if (!k) { - Row.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); - this.observeComponentCreation((h, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(h); + }, Row); + this.observeComponentCreation2((h, i) => { Text.create(this.content); - Text.fontSize({ id: -1, type: 10002, params: ['sys.float.Body_L'], bundleName: '', moduleName: '' }); + Text.fontSize({ + 'id': -1, + 'type': 10002, + params: ['sys.float.Body_L'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }); Text.fontWeight(FontWeight.Regular); - Text.fontColor({ id: -1, type: 10001, params: ['sys.color.font_primary'], bundleName: '', moduleName: '' }); + Text.fontColor(ObservedObject.GetRawObject(this.fontColorWithTheme)); Text.layoutWeight(LOADING_TEXT_LAYOUT_WEIGHT); Text.maxLines(LOADING_MAX_LINES); Text.focusable(true); Text.defaultFocus(true); Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - if (!i) { - Text.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + Text.key('advanced_LoadingDialog_content'); + }, Text); Text.pop(); - this.observeComponentCreation((f, g) => { - ViewStackProcessor.StartGetAccessRecordingFor(f); + this.observeComponentCreation2((f, g) => { LoadingProgress.create(); - LoadingProgress.color({ id: -1, type: 10001, params: ['sys.color.icon_secondary'], bundleName: '', moduleName: '' }); + LoadingProgress.color(ObservedObject.GetRawObject(this.loadingProgressColorWithTheme)); LoadingProgress.width(LOADING_PROGRESS_WIDTH); LoadingProgress.height(LOADING_PROGRESS_HEIGHT); LoadingProgress.margin({ left: LOADING_TEXT_MARGIN_LEFT }); - if (!g) { - LoadingProgress.pop(); - } - ViewStackProcessor.StopGetAccessRecording(); - }); + LoadingProgress.key('advanced_LoadingDialog_loadingProgress'); + }, LoadingProgress); Row.pop(); Column.pop(); } + aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.font_primary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + this.loadingProgressColorWithTheme = this.theme.colors?.iconSecondary ? + this.theme.colors.iconSecondary : { + 'id': -1, + 'type': 10001, + params: ['sys.color.icon_secondary'], + 'bundleName': '__harDefaultBundleName__', + 'moduleName': '__harDefaultModuleName__', + }; + } rerender() { this.updateDirtyElements(); } diff --git a/advanced_ui_component/dialog/source/dialog.ets b/advanced_ui_component/dialog/source/dialog.ets index 850b5482f7842dbd98bc9d2d69ecd80c1699e35f..9e6d41a2d8513bb4f4c011065576bc9008244306 100644 --- a/advanced_ui_component/dialog/source/dialog.ets +++ b/advanced_ui_component/dialog/source/dialog.ets @@ -20,6 +20,14 @@ import hilog from '@ohos.hilog'; import measure from '@ohos.measure'; import resourceManager from '@ohos.resourceManager'; +export class CustomThemeImpl implements CustomTheme { + colors?: CustomColors; + + constructor(colors: CustomColors) { + this.colors = colors; + } +} + const TITLE_MAX_LINES: number = 2; const HORIZON_BUTTON_MAX_COUNT: number = 2; const VERTICAL_BUTTON_MAX_COUNT: number = 4; @@ -66,15 +74,20 @@ export struct TipsDialog { buttonHeight: number = 0; // the controller of content area scroll contentScroller: Scroller = new Scroller(); + @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + theme: CustomTheme = new CustomThemeImpl({}); build() { - CustomDialogComponent({ - controller: this.controller, - contentBuilder: () => { - this.contentBuilder(); - }, - buttons: this.buttons, - }) + WithTheme({ theme: this.theme }) { + CustomDialogComponent({ + controller: this.controller, + contentBuilder: () => { + this.contentBuilder(); + }, + buttons: this.buttons, + theme: this.theme, + }) + } } @Builder @@ -112,11 +125,12 @@ export struct TipsDialog { Text(content) .fontSize($r('sys.float.Body_M')) .fontWeight(FontWeight.Regular) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .maxLines(CONTENT_MAX_LINES) .layoutWeight(1) .focusable(false) .textOverflow({ overflow: TextOverflow.Ellipsis }) + .key('advanced_tipsDialog_checkboxPart_text') .onClick(() => { this.isChecked = !this.isChecked; if (this.checkAction) { @@ -164,13 +178,14 @@ export struct TipsDialog { Text(this.title) .fontSize($r('sys.float.Title_S')) .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .textAlign(TextAlign.Center) .maxLines(CONTENT_MAX_LINES) .textOverflow({ overflow: TextOverflow.Ellipsis }) .minFontSize($r('sys.float.Body_L')) .maxFontSize($r('sys.float.Title_S')) .width('100%') + .key('advanced_tipsDialog_textPart_title') } .padding({ bottom: $r('sys.float.padding_level8') }) } @@ -181,9 +196,10 @@ export struct TipsDialog { .defaultFocus(!(this.primaryButton || this.secondaryButton)) .fontSize($r('sys.float.Body_L')) .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .textAlign(this.textAlignment) .width('100%') + .key('advanced_tipsDialog_textPart_content') .onKeyEvent((event: KeyEvent) => { if (event) { resolveKeyEvent(event, this.contentScroller); @@ -201,6 +217,8 @@ export struct TipsDialog { } aboutToAppear() { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); this.initButtons(); this.initMargin(); } @@ -265,6 +283,10 @@ export struct SelectDialog{ buttons?: ButtonOptions[] = []; contentPadding ?: Padding; @BuilderParam contentBuilder: () => void = this.buildContent; + @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + @State dividerColorWithTheme: ResourceColor = $r('sys.color.comp_divider'); + theme: CustomTheme = new CustomThemeImpl({}); + controller: CustomDialogController = new CustomDialogController({ builder: CustomContentDialog({ primaryTitle: this.title, @@ -276,7 +298,7 @@ export struct SelectDialog{ }); // the controller of content list contentScroller: Scroller = new Scroller(); - + @Styles paddingContentStyle() { .padding({ left: $r('sys.float.padding_level12'), @@ -294,18 +316,19 @@ export struct SelectDialog{ @Builder buildContent() : void { - Scroll() { + Scroll(this.contentScroller) { Column() { if (this.content) { Row() { Text(this.content) .fontSize($r('sys.float.Body_M')) .fontWeight(FontWeight.Regular) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .textOverflow({overflow: TextOverflow.Ellipsis}) + .key('advanced_selectDialog_content') }.paddingContentStyle().width('100%') } - List({ space: 1, scroller: this.contentScroller }) { + List({ space: 1 }) { ForEach(this.radioContent, (item: SheetInfo, index?: number) => { ListItem() { Column() { @@ -314,17 +337,19 @@ export struct SelectDialog{ Text(item.title) .fontSize($r('sys.float.Body_L')) .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .layoutWeight(1) + .key('advanced_selectDialog_listText') Radio({ value: 'item.title', group: 'radioGroup' }) .size({ width: CHECKBOX_CONTAINER_LENGTH, height: CHECKBOX_CONTAINER_LENGTH }) .checked(this.selectedIndex === index) .hitTestBehavior(HitTestMode.None) .id(String(index)) .onFocus(() => { - if (index == FIRST_ITEM_INDEX) { - // fix no buttons not to scroll to first item when first item reGet focus - this.contentScroller.scrollToIndex(FIRST_ITEM_INDEX); + if (index === FIRST_ITEM_INDEX) { + this.contentScroller.scrollEdge(Edge.Top); + } else if (index === this.radioContent.length - 1) { + this.contentScroller.scrollEdge(Edge.Bottom); } }) }.constraintSize({ minHeight: LIST_MIN_HEIGHT }).clip(false) @@ -335,15 +360,15 @@ export struct SelectDialog{ item.action && item.action(); this.controller.close(); }) - if (index < this.radioContent.length - 1) { - Divider().color($r('sys.color.comp_divider')).paddingStyle() + if (index && index < this.radioContent.length - 1) { + Divider().color(this.dividerColorWithTheme).paddingStyle().key('advanced_selectDialog_divider') } }.paddingStyle() } }) }.width('100%').clip(false) .onFocus(() => { - this.contentScroller.scrollToIndex(FIRST_ITEM_INDEX); + this.contentScroller.scrollEdge(Edge.Top); focusControl.requestFocus(String(FIRST_ITEM_INDEX)); }) .defaultFocus(this.buttons?.length == 0 ? true : false) @@ -352,18 +377,25 @@ export struct SelectDialog{ } build() { - CustomDialogComponent({ - controller: this.controller, - primaryTitle: this.title, - contentBuilder: () => { - this.contentBuilder(); - }, - buttons: this.buttons, - contentAreaPadding: this.contentPadding - }) + WithTheme({ theme: this.theme }) { + CustomDialogComponent({ + controller: this.controller, + primaryTitle: this.title, + contentBuilder: () => { + this.contentBuilder(); + }, + buttons: this.buttons, + contentAreaPadding: this.contentPadding, + theme: this.theme, + }) + } } aboutToAppear(): void { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); + this.dividerColorWithTheme = this.theme.colors?.compDivider ? + this.theme.colors.compDivider : $r('sys.color.comp_divider'); this.initContentPadding(); this.initButtons(); } @@ -410,8 +442,13 @@ export struct ConfirmDialog{ @State isChecked?: boolean = false primaryButton?: ButtonOptions = {value: ""} secondaryButton?: ButtonOptions = {value: ""} + @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + @State checkboxFontColorWithTheme: ResourceColor = $r('sys.color.ohos_id_color_text_primary'); + @State buttonFontColorWithTheme: ResourceColor = $r('sys.color.ohos_id_color_text_primary_activated'); + theme: CustomTheme = new CustomThemeImpl({}); build() { + WithTheme({ theme: this.theme }) { Column() { Row() { Text(this.title) @@ -420,9 +457,10 @@ export struct ConfirmDialog{ .maxLines(CONTENT_MAX_LINES) .minFontSize(15) .textOverflow({ overflow: TextOverflow.Ellipsis}) - .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontColor(this.fontColorWithTheme) .textAlign(TextAlign.Start) .width('100%') + .key('advanced_confirmDialog_title') }.padding({ left: 24, right: 24, top: 24 }) .constraintSize({minHeight: 56}) if (this.content) { @@ -432,10 +470,11 @@ export struct ConfirmDialog{ .defaultFocus(!(this.primaryButton?.value || this.secondaryButton?.value)) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontColor(this.fontColorWithTheme) .maxLines(CONTENT_MAX_LINES) .textOverflow({ overflow: TextOverflow.Ellipsis}) .minFontSize($r('sys.float.ohos_id_text_size_body3')) + .key('advanced_confirmDialog_content') }.padding({ left: 24, right: 24, top: 8, bottom: 8 }) .width('100%') .constraintSize({minHeight: 36}) @@ -448,47 +487,50 @@ export struct ConfirmDialog{ .margin({ left: 0, right: 8}) Text(this.checkTips).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontColor(this.checkboxFontColorWithTheme) .maxLines(CONTENT_MAX_LINES) .layoutWeight(1) .focusable(false) .textOverflow({ overflow: TextOverflow.Ellipsis }) + .key('advanced_confirmDialog_checkboxText') .onClick(() => { this.isChecked = !this.isChecked }) }.height(CHECKBOX_CONTAINER_HEIGHT).width('100%').padding({ left: 24, right: 24 , top: 8, bottom: 8 }) Row() { - if (this.primaryButton.value) { + if (this.primaryButton?.value) { Button(this.primaryButton.value) .fontSize($r('sys.float.ohos_id_text_size_button1')) .fontWeight(FontWeight.Medium) .layoutWeight(1) .defaultFocus(true) .backgroundColor(this.primaryButton.background? this.primaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) + .fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor : this.buttonFontColorWithTheme) + .key('advanced_confirmDialog_primaryButton') .onClick(() => { - if (this.primaryButton.action) this.primaryButton.action() + if (this.primaryButton?.action) this.primaryButton.action() this.controller.close() }) } - if (this.secondaryButton.value && this.primaryButton.value) { + if (this.secondaryButton?.value && this.primaryButton?.value) { Column() { if (!this.secondaryButton.background) { Divider().width(DIVIDER_WIDTH).height(DIVIDER_HEIGHT).color($r('sys.color.ohos_id_color_list_separator')).vertical(true) } }.width(DIVIDER_CONTAINER_WIDTH).alignItems(HorizontalAlign.Center) } - if (this.secondaryButton.value) { + if (this.secondaryButton?.value) { Button(this.secondaryButton.value) .fontSize($r('sys.float.ohos_id_text_size_button1')) .fontWeight(FontWeight.Medium) .layoutWeight(1) .defaultFocus(true) .backgroundColor(this.secondaryButton.background? this.secondaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) + .fontColor(this.secondaryButton?.fontColor ? this.secondaryButton.fontColor : this.buttonFontColorWithTheme) + .key('advanced_confirmDialog_secondaryButton') .onClick(() => { - if (this.secondaryButton.action) this.secondaryButton.action() + if (this.secondaryButton?.action) this.secondaryButton.action() this.controller.close() }) } @@ -503,6 +545,16 @@ export struct ConfirmDialog{ }) // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) + } + } + + aboutToAppear(): void { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); + this.checkboxFontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.ohos_id_color_text_primary'); + this.buttonFontColorWithTheme = this.theme.colors?.fontEmphasize ? + this.theme.colors.fontEmphasize : $r('sys.color.ohos_id_color_text_primary_activated'); } } @@ -518,17 +570,22 @@ export struct AlertDialog { @State textAlign: TextAlign = TextAlign.Start; // the controller of content area contentScroller: Scroller = new Scroller(); + @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + theme: CustomTheme = new CustomThemeImpl({}); build() { - CustomDialogComponent({ - primaryTitle: this.primaryTitle, - secondaryTitle: this.secondaryTitle, - controller: this.controller, - contentBuilder: () => { - this.AlertDialogContentBuilder(); - }, - buttons: this.buttons, - }) + WithTheme({ theme: this.theme }) { + CustomDialogComponent({ + primaryTitle: this.primaryTitle, + secondaryTitle: this.secondaryTitle, + controller: this.controller, + contentBuilder: () => { + this.AlertDialogContentBuilder(); + }, + buttons: this.buttons, + theme: this.theme, + }) + } } @Builder @@ -540,10 +597,11 @@ export struct AlertDialog { .defaultFocus(!(this.primaryButton || this.secondaryButton)) .fontSize($r('sys.float.Body_L')) .fontWeight(this.getFontWeight()) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .margin({ right: $r('sys.float.padding_level8'), }) .width(`calc(100% - ${getNumberByResource('padding_level8')}vp)`) .textAlign(this.textAlign) + .key('advanced_alertDialog_content') .onAreaChange((oldValue: Area, newValue: Area) => { this.getTextAlign(Number(newValue.width)); }) @@ -559,6 +617,8 @@ export struct AlertDialog { } aboutToAppear(): void { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); this.initButtons(); } @@ -618,18 +678,22 @@ export struct CustomContentDialog { @BuilderParam contentBuilder: () => void; contentAreaPadding?: Padding; buttons?: ButtonOptions[]; + theme: CustomTheme = new CustomThemeImpl({}); build() { - CustomDialogContentComponent({ - controller: this.controller, - primaryTitle: this.primaryTitle, - secondaryTitle: this.secondaryTitle, - contentBuilder: () => { - this.contentBuilder(); - }, - contentAreaPadding: this.contentAreaPadding, - buttons: this.buttons, - }); + WithTheme({ theme: this.theme }) { + CustomDialogContentComponent({ + controller: this.controller, + primaryTitle: this.primaryTitle, + secondaryTitle: this.secondaryTitle, + contentBuilder: () => { + this.contentBuilder(); + }, + contentAreaPadding: this.contentAreaPadding, + buttons: this.buttons, + theme: this.theme, + }); + } } } @@ -642,6 +706,11 @@ struct CustomDialogContentComponent { buttons?: ButtonOptions[]; contentAreaPadding?: Padding; keyIndex: number = 0; + @State primaryFontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + @State secondaryFontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + @State buttonFontColorWithTheme: ResourceColor = $r('sys.color.ohos_id_color_text_primary_activated'); + @State errorButtonFontColorWithTheme: ResourceColor = $r('sys.color.ohos_id_color_text_primary_activated'); + theme: CustomTheme = new CustomThemeImpl({}); @Builder defaultContentBuilder(): void { @@ -651,21 +720,23 @@ struct CustomDialogContentComponent { @State contentMaxHeight: string = ''; build() { - Column() { - // title area - this.buildTitles(); - - // content area + WithTheme({ theme: this.theme }) { Column() { - this.contentBuilder(); - } - .padding(this.getContentPadding()) - .constraintSize({ maxHeight: this.contentMaxHeight, }) + // title area + this.buildTitles(); - // operation area - this.buildButtons(); + // content area + Column() { + this.contentBuilder(); + } + .padding(this.getContentPadding()) + .constraintSize({ maxHeight: this.contentMaxHeight, }) + + // operation area + this.buildButtons(); + } + .width('100%') } - .width('100%') } @Builder @@ -674,7 +745,7 @@ struct CustomDialogContentComponent { Row() { Text(this.primaryTitle) .fontWeight(FontWeight.Bold) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.primaryFontColorWithTheme) .textAlign(this.getTitleTextAlign()) .maxFontSize($r('sys.float.Title_S')) .minFontSize($r('sys.float.Body_L')) @@ -682,6 +753,7 @@ struct CustomDialogContentComponent { .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) .textOverflow({ overflow: TextOverflow.Ellipsis }) .width('100%') + .key('advanced_dialog_primaryTitle') } .width('100%') @@ -694,7 +766,7 @@ struct CustomDialogContentComponent { Row() { Text(this.secondaryTitle) .fontWeight(FontWeight.Regular) - .fontColor($r('sys.color.font_secondary')) + .fontColor(this.secondaryFontColorWithTheme) .textAlign(this.getTitleTextAlign()) .maxFontSize($r('sys.float.Subtitle_S')) .minFontSize($r('sys.float.Body_S')) @@ -702,6 +774,7 @@ struct CustomDialogContentComponent { .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) .textOverflow({ overflow: TextOverflow.Ellipsis }) .width('100%') + .key('advanced_dialog_secondaryTitle') } .width('100%') } @@ -745,6 +818,13 @@ struct CustomDialogContentComponent { .setButtonProperties(buttonOptions, this.controller) .backgroundColor(buttonOptions.background) .key(`advanced_dialog_button_${this.keyIndex++}`) + } else if (buttonOptions.background !== undefined && buttonOptions.fontColor === undefined || '') { + Button(buttonOptions.value) + .setButtonProperties(buttonOptions, this.controller) + .backgroundColor(buttonOptions.background) + .fontColor(buttonOptions.role === ButtonRole.ERROR ? + this.errorButtonFontColorWithTheme : this.buttonFontColorWithTheme) + .key(`advanced_dialog_button_${this.keyIndex++}`) } else { Button(buttonOptions.value) .setButtonProperties(buttonOptions, this.controller) @@ -808,6 +888,14 @@ struct CustomDialogContentComponent { this.titleHeight = getNumberByResource('alert_title_secondary_height'); } this.contentMaxHeight = `calc(100% - ${this.titleHeight}vp - ${this.getButtonsHeight()}vp)`; + this.primaryFontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); + this.secondaryFontColorWithTheme = this.theme.colors?.fontSecondary ? + this.theme.colors.fontSecondary : $r('sys.color.font_primary'); + this.buttonFontColorWithTheme = this.theme.colors?.fontEmphasize ? + this.theme.colors.fontEmphasize : $r('sys.color.ohos_id_color_text_primary_activated'); + this.errorButtonFontColorWithTheme = this.theme.colors?.warning ? + this.theme.colors.warning : $r('sys.color.ohos_id_color_text_primary_activated'); } /** @@ -997,6 +1085,7 @@ export struct CustomDialogComponent { screenWidth: number = 0; @State columnModifier: ColumnModifier = new ColumnModifier(); isFirstInit: boolean = true; + theme: CustomTheme = new CustomThemeImpl({}); build() { Column() { @@ -1010,6 +1099,7 @@ export struct CustomDialogComponent { }, buttons: this.buttons, contentAreaPadding: this.contentAreaPadding, + theme: this.theme, }) } .attributeModifier(this.columnModifier) @@ -1130,15 +1220,21 @@ function resolveKeyEvent(event: KeyEvent, controller: Scroller) { export struct LoadingDialog { controller: CustomDialogController; content?: ResourceStr = ''; + @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); + @State loadingProgressColorWithTheme: ResourceColor = $r('sys.color.icon_secondary'); + theme: CustomTheme = new CustomThemeImpl({}); build() { Column() { - CustomDialogComponent({ - controller: this.controller, - contentBuilder: () => { - this.contentBuilder(); - }, - }) + WithTheme({ theme: this.theme }) { + CustomDialogComponent({ + controller: this.controller, + contentBuilder: () => { + this.contentBuilder(); + }, + theme: this.theme, + }) + } } } @@ -1149,19 +1245,28 @@ export struct LoadingDialog { Text(this.content) .fontSize($r('sys.float.Body_L')) .fontWeight(FontWeight.Regular) - .fontColor($r('sys.color.font_primary')) + .fontColor(this.fontColorWithTheme) .layoutWeight(LOADING_TEXT_LAYOUT_WEIGHT) .maxLines(LOADING_MAX_LINES) .focusable(true) .defaultFocus(true) .textOverflow({ overflow: TextOverflow.Ellipsis }) + .key('advanced_LoadingDialog_content') LoadingProgress() - .color($r('sys.color.icon_secondary')) + .color(this.loadingProgressColorWithTheme) .width(LOADING_PROGRESS_WIDTH) .height(LOADING_PROGRESS_HEIGHT) .margin({ left: LOADING_TEXT_MARGIN_LEFT }) + .key('advanced_LoadingDialog_loadingProgress') } .constraintSize({ minHeight: LOADING_MIN_HEIGHT }) } } + + aboutToAppear(): void { + this.fontColorWithTheme = this.theme.colors?.fontPrimary ? + this.theme.colors.fontPrimary : $r('sys.color.font_primary'); + this.loadingProgressColorWithTheme = this.theme.colors?.iconSecondary ? + this.theme.colors.iconSecondary : $r('sys.color.icon_secondary'); + } } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_button.cpp index 4c202262803e0c6e657c17012120c5af9144b2b4..8b7df0625350ffb4b0ccf130563d108d4c7eb71a 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_button.cpp @@ -21,9 +21,11 @@ #include "base/utils/utils.h" #include "core/components/button/button_component.h" #include "core/components/button/button_theme.h" +#include "core/components_ng/base/view_stack_model.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/button/button_model_ng.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_click_function.h" +#include "frameworks/bridge/declarative_frontend/jsview/js_theme.h" #include "frameworks/bridge/declarative_frontend/jsview/js_utils.h" #include "frameworks/bridge/declarative_frontend/jsview/models/button_model_impl.h" #include "frameworks/bridge/declarative_frontend/view_stack_processor.h" @@ -357,6 +359,27 @@ void JSButton::CreateWithLabel(const JSCallbackInfo& info) ButtonModel::GetInstance()->CreateWithLabel(para, buttonChildren); ButtonModel::GetInstance()->Create(para, buttonChildren); isLabelButton_ = true; + + auto jsValue = info[0]; + if (jsValue->IsBoolean()) { + auto needApplyTheme = jsValue->ToBoolean(); // TODO: use only for experiments + if (needApplyTheme) { + // normal + ViewStackModel::GetInstance()->SetVisualState(VisualState::NORMAL); + ButtonModel::GetInstance()->SetFontColor( + JSThemeScope::jsTheme_.Colors().FontOnPrimary()); + ButtonModel::GetInstance()->BackgroundColor( + JSThemeScope::jsTheme_.Colors().BackgroundEmphasize(), true); + + // pressed + ViewStackModel::GetInstance()->SetVisualState(VisualState::PRESSED); + ButtonModel::GetInstance()->BackgroundColor( + JSThemeScope::jsTheme_.Colors().InteractivePressed(), true); + + // clear state + ViewStackModel::GetInstance()->ClearVisualState(); + } + } } void JSButton::CreateWithChild(const JSCallbackInfo& info) @@ -618,19 +641,19 @@ CreateWithPara JSButton::ParseCreatePara(const JSCallbackInfo& info, bool hasLab CreateWithPara para; para.parseSuccess = false; para.optionSetFirst = false; - if (info.Length() < 1) { + if (info.Length() < 2) { para.label = label; return para; } - int32_t optionIndex = 0; + int32_t optionIndex = 1; if (hasLabel) { - para.parseSuccess = ParseJsString(info[0], label); + para.parseSuccess = ParseJsString(info[1], label); if (para.parseSuccess) { // resource string - if (info[0]->IsObject() && JSRef::Cast(info[0])->HasProperty("id")) { + if (info[1]->IsObject() && JSRef::Cast(info[0])->HasProperty("id")) { optionIndex++; // string - } else if (info[0]->IsString()) { + } else if (info[1]->IsString()) { optionIndex++; } } @@ -639,7 +662,7 @@ CreateWithPara JSButton::ParseCreatePara(const JSCallbackInfo& info, bool hasLab if (optionIndex >= info.Length() || !info[optionIndex]->IsObject()) { return para; } - if (optionIndex == 0) { + if (optionIndex == 1) { para.optionSetFirst = true; } JSRef optionObj = JSRef::Cast(info[optionIndex]); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_theme.h b/frameworks/bridge/declarative_frontend/jsview/js_theme.h new file mode 100644 index 0000000000000000000000000000000000000000..921ff3c240c1422f9827eabcfb604d01421a77d2 --- /dev/null +++ b/frameworks/bridge/declarative_frontend/jsview/js_theme.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_THEME_H +#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_THEME_H + +#include "core/components/common/properties/color.h" + +namespace OHOS::Ace::Framework { +class JSThemeColors { +public: + JSThemeColors() = default; + virtual ~JSThemeColors() = default; + + void SetColors( + const Color& fontOnPrimary, + const Color& backgroundEmphasize, + const Color& interactivePressed) + { + fontOnPrimary_ = fontOnPrimary; + backgroundEmphasize_ = backgroundEmphasize; + interactivePressed_ = interactivePressed; + } + + Color FontOnPrimary() const + { + return fontOnPrimary_; + } + Color BackgroundEmphasize() const + { + return backgroundEmphasize_; + } + Color InteractivePressed() const + { + return interactivePressed_; + } +private: + Color fontOnPrimary_; + Color backgroundEmphasize_; + Color interactivePressed_; +}; + +class JSTheme { +public: + JSTheme() = default; + virtual ~JSTheme() = default; + + void SetColors(const JSThemeColors& colors) + { + colors_ = colors; + } + + JSThemeColors Colors() const + { + return colors_; + } +private: + JSThemeColors colors_; +}; + +// TODO: use single static instance for experiments only +class JSThemeScope { +public: + static JSTheme jsTheme_; +}; +} // namespace OHOS::Ace::Framework +#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_THEME_H \ No newline at end of file diff --git a/frameworks/bridge/declarative_frontend/jsview/js_with_theme.cpp b/frameworks/bridge/declarative_frontend/jsview/js_with_theme.cpp index 7befaf523a5bf7a7c330fb6f2c382ebcf0a9e8f6..b1c22924cfea755502d0442e734537e3fa77b3c0 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_with_theme.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_with_theme.cpp @@ -16,14 +16,48 @@ #include "bridge/declarative_frontend/jsview/js_with_theme.h" #include "base/memory/referenced.h" +#include "bridge/declarative_frontend/jsview/js_theme.h" namespace OHOS::Ace::Framework { +JSTheme JSThemeScope::jsTheme_ = JSTheme(); + void JSWithTheme::JSBind(BindingTarget globalObj) { JSClass::Declare("WithTheme"); - JSClass::Bind<>(globalObj); + JSClass::StaticMethod("sendThemeToNative", &JSWithTheme::SendThemeToNative, MethodOptions::NONE); JSClass::InheritAndBind(globalObj); } +void JSWithTheme::SendThemeToNative(const JSCallbackInfo& info) +{ + auto jsTheme = info[0]; + if (!jsTheme->IsObject()) { + return; + } + JSRef jsThemeObj = JSRef::Cast(jsTheme); + JSRef jsColors = jsThemeObj->GetProperty("colors"); + if (!jsColors->IsObject()) { + return; + } + JSRef jsColorsObj = JSRef::Cast(jsColors); + + Color fontOnPrimary; + Color backgroundEmphasize; + Color interactivePressed; + + ParseJsColor(jsColorsObj->GetProperty("fontOnPrimary"), fontOnPrimary); + ParseJsColor(jsColorsObj->GetProperty("backgroundEmphasize"), backgroundEmphasize); + ParseJsColor(jsColorsObj->GetProperty("interactivePressed"), interactivePressed); + + auto colors = JSThemeColors(); + colors.SetColors( + fontOnPrimary, + backgroundEmphasize, + interactivePressed + ); + + JSThemeScope::jsTheme_.SetColors(colors); +} + } // namespace OHOS::Ace::Framework \ No newline at end of file diff --git a/frameworks/bridge/declarative_frontend/jsview/js_with_theme.h b/frameworks/bridge/declarative_frontend/jsview/js_with_theme.h index 2d8b566e1c5e06b29a08c240479d4fd70bfd4eb6..e6526f1a9d0a737d94bf47724a9177ce436e2a07 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_with_theme.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_with_theme.h @@ -24,8 +24,8 @@ namespace OHOS::Ace::Framework { class JSWithTheme : public JSViewAbstract { public: + static void SendThemeToNative(const JSCallbackInfo& info); static void JSBind(BindingTarget globalObj); - }; }// namespace OHOS::Ace::Framework