From 9c249b41eda5086d723599a4a1d434fbb0d9e195 Mon Sep 17 00:00:00 2001 From: yuxiaofei9 Date: Wed, 10 Sep 2025 20:31:05 +0800 Subject: [PATCH] =?UTF-8?q?[feate]=E9=AB=98=E7=BA=A7=E7=BB=84=E4=BB=B6numb?= =?UTF-8?q?er=E6=95=B4=E6=94=B9int?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yuxiaofei9 --- .../dialog/@ohos.arkui.advanced.Dialog.ets | 4 +- .../@ohos.arkui.advanced.DialogV2.ets | 4 +- .../filter/@ohos.arkui.advanced.Filter.ets | 50 ++++++++----------- .../@ohos.arkui.advanced.ProgressButton.ets | 2 +- .../@ohos.arkui.advanced.ProgressButtonV2.ets | 2 +- .../@ohos.arkui.advanced.SelectTitleBar.ets | 2 +- .../@ohos.arkui.advanced.SubHeader.ets | 8 +-- .../@ohos.arkui.advanced.SubHeaderV2.ets | 12 ++--- .../toolbar/@ohos.arkui.advanced.ToolBar.ets | 4 +- .../@ohos.arkui.advanced.ToolBarV2.ets | 10 ++-- 10 files changed, 44 insertions(+), 54 deletions(-) diff --git a/advanced_ui_component_static/dialog/@ohos.arkui.advanced.Dialog.ets b/advanced_ui_component_static/dialog/@ohos.arkui.advanced.Dialog.ets index eb5f1b07b4b..01ee37c23d1 100644 --- a/advanced_ui_component_static/dialog/@ohos.arkui.advanced.Dialog.ets +++ b/advanced_ui_component_static/dialog/@ohos.arkui.advanced.Dialog.ets @@ -498,7 +498,7 @@ export struct SelectDialog { currentFocusIndex?: number = -1; radioHeight: number = 0; itemHeight: number = 0; - @State selectedIndex?: number = -1; + @State selectedIndex?: int = -1; @BuilderParam contentBuilder: () => void = this.buildContent; @State fontColorWithTheme: ResourceColor = $r('sys.color.font_primary'); @State dividerColorWithTheme: ResourceColor = $r('sys.color.comp_divider'); @@ -590,7 +590,7 @@ export struct SelectDialog { }) .accessibilityText(getAccessibilityText(item.title, this.selectedIndex === index)) .onClick((event: ClickEvent) => { - this.selectedIndex = index; + this.selectedIndex = index.toInt(); item?.action(); this.controller?.close(); }) diff --git a/advanced_ui_component_static/dialogv2/@ohos.arkui.advanced.DialogV2.ets b/advanced_ui_component_static/dialogv2/@ohos.arkui.advanced.DialogV2.ets index 70124ab2ce5..d73c97b6653 100644 --- a/advanced_ui_component_static/dialogv2/@ohos.arkui.advanced.DialogV2.ets +++ b/advanced_ui_component_static/dialogv2/@ohos.arkui.advanced.DialogV2.ets @@ -477,7 +477,7 @@ export struct SelectDialogV2 { @Param content?: ResourceStr = ''; @Param confirm?: AdvancedDialogV2Button | null = null; @Require @Param radioContent: SheetInfo[] = [] as Array; - @Param selectedIndex?: number = -1; + @Param selectedIndex?: int = -1; @Local selectedIndexInner?: number = -1; @Monitor(['selectedIndex']) @@ -696,7 +696,7 @@ export struct SelectDialogV2 { } aboutToAppear(): void { - this.selectedIndexInner = this.selectedIndex; + this.selectedIndexInner = this.selectedIndex as (number | undefined); } } diff --git a/advanced_ui_component_static/filter/@ohos.arkui.advanced.Filter.ets b/advanced_ui_component_static/filter/@ohos.arkui.advanced.Filter.ets index e47c53c31f7..896bd99d62b 100644 --- a/advanced_ui_component_static/filter/@ohos.arkui.advanced.Filter.ets +++ b/advanced_ui_component_static/filter/@ohos.arkui.advanced.Filter.ets @@ -75,27 +75,15 @@ enum FilterAccessibilityType { SEND_ACCESSIBILITY, } -@Observed -export class FilterParams { +export interface FilterParams { name: ResourceStr; options: Array; - - constructor(name: ResourceStr, options: Array) { - this.name = name; - this.options = options - } } -export class FilterResult { +export interface FilterResult { name: ResourceStr; - index: number; + index: int; value: ResourceStr; - - constructor(name: ResourceStr, index: number, value: ResourceStr) { - this.name = name; - this.index = index; - this.value = value - } } type FontWeightArray = Array; @@ -172,7 +160,7 @@ struct ListFilterRow { @PropRef isBackgroundHoverRow: BooleanArray; @PropRef isSelectedRow: BooleanArray; @ObjectLink filterAccessibilityText: FilterAccessibilityText; - filterRow: FilterParams = new FilterParams('', []); + filterRow: FilterParams = { name: '', options: [] } as FilterParams; onItemClick: (colIndex: number) => void = () => {}; rowIndex: number = 0; maxAppFontScale: number = 1; @@ -933,7 +921,7 @@ export struct Filter { textColor(rowIndex: number, colIndex: number) { if (this.selectedFilters && (this.selectedFilters as Array).length > rowIndex && - ((this.selectedFilters as Array)[rowIndex.toInt()].index as number) === colIndex) { + ((this.selectedFilters as Array)[rowIndex.toInt()].index) === colIndex) { return $r('sys.color.ohos_id_color_text_primary_activated'); } return $r('sys.color.ohos_id_color_text_primary'); @@ -1085,23 +1073,23 @@ export struct Filter { ((this.colorArr as Array)[rowIndex.toInt()] as ResourceArray)[colIndex.toInt()] = $r('sys.color.ohos_id_color_text_primary_activated'); ((this.colorArr as Array)[rowIndex.toInt()] as ResourceArray) - [((this.selectedFilters as Array)[rowIndex.toInt()].index.toInt())] = - $r('sys.color.ohos_id_color_text_primary'); + [((this.selectedFilters as Array)[rowIndex.toInt()].index)] = + $r('sys.color.ohos_id_color_text_primary'); } if (this.fontWeightArr) { (this.fontWeightArr as Array)[rowIndex.toInt()][colIndex.toInt()] = FontWeight.Medium as FontWeight; - (this.fontWeightArr as Array)[rowIndex.toInt()] - [(this.selectedFilters as Array)[rowIndex.toInt()].index.toInt()] = FontWeight.Regular; + (this.fontWeightArr as Array)[rowIndex.toInt()] + [(this.selectedFilters as Array)[rowIndex.toInt()].index] = FontWeight.Regular; } if (this.isSelectedArr) { (this.isSelectedArr as Array)[rowIndex.toInt()][colIndex.toInt()] = true; (this.isSelectedArr as Array)[rowIndex.toInt()] - [(this.selectedFilters as Array)[rowIndex.toInt()].index.toInt()] = false; + [(this.selectedFilters as Array)[rowIndex.toInt()].index] = false; } this.colorRefresh = (!this.colorRefresh) as boolean; (this.selectedFilters as Array)[rowIndex.toInt()].value = selectedFilterValue as ResourceStr; - (this.selectedFilters as Array)[rowIndex.toInt()].index = colIndex; + (this.selectedFilters as Array)[rowIndex.toInt()].index = colIndex.toInt(); let filterChanged: ((filterResults: Array) => void) | null = this.onFilterChanged; if (filterChanged) { filterChanged(this.selectedFilters as Array); @@ -1192,7 +1180,7 @@ export struct Filter { if (!this.selectedFilters) { this.selectedFilters = []; for (let filter of (this.multiFilters as Array)) { - let result: FilterResult = new FilterResult(filter.name, -1, ''); + let result: FilterResult = { name: filter.name, index: -1, value: '' } as FilterResult; if (filter.options.length > 0) { result.index = 0; result.value = filter.options[0]; @@ -1200,7 +1188,8 @@ export struct Filter { this.selectedFilters?.push(result); } if (this.additionFilters && this.additionFilters?.name) { - let result: FilterResult = new FilterResult(this.additionFilters?.name as ResourceStr, -1, ''); + let result: FilterResult = + { name: this.additionFilters?.name as ResourceStr, index: -1, value: '' } as FilterResult; this.selectedFilters?.push(result); } this.refreshFloatFilterBarText(); @@ -1362,18 +1351,19 @@ export struct Filter { if ((this.selectedFilters as Array)[additionRowIndex.toInt()].index === -1) { (this.selectedFilters as Array)[additionRowIndex.toInt()].value = this.additionFilters ? this.additionFilters?.options[index.toInt()] as ResourceStr : '' as ResourceStr; - (this.selectedFilters as Array)[additionRowIndex.toInt()].index = index; + (this.selectedFilters as Array)[additionRowIndex.toInt()].index = index.toInt(); this.additionFiltersSelectedIndex = index; } else { - let lastIndex: number = (this.selectedFilters as Array)[additionRowIndex.toInt()].index; - this.additionColorArr && ((this.additionColorArr as Array)[lastIndex.toInt()] = + let lastIndex: int = (this.selectedFilters as Array)[additionRowIndex.toInt()].index; + this.additionColorArr && ((this.additionColorArr as Array)[lastIndex] = $r('sys.color.ohos_id_color_text_primary')); this.additionFontWeightArr && - ((this.additionFontWeightArr as Array)[lastIndex.toInt()] = FontWeight.Regular); + ((this.additionFontWeightArr as Array)[lastIndex] = FontWeight.Regular); this.selectedFilters && ((this.selectedFilters as Array)[additionRowIndex.toInt()].value = this.additionFilters ? this.additionFilters?.options[index.toInt()] as ResourceStr : ''); - this.selectedFilters && ((this.selectedFilters as Array)[additionRowIndex.toInt()].index = index); + this.selectedFilters && + ((this.selectedFilters as Array)[additionRowIndex.toInt()].index = index.toInt()); this.additionFiltersSelectedIndex = index; } } else { diff --git a/advanced_ui_component_static/progressbutton/@ohos.arkui.advanced.ProgressButton.ets b/advanced_ui_component_static/progressbutton/@ohos.arkui.advanced.ProgressButton.ets index 4484f8b619b..7596b4ee21f 100644 --- a/advanced_ui_component_static/progressbutton/@ohos.arkui.advanced.ProgressButton.ets +++ b/advanced_ui_component_static/progressbutton/@ohos.arkui.advanced.ProgressButton.ets @@ -48,7 +48,7 @@ const PROGRESS_BUTTON_EMPHASIZE_SECONDARY_BUTTON_KEY = 'progress_button_emphasiz @Component export struct ProgressButton { - @PropRef @Watch('getProgressContext') progress: number; + @PropRef @Watch('getProgressContext') progress: int; @State textProgress: string = EMPTY_STRING as string; @PropRef content: ResourceStr = EMPTY_STRING as string; @State @Watch('getLoadingProgress') isLoading: boolean = false; diff --git a/advanced_ui_component_static/progressbuttonV2/@ohos.arkui.advanced.ProgressButtonV2.ets b/advanced_ui_component_static/progressbuttonV2/@ohos.arkui.advanced.ProgressButtonV2.ets index 7546665ca61..a445789bc98 100644 --- a/advanced_ui_component_static/progressbuttonV2/@ohos.arkui.advanced.ProgressButtonV2.ets +++ b/advanced_ui_component_static/progressbuttonV2/@ohos.arkui.advanced.ProgressButtonV2.ets @@ -41,7 +41,7 @@ const PROGRESS_BUTTON_EMPHASIZE_SECONDARY_BUTTON_KEY = 'progress_button_emphasiz @ComponentV2 export struct ProgressButtonV2 { - @Param @Require progress: number; + @Param @Require progress: int; @Param content: ResourceStr = EMPTY_STRING as string; @Param @Once progressButtonWidth?: LengthMetrics = LengthMetrics.vp(BUTTON_NORMARL_WIDTH); @Param onClicked: ClickCallback = () => {}; diff --git a/advanced_ui_component_static/selecttitlebar/@ohos.arkui.advanced.SelectTitleBar.ets b/advanced_ui_component_static/selecttitlebar/@ohos.arkui.advanced.SelectTitleBar.ets index a47b1c4ee2b..c30a2400276 100644 --- a/advanced_ui_component_static/selecttitlebar/@ohos.arkui.advanced.SelectTitleBar.ets +++ b/advanced_ui_component_static/selecttitlebar/@ohos.arkui.advanced.SelectTitleBar.ets @@ -87,7 +87,7 @@ export struct SelectTitleBar { options: Array = [] as Array; menuItems: Array = [] as Array; subtitle: ResourceStr = ''; - badgeValue: number = 0; + badgeValue: int = 0; hidesBackButton: boolean = false; messageDesc: string = ''; onSelected: ((index: number) => void) = (index: number) => { diff --git a/advanced_ui_component_static/subheader/@ohos.arkui.advanced.SubHeader.ets b/advanced_ui_component_static/subheader/@ohos.arkui.advanced.SubHeader.ets index eacf52f1350..ecb54f32c33 100644 --- a/advanced_ui_component_static/subheader/@ohos.arkui.advanced.SubHeader.ets +++ b/advanced_ui_component_static/subheader/@ohos.arkui.advanced.SubHeader.ets @@ -81,9 +81,9 @@ export class OperationOption { export class SelectOptions { public options: Array = [] as Array; - public selected?: number; + public selected?: int; public value?: ResourceStr; - public onSelect?: (index: number, value?: string) => void; + public onSelect?: (index: int, value?: string) => void; public defaultFocus?: boolean; } @@ -349,7 +349,7 @@ export struct SubHeader { this.subHeaderModifier.isAgeing = this.ageing; } if (this.select) { - this.selectedIndex = this.select?.selected as number; + this.selectedIndex = this.select!.selected!.toDouble(); this.selectValue = this.select?.value as string; } } @@ -775,7 +775,7 @@ export struct SubHeader { this.selectValue = value; } if (selectParam.onSelect) { - (selectParam?.onSelect as (index: number, value?: string) => void)(index, value); + (selectParam?.onSelect as (index: int, value?: string) => void)(index.toInt(), value); } }) .font({ diff --git a/advanced_ui_component_static/subheaderv2/@ohos.arkui.advanced.SubHeaderV2.ets b/advanced_ui_component_static/subheaderv2/@ohos.arkui.advanced.SubHeaderV2.ets index 092cc7a6961..421934b1d5a 100644 --- a/advanced_ui_component_static/subheaderv2/@ohos.arkui.advanced.SubHeaderV2.ets +++ b/advanced_ui_component_static/subheaderv2/@ohos.arkui.advanced.SubHeaderV2.ets @@ -89,11 +89,11 @@ export class SubHeaderV2Title { } } -export type SubHeaderV2SelectOnSelect = (selectedIndex: number, selectedContent?: string) => void; +export type SubHeaderV2SelectOnSelect = (selectedIndex: int, selectedContent?: string) => void; export interface SubHeaderV2SelectOptions { options: SelectOption[]; - selectedIndex?: number; + selectedIndex?: int; selectedContent?: ResourceStr; onSelect?: SubHeaderV2SelectOnSelect; defaultFocus?: boolean; @@ -108,7 +108,7 @@ export class SubHeaderV2Select { @Trace public options: SelectOption[]; @Trace - public selectedIndex?: number; + public selectedIndex?: int; @Trace public selectedContent?: ResourceStr; @Trace @@ -328,7 +328,7 @@ export struct SubHeaderV2 { this.subHeaderModifier.isAgeing = this.ageing; } if (this.select) { - this.selectedIndex = this.select?.selectedIndex; + this.selectedIndex = this.select!.selectedIndex!.toDouble(); this.selectedContent = this.select?.selectedContent; } } @@ -423,7 +423,7 @@ export struct SubHeaderV2 { infoChange(monitor: IMonitor) { monitor.dirty.forEach((path: string) => { if ('select' === path) { - this.selectedIndex = (monitor.value(path) as IMonitorValue).now?.selectedIndex; + this.selectedIndex = (monitor.value(path) as IMonitorValue).now?.selectedIndex as int; this.selectedContent = (monitor.value(path) as IMonitorValue).now ?.selectedContent; } }) @@ -441,7 +441,7 @@ export struct SubHeaderV2 { this.selectedContent = value; } if (selectParam.params.onSelect) { - (selectParam?.params.onSelect as (index: number, value?: string) => void)(index, value); + (selectParam?.params.onSelect as (index: int, value?: string) => void)(index.toInt(), value); } }) .font({ diff --git a/advanced_ui_component_static/toolbar/@ohos.arkui.advanced.ToolBar.ets b/advanced_ui_component_static/toolbar/@ohos.arkui.advanced.ToolBar.ets index 73279b861c0..7b1400b4fea 100644 --- a/advanced_ui_component_static/toolbar/@ohos.arkui.advanced.ToolBar.ets +++ b/advanced_ui_component_static/toolbar/@ohos.arkui.advanced.ToolBar.ets @@ -171,7 +171,7 @@ class ToolBarTheme { export struct ToolBar { @ObjectLink @Watch('onToolBarListChanged') toolBarList: Array; controller: TabsController = new TabsController(); - @PropRef activateIndex: number = -1; + @PropRef activateIndex: int = -1; @Observed @PropRef dividerModifier: DividerModifier; @Observed @@ -451,7 +451,7 @@ export struct ToolBar { if (this.activateIndex === index) { this.activateIndex = -1; } else { - this.activateIndex = index; + this.activateIndex = index.toInt(); } } if (!(toolbar.state === ItemState.DISABLE)) { diff --git a/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets b/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets index eea97a865b2..287eba70013 100644 --- a/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets +++ b/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets @@ -147,14 +147,14 @@ export interface ToolBarV2ItemImageOptions { activatedColor?: ColorMetrics; } -export type ToolBarV2ItemAction = (index: number) => void; +export type ToolBarV2ItemAction = (index: int) => void; @ObservedV2 export class ToolBarV2Item { @Trace public content: ToolBarV2ItemText = new ToolBarV2ItemText({ text: '' }); @Trace - public action?: (index: number) => void = undefined; + public action?: (index: int) => void = undefined; @Trace public icon?: ToolBarV2ItemIconType = undefined; @Trace @@ -198,7 +198,7 @@ export class ToolBarV2Item { export interface ToolBarV2ItemOptions { content: ToolBarV2ItemText; - action?: (index: number) => void; + action?: (index: int) => void; icon?: ToolBarV2ItemIconType; state?: ToolBarV2ItemState; accessibilityText?: ResourceStr; @@ -260,7 +260,7 @@ export struct ToolBarV2 { @Require @Param toolBarList: ToolBarV2Item[] = [] as ToolBarV2Item[]; @Param - activatedIndex?: number = -1; + activatedIndex?: int = -1; @Param dividerModifier?: DividerModifier = new DividerModifier(); @Param @@ -664,7 +664,7 @@ export struct ToolBarV2 { } if (toolbar.state !== ToolBarV2ItemState.DISABLE) { if (typeof toolbar.action === 'function') { - toolbar.action?.(index); + toolbar.action?.(index.toInt()); } } } -- Gitee