From 55d6674927317efb3188d0816c214c956cbb1fb4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Thu, 10 Jul 2025 14:41:43 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- componentstacklibrary/Index.ets | 5 ++-- .../ComponentStackPage.ets | 29 ++++++++++--------- .../{constant => constants}/StackConstant.ets | 0 .../src/main/ets/utils/BreakpointSystem.ets | 6 ++-- .../src/main/ets/utils/WindowUtil.ets | 25 +++++++++++++--- .../src/main/ets/view/IconView.ets | 9 +++--- .../src/main/ets/view/ProductList.ets | 8 ++--- .../resources/base/profile/main_pages.json | 2 +- .../main/ets/entryability/EntryAbility.ets | 16 +++++----- 9 files changed, 60 insertions(+), 40 deletions(-) rename componentstacklibrary/src/main/ets/{pages => component}/ComponentStackPage.ets (84%) rename componentstacklibrary/src/main/ets/{constant => constants}/StackConstant.ets (100%) diff --git a/componentstacklibrary/Index.ets b/componentstacklibrary/Index.ets index 8f9d01b..3007005 100644 --- a/componentstacklibrary/Index.ets +++ b/componentstacklibrary/Index.ets @@ -1,2 +1,3 @@ -export { ComponentStackPage} from './src/main/ets/pages/ComponentStackPage' -export { WindowUtil } from './src/main/ets/utils/WindowUtil'; \ No newline at end of file +export { ComponentStackPage } from './src/main/ets/component/ComponentStackPage'; + +export { ComponentStackController } from './src/main/ets/ComponentStackController.ets'; \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/pages/ComponentStackPage.ets b/componentstacklibrary/src/main/ets/component/ComponentStackPage.ets similarity index 84% rename from componentstacklibrary/src/main/ets/pages/ComponentStackPage.ets rename to componentstacklibrary/src/main/ets/component/ComponentStackPage.ets index 3eae197..54e8ef8 100644 --- a/componentstacklibrary/src/main/ets/pages/ComponentStackPage.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackPage.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { IconList1, IconList2, IconList3 } from '../view/IconView'; -import { StackConstant } from '../constant/StackConstant'; +import { StackConstant } from '../constants/StackConstant'; import { ProductList } from '../view/ProductList'; +import { CommonConstants } from '../constants/CommonConstants'; @Component -export struct ComponentStackPage { +export struct ComponentStackPage { @State searchHeight: number = StackConstant.SEARCH_HEIGHT_RAW; @State opacityList: number = 1; @State opacityList2: number = 1; @@ -27,10 +27,10 @@ export struct ComponentStackPage { @State isChange: boolean = false; @State heightList2: number = StackConstant.HEIGHT_LIST_2_RAW; @State marginSpace: number = StackConstant.MAX_MARGIN_SPACE; - @StorageLink('statusHeight') statusHeight: number = 0; - @StorageLink('bottomHeight') bottomHeight: number = 0; - @StorageLink('screenHeight') screenHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; + @StorageLink(CommonConstants.KEY_PREFIX + 'statusHeight') statusHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'bottomHeight') bottomHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; private scroller: Scroller = new Scroller(); private scroller2: Scroller = new Scroller(); @@ -72,7 +72,9 @@ export struct ComponentStackPage { .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.search_border_radius')) .onClick(() => { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + this.getUIContext() + .getPromptAction() + .showToast({ message: $r('app.string.component_stack_other_function') }); }); Stack({ alignContent: Alignment.Top }) { @@ -80,7 +82,7 @@ export struct ComponentStackPage { Row() { IconList3({ marginSpace: this.marginSpace }) } - .backgroundColor($r('sys.color.comp_background_primary')) + .backgroundColor($r('sys.color.background_secondary')) .width(StackConstant.FULL_PERCENT) .height($r('app.integer.icon_list_height3')) .opacity(this.opacityList) @@ -105,7 +107,8 @@ export struct ComponentStackPage { ProductList() .width(StackConstant.FULL_PERCENT) - .height(px2vp(this.screenHeight - this.statusHeight - this.bottomHeight) - StackConstant.USED_SPACE) + .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.bottomHeight) - + StackConstant.USED_SPACE) } .margin({ top: StackConstant.MARGIN_TOP }) } @@ -141,7 +144,7 @@ export struct ComponentStackPage { this.isChange = true; this.opacityList = (yOffset - StackConstant.ICON_LIST_1_RAW) / StackConstant.MAX_MARGIN_SPACE; this.marginSpace = StackConstant.ICON_LIST_3_RAW - yOffset > StackConstant.MIN_MARGIN_SPACE ? - (StackConstant.ICON_LIST_3_RAW - yOffset) : StackConstant.MIN_MARGIN_SPACE; + (StackConstant.ICON_LIST_3_RAW - yOffset) : StackConstant.MIN_MARGIN_SPACE; } return { offsetRemain: offset }; }) @@ -167,9 +170,9 @@ export struct ComponentStackPage { .padding({ top: this.statusHeight, left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : - this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), + this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : - this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), + this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), }) } } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/constant/StackConstant.ets b/componentstacklibrary/src/main/ets/constants/StackConstant.ets similarity index 100% rename from componentstacklibrary/src/main/ets/constant/StackConstant.ets rename to componentstacklibrary/src/main/ets/constants/StackConstant.ets diff --git a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets index aa7581b..ed6f049 100644 --- a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets @@ -16,6 +16,7 @@ import { window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { CommonConstants } from '../constants/CommonConstants'; const TAG: string = '[BreakpointSystem]'; @@ -84,7 +85,7 @@ export class BreakpointSystem { public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { if (this.currentBreakpoint !== breakpoint) { this.currentBreakpoint = breakpoint; - AppStorage.setOrCreate('currentBreakpoint', this.currentBreakpoint); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'currentBreakpoint', this.currentBreakpoint); } } @@ -94,9 +95,10 @@ export class BreakpointSystem { public updateWidthBp(window: window.Window): void { try { + const uiContext: UIContext = AppStorage.get(CommonConstants.KEY_PREFIX + 'UIContext') as UIContext; const mainWindow: window.WindowProperties = window.getWindowProperties(); const windowWidth: number = mainWindow.windowRect.width; - const windowWidthVp = px2vp(windowWidth); + const windowWidthVp = uiContext.px2vp(windowWidth); let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.MD; if (windowWidthVp < 320) { widthBp = BreakpointTypeEnum.XS; diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index 75b2e80..1e6ec77 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -18,10 +18,27 @@ import type { BusinessError } from '@kit.BasicServicesKit'; import { BreakpointSystem } from './BreakpointSystem'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { Configuration, ConfigurationConstant } from '@kit.AbilityKit'; +import { CommonConstants } from '../constants/CommonConstants'; const TAG: string = '[WindowUtil]'; export class WindowUtil { + private static windowClass?: window.Window; + private static uiContext: UIContext; + + public static initialize(windowStage: window.WindowStage) { + try { + WindowUtil.windowClass = windowStage.getMainWindowSync(); + const uiContext: UIContext = WindowUtil.windowClass.getUIContext(); + WindowUtil.uiContext = uiContext; + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'UIContext', uiContext); + WindowUtil.registerBreakPoint(windowStage); + WindowUtil.requestFullScreen(windowStage); + } catch (err) { + hilog.error(0x0000, TAG, `WindowUtil initialize failed. Cause: ${err.code} ${err.message}`); + } + } + public static requestFullScreen(windowStage: window.WindowStage): void { windowStage.getMainWindow((err: BusinessError, data: window.Window) => { if (err.code) { @@ -63,18 +80,18 @@ export class WindowUtil { // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate('statusHeight', px2vp(area.topRect.height)); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', WindowUtil.uiContext.px2vp(area.topRect.height)); } else { - AppStorage.setOrCreate('bottomHeight', px2vp(area.bottomRect.height)); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', WindowUtil.uiContext.px2vp(area.bottomRect.height)); } } public static updatedColorMode(newConfig: Configuration): void { let newColorMode: ConfigurationConstant.ColorMode = newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get('systemColorMode'); + let currentColorMode = AppStorage.get(CommonConstants.KEY_PREFIX + 'systemColorMode'); if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate('systemColorMode', newColorMode); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'systemColorMode', newColorMode); } } } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/view/IconView.ets b/componentstacklibrary/src/main/ets/view/IconView.ets index 78df725..49cca54 100644 --- a/componentstacklibrary/src/main/ets/view/IconView.ets +++ b/componentstacklibrary/src/main/ets/view/IconView.ets @@ -13,10 +13,9 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { ICON_DATA1, ICON_DATA2 } from '../model/IconModel'; import { IconDataModel } from '../viewmodel/IconViewModel'; -import { StackConstant } from '../constant/StackConstant'; +import { StackConstant } from '../constants/StackConstant'; // White background style of the lower text in the preceding figure. @Component @@ -42,7 +41,7 @@ struct IconView1 { .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.icon_view_border_radius')) .onClick(() => { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); }) } } @@ -70,7 +69,7 @@ struct IconView2 { .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.icon_view_border_radius')) .onClick(() => { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); }) } } @@ -96,7 +95,7 @@ struct IconView3 { .height($r('app.integer.icon_view_height3')) .justifyContent(FlexAlign.Center) .onClick(() => { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); }) } } diff --git a/componentstacklibrary/src/main/ets/view/ProductList.ets b/componentstacklibrary/src/main/ets/view/ProductList.ets index 756107d..fcd6c08 100644 --- a/componentstacklibrary/src/main/ets/view/ProductList.ets +++ b/componentstacklibrary/src/main/ets/view/ProductList.ets @@ -13,18 +13,18 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { ProductDataModel } from '../viewmodel/IconViewModel'; import { ProductDataSource } from '../viewmodel/DataSource'; -import { StackConstant } from '../constant/StackConstant'; +import { StackConstant } from '../constants/StackConstant'; import { PRODUCT_DATA } from '../model/IconModel'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BusinessError } from '@kit.BasicServicesKit'; +import { CommonConstants } from '../constants/CommonConstants'; @Component export struct ProductList { private productData: ProductDataSource = new ProductDataSource(); - @StorageLink('currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; + @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; aboutToAppear() { this.productData.pushData(PRODUCT_DATA); @@ -76,7 +76,7 @@ export struct ProductList { .borderRadius($r('app.integer.water_flow_column_border_radius')) .onClick(() => { try { - promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); } catch (error) { const err = error as BusinessError; hilog.error(0x000, 'ProductList', `showToast catch error, code: ${err.code}, message: ${err.message}`); diff --git a/componentstacklibrary/src/main/resources/base/profile/main_pages.json b/componentstacklibrary/src/main/resources/base/profile/main_pages.json index 3b90675..7b9d70f 100644 --- a/componentstacklibrary/src/main/resources/base/profile/main_pages.json +++ b/componentstacklibrary/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/ComponentStackPage" + "component/ComponentStackPage" ] } diff --git a/componentstacksample/src/main/ets/entryability/EntryAbility.ets b/componentstacksample/src/main/ets/entryability/EntryAbility.ets index d583592..050a0d7 100644 --- a/componentstacksample/src/main/ets/entryability/EntryAbility.ets +++ b/componentstacksample/src/main/ets/entryability/EntryAbility.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import { Configuration, ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; +import { Configuration, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; -import { WindowUtil } from 'componentstacklibrary'; +import { window } from '@kit.ArkUI'; +import { ComponentStackController } from 'componentstacklibrary'; const TAG = '[EntryAbility]'; @@ -24,8 +24,6 @@ export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate'); - AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } onDestroy(): void { @@ -33,16 +31,16 @@ export default class EntryAbility extends UIAbility { } onConfigurationUpdate(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig) + ComponentStackController.updatedColorMode(newConfig) } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability. hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); - WindowUtil.requestFullScreen(windowStage) - WindowUtil.registerBreakPoint(windowStage) - + ComponentStackController.requestFullScreen(windowStage); + ComponentStackController.registerBreakPoint(windowStage); windowStage.loadContent('pages/Index', (err) => { + ComponentStackController.initWindowConfig(windowStage); if (err.code) { hilog.error(0x0000, TAG, `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; -- Gitee From 5e1be2a53dd001f1af2860d6dfb11719003c51eb Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Thu, 10 Jul 2025 19:11:39 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets index ed6f049..1b00ae3 100644 --- a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets @@ -78,6 +78,7 @@ export class BreakpointSystem { public static getInstance(): BreakpointSystem { if (!BreakpointSystem.instance) { BreakpointSystem.instance = new BreakpointSystem(); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'currentBreakpoint', BreakpointTypeEnum.MD); } return BreakpointSystem.instance; } -- Gitee From e55e8e19ebd2ec5067ae97f989469d8e6178d893 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Thu, 10 Jul 2025 19:19:47 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- componentstacklibrary/BuildProfile.ets | 17 +++++++++ .../src/main/ets/ComponentStackController.ets | 37 +++++++++++++++++++ .../main/ets/constants/CommonConstants.ets | 8 ++++ 3 files changed, 62 insertions(+) create mode 100644 componentstacklibrary/BuildProfile.ets create mode 100644 componentstacklibrary/src/main/ets/ComponentStackController.ets create mode 100644 componentstacklibrary/src/main/ets/constants/CommonConstants.ets diff --git a/componentstacklibrary/BuildProfile.ets b/componentstacklibrary/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/componentstacklibrary/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/ComponentStackController.ets b/componentstacklibrary/src/main/ets/ComponentStackController.ets new file mode 100644 index 0000000..16cfb29 --- /dev/null +++ b/componentstacklibrary/src/main/ets/ComponentStackController.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 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. + */ +import { window } from '@kit.ArkUI'; +import { Configuration } from '@kit.AbilityKit'; +import { WindowUtil } from './utils/WindowUtil'; + + +export class ComponentStackController { + public static initWindowConfig(windowStage: window.WindowStage): void { + WindowUtil.initialize(windowStage); + } + + public static updatedColorMode(newConfig: Configuration): void { + WindowUtil.updatedColorMode(newConfig) + } + + public static requestFullScreen(windowStage: window.WindowStage): void { + WindowUtil.requestFullScreen(windowStage) + } + + public static registerBreakPoint(windowStage: window.WindowStage): void { + WindowUtil.registerBreakPoint(windowStage) + } + +} \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/constants/CommonConstants.ets b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets new file mode 100644 index 0000000..812966f --- /dev/null +++ b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets @@ -0,0 +1,8 @@ + + +export class CommonConstants { + /** + * AppStorage key prefix. + */ + public static readonly KEY_PREFIX: string = 'componentStack'; +} \ No newline at end of file -- Gitee From a6d0912710863cdac6ccd54740d808f11dcbb8ea Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Thu, 10 Jul 2025 19:56:58 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- componentstacklibrary/Index.ets | 2 +- .../src/main/ets/ComponentStackController.ets | 9 --------- ...omponentStackPage.ets => ComponentStackComponent.ets} | 2 +- componentstacklibrary/src/main/ets/utils/WindowUtil.ets | 2 +- .../src/main/resources/base/profile/main_pages.json | 2 +- .../src/main/ets/entryability/EntryAbility.ets | 4 +--- componentstacksample/src/main/ets/pages/Index.ets | 4 ++-- 7 files changed, 7 insertions(+), 18 deletions(-) rename componentstacklibrary/src/main/ets/component/{ComponentStackPage.ets => ComponentStackComponent.ets} (99%) diff --git a/componentstacklibrary/Index.ets b/componentstacklibrary/Index.ets index 3007005..baab691 100644 --- a/componentstacklibrary/Index.ets +++ b/componentstacklibrary/Index.ets @@ -1,3 +1,3 @@ -export { ComponentStackPage } from './src/main/ets/component/ComponentStackPage'; +export { ComponentStackComponent } from './src/main/ets/component/ComponentStackComponent'; export { ComponentStackController } from './src/main/ets/ComponentStackController.ets'; \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/ComponentStackController.ets b/componentstacklibrary/src/main/ets/ComponentStackController.ets index 16cfb29..94a0693 100644 --- a/componentstacklibrary/src/main/ets/ComponentStackController.ets +++ b/componentstacklibrary/src/main/ets/ComponentStackController.ets @@ -25,13 +25,4 @@ export class ComponentStackController { public static updatedColorMode(newConfig: Configuration): void { WindowUtil.updatedColorMode(newConfig) } - - public static requestFullScreen(windowStage: window.WindowStage): void { - WindowUtil.requestFullScreen(windowStage) - } - - public static registerBreakPoint(windowStage: window.WindowStage): void { - WindowUtil.registerBreakPoint(windowStage) - } - } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackPage.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets similarity index 99% rename from componentstacklibrary/src/main/ets/component/ComponentStackPage.ets rename to componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index 54e8ef8..c862519 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackPage.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -19,7 +19,7 @@ import { ProductList } from '../view/ProductList'; import { CommonConstants } from '../constants/CommonConstants'; @Component -export struct ComponentStackPage { +export struct ComponentStackComponent { @State searchHeight: number = StackConstant.SEARCH_HEIGHT_RAW; @State opacityList: number = 1; @State opacityList2: number = 1; diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index 1e6ec77..696a2bb 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -15,10 +15,10 @@ import { window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; -import { BreakpointSystem } from './BreakpointSystem'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { Configuration, ConfigurationConstant } from '@kit.AbilityKit'; import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointSystem } from './BreakpointSystem'; const TAG: string = '[WindowUtil]'; diff --git a/componentstacklibrary/src/main/resources/base/profile/main_pages.json b/componentstacklibrary/src/main/resources/base/profile/main_pages.json index 7b9d70f..0d0d096 100644 --- a/componentstacklibrary/src/main/resources/base/profile/main_pages.json +++ b/componentstacklibrary/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "component/ComponentStackPage" + "component/ComponentStackComponent" ] } diff --git a/componentstacksample/src/main/ets/entryability/EntryAbility.ets b/componentstacksample/src/main/ets/entryability/EntryAbility.ets index 050a0d7..5e56b59 100644 --- a/componentstacksample/src/main/ets/entryability/EntryAbility.ets +++ b/componentstacksample/src/main/ets/entryability/EntryAbility.ets @@ -37,14 +37,12 @@ export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability. hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); - ComponentStackController.requestFullScreen(windowStage); - ComponentStackController.registerBreakPoint(windowStage); windowStage.loadContent('pages/Index', (err) => { - ComponentStackController.initWindowConfig(windowStage); if (err.code) { hilog.error(0x0000, TAG, `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; } + ComponentStackController.initWindowConfig(windowStage); hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); }); } diff --git a/componentstacksample/src/main/ets/pages/Index.ets b/componentstacksample/src/main/ets/pages/Index.ets index 8be4f1c..5e02c97 100644 --- a/componentstacksample/src/main/ets/pages/Index.ets +++ b/componentstacksample/src/main/ets/pages/Index.ets @@ -13,14 +13,14 @@ * limitations under the License. */ -import { ComponentStackPage } from 'componentstacklibrary' +import { ComponentStackComponent } from 'componentstacklibrary' @Entry @Component struct Index { build() { Stack(){ - ComponentStackPage() + ComponentStackComponent() } } } \ No newline at end of file -- Gitee From e65d40c1b1cdfc7c22d068484e1e62e6d16bc15a Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Sat, 12 Jul 2025 10:24:48 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/component/ComponentStackComponent.ets | 4 +- .../main/ets/constants/CommonConstants.ets | 3 ++ .../src/main/ets/constants/StackConstant.ets | 5 --- .../src/main/ets/model/IconModel.ets | 42 ++++++++++++++++--- .../src/main/ets/utils/BreakpointSystem.ets | 3 -- .../src/main/ets/utils/WindowUtil.ets | 18 ++++++-- .../src/main/ets/view/ProductList.ets | 3 +- 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index c862519..f0fe533 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -17,6 +17,7 @@ import { IconList1, IconList2, IconList3 } from '../view/IconView'; import { StackConstant } from '../constants/StackConstant'; import { ProductList } from '../view/ProductList'; import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Component export struct ComponentStackComponent { @@ -30,7 +31,7 @@ export struct ComponentStackComponent { @StorageLink(CommonConstants.KEY_PREFIX + 'statusHeight') statusHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'bottomHeight') bottomHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; - @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; + @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private scroller: Scroller = new Scroller(); private scroller2: Scroller = new Scroller(); @@ -157,6 +158,7 @@ export struct ComponentStackComponent { .width(StackConstant.FULL_PERCENT) .height(StackConstant.FULL_PERCENT) .scrollBar(BarState.Off) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .onScrollFrameBegin((offset: number) => { // Obtains the sliding distance. const yOffset: number = this.scroller.currentOffset().yOffset; diff --git a/componentstacklibrary/src/main/ets/constants/CommonConstants.ets b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets index 812966f..95b99a2 100644 --- a/componentstacklibrary/src/main/ets/constants/CommonConstants.ets +++ b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets @@ -5,4 +5,7 @@ export class CommonConstants { * AppStorage key prefix. */ public static readonly KEY_PREFIX: string = 'componentStack'; + + + } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/constants/StackConstant.ets b/componentstacklibrary/src/main/ets/constants/StackConstant.ets index b4f6e5e..0c5a308 100644 --- a/componentstacklibrary/src/main/ets/constants/StackConstant.ets +++ b/componentstacklibrary/src/main/ets/constants/StackConstant.ets @@ -98,9 +98,4 @@ export class StackConstant { * 100 percent. */ public static readonly FULL_PERCENT: string = '100%'; - - /** - * Breakpoint sm. - */ - public static readonly BREAK_POINT_SM: string = 'sm'; } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/model/IconModel.ets b/componentstacklibrary/src/main/ets/model/IconModel.ets index ae08d23..266c326 100644 --- a/componentstacklibrary/src/main/ets/model/IconModel.ets +++ b/componentstacklibrary/src/main/ets/model/IconModel.ets @@ -36,10 +36,40 @@ export const ICON_DATA2: IconDataModel[] = [ // Offering List Data Source. export const PRODUCT_DATA: ProductDataModel[] = [ - new ProductDataModel(0, $r('app.media.product00'), $r('app.string.product_title00'), $r('app.string.product_price00'), $r('app.string.product_insurance00')), - new ProductDataModel(1, $r('app.media.product01'), $r('app.string.product_title01'), $r('app.string.product_price01'), $r('app.string.product_insurance01')), - new ProductDataModel(2, $r('app.media.product02'), $r('app.string.product_title02'), $r('app.string.product_price02'), $r('app.string.product_insurance02')), - new ProductDataModel(3, $r('app.media.product03'), $r('app.string.product_title03'), $r('app.string.product_price03'), $r('app.string.product_insurance03')), - new ProductDataModel(4, $r('app.media.product04'), $r('app.string.product_title04'), $r('app.string.product_price04'), $r('app.string.product_insurance04')), - new ProductDataModel(5, $r('app.media.product03'), $r('app.string.product_title03'), $r('app.string.product_price03'), $r('app.string.product_insurance05')) + new ProductDataModel(0, $r('app.media.product00'), $r('app.string.product_title00'), $r('app.string.product_price00'), + $r('app.string.product_insurance00')), + new ProductDataModel(1, $r('app.media.product01'), $r('app.string.product_title01'), $r('app.string.product_price01'), + $r('app.string.product_insurance01')), + new ProductDataModel(2, $r('app.media.product02'), $r('app.string.product_title02'), $r('app.string.product_price02'), + $r('app.string.product_insurance02')), + new ProductDataModel(3, $r('app.media.product03'), $r('app.string.product_title03'), $r('app.string.product_price03'), + $r('app.string.product_insurance03')), + new ProductDataModel(4, $r('app.media.product04'), $r('app.string.product_title04'), $r('app.string.product_price04'), + $r('app.string.product_insurance04')), + new ProductDataModel(5, $r('app.media.product03'), $r('app.string.product_title03'), $r('app.string.product_price03'), + $r('app.string.product_insurance05')), + new ProductDataModel(6, $r('app.media.product00'), $r('app.string.product_title00'), $r('app.string.product_price00'), + $r('app.string.product_insurance00')), + new ProductDataModel(7, $r('app.media.product01'), $r('app.string.product_title01'), $r('app.string.product_price01'), + $r('app.string.product_insurance01')), + new ProductDataModel(8, $r('app.media.product02'), $r('app.string.product_title02'), $r('app.string.product_price02'), + $r('app.string.product_insurance02')), + new ProductDataModel(9, $r('app.media.product03'), $r('app.string.product_title03'), $r('app.string.product_price03'), + $r('app.string.product_insurance03')), + new ProductDataModel(10, $r('app.media.product04'), $r('app.string.product_title04'), + $r('app.string.product_price04'), $r('app.string.product_insurance04')), + new ProductDataModel(11, $r('app.media.product03'), $r('app.string.product_title03'), + $r('app.string.product_price03'), $r('app.string.product_insurance05')), + new ProductDataModel(12, $r('app.media.product00'), $r('app.string.product_title00'), + $r('app.string.product_price00'), $r('app.string.product_insurance00')), + new ProductDataModel(13, $r('app.media.product01'), $r('app.string.product_title01'), + $r('app.string.product_price01'), $r('app.string.product_insurance01')), + new ProductDataModel(14, $r('app.media.product02'), $r('app.string.product_title02'), + $r('app.string.product_price02'), $r('app.string.product_insurance02')), + new ProductDataModel(15, $r('app.media.product03'), $r('app.string.product_title03'), + $r('app.string.product_price03'), $r('app.string.product_insurance03')), + new ProductDataModel(16, $r('app.media.product04'), $r('app.string.product_title04'), + $r('app.string.product_price04'), $r('app.string.product_insurance04')), + new ProductDataModel(17, $r('app.media.product03'), $r('app.string.product_title03'), + $r('app.string.product_price03'), $r('app.string.product_insurance05')) ]; \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets index 1b00ae3..02feb55 100644 --- a/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/componentstacklibrary/src/main/ets/utils/BreakpointSystem.ets @@ -78,16 +78,13 @@ export class BreakpointSystem { public static getInstance(): BreakpointSystem { if (!BreakpointSystem.instance) { BreakpointSystem.instance = new BreakpointSystem(); - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'currentBreakpoint', BreakpointTypeEnum.MD); } return BreakpointSystem.instance; } public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { - if (this.currentBreakpoint !== breakpoint) { this.currentBreakpoint = breakpoint; AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'currentBreakpoint', this.currentBreakpoint); - } } public onWindowSizeChange(window: window.Window): void { diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index 696a2bb..4c8295e 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -55,7 +55,7 @@ export class WindowUtil { `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); }); } catch { - hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. '); + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode.'); } }); } @@ -67,8 +67,15 @@ export class WindowUtil { return; } BreakpointSystem.getInstance().updateWidthBp(data); + let avoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', + WindowUtil.uiContext.px2vp(avoidArea.bottomRect.height)); + avoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', + WindowUtil.uiContext.px2vp(avoidArea.topRect.height)); data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); data.on('avoidAreaChange', (avoidAreaOption) => { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); @@ -80,16 +87,19 @@ export class WindowUtil { // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', WindowUtil.uiContext.px2vp(area.topRect.height)); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', + WindowUtil.uiContext.px2vp(area.topRect.height)); } else { - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', WindowUtil.uiContext.px2vp(area.bottomRect.height)); + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', + WindowUtil.uiContext.px2vp(area.bottomRect.height)); } } public static updatedColorMode(newConfig: Configuration): void { let newColorMode: ConfigurationConstant.ColorMode = newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get(CommonConstants.KEY_PREFIX + 'systemColorMode'); + let currentColorMode = + AppStorage.get(CommonConstants.KEY_PREFIX + 'systemColorMode'); if (newColorMode !== currentColorMode) { AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'systemColorMode', newColorMode); } diff --git a/componentstacklibrary/src/main/ets/view/ProductList.ets b/componentstacklibrary/src/main/ets/view/ProductList.ets index fcd6c08..bbfeb25 100644 --- a/componentstacklibrary/src/main/ets/view/ProductList.ets +++ b/componentstacklibrary/src/main/ets/view/ProductList.ets @@ -20,11 +20,12 @@ import { PRODUCT_DATA } from '../model/IconModel'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Component export struct ProductList { private productData: ProductDataSource = new ProductDataSource(); - @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = StackConstant.BREAK_POINT_SM; + @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; aboutToAppear() { this.productData.pushData(PRODUCT_DATA); -- Gitee From 1e98113f236071fe1299b7bc7c4885d74f1a8162 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Sat, 12 Jul 2025 14:15:23 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/ComponentStackController.ets | 4 ---- .../src/main/ets/entryability/EntryAbility.ets | 4 ---- 2 files changed, 8 deletions(-) diff --git a/componentstacklibrary/src/main/ets/ComponentStackController.ets b/componentstacklibrary/src/main/ets/ComponentStackController.ets index 94a0693..0856a3a 100644 --- a/componentstacklibrary/src/main/ets/ComponentStackController.ets +++ b/componentstacklibrary/src/main/ets/ComponentStackController.ets @@ -21,8 +21,4 @@ export class ComponentStackController { public static initWindowConfig(windowStage: window.WindowStage): void { WindowUtil.initialize(windowStage); } - - public static updatedColorMode(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig) - } } \ No newline at end of file diff --git a/componentstacksample/src/main/ets/entryability/EntryAbility.ets b/componentstacksample/src/main/ets/entryability/EntryAbility.ets index 5e56b59..b8c5c7d 100644 --- a/componentstacksample/src/main/ets/entryability/EntryAbility.ets +++ b/componentstacksample/src/main/ets/entryability/EntryAbility.ets @@ -30,10 +30,6 @@ export default class EntryAbility extends UIAbility { hilog.info(0x0000, TAG, '%{public}s', 'Ability onDestroy'); } - onConfigurationUpdate(newConfig: Configuration): void { - ComponentStackController.updatedColorMode(newConfig) - } - onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability. hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); -- Gitee From 966973bd4cd5f584787832bd6452f103bd0b03a5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Mon, 14 Jul 2025 11:22:27 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/ComponentStackController.ets | 2 +- .../src/main/ets/component/ComponentStackComponent.ets | 4 ++-- componentstacklibrary/src/main/ets/utils/WindowUtil.ets | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/componentstacklibrary/src/main/ets/ComponentStackController.ets b/componentstacklibrary/src/main/ets/ComponentStackController.ets index 0856a3a..919bf38 100644 --- a/componentstacklibrary/src/main/ets/ComponentStackController.ets +++ b/componentstacklibrary/src/main/ets/ComponentStackController.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { window } from '@kit.ArkUI'; -import { Configuration } from '@kit.AbilityKit'; import { WindowUtil } from './utils/WindowUtil'; diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index f0fe533..72e4bc5 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -28,8 +28,8 @@ export struct ComponentStackComponent { @State isChange: boolean = false; @State heightList2: number = StackConstant.HEIGHT_LIST_2_RAW; @State marginSpace: number = StackConstant.MAX_MARGIN_SPACE; - @StorageLink(CommonConstants.KEY_PREFIX + 'statusHeight') statusHeight: number = 0; - @StorageLink(CommonConstants.KEY_PREFIX + 'bottomHeight') bottomHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'statusBarHeight') statusHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'navigatorBarHeight') bottomHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private scroller: Scroller = new Scroller(); diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index 4c8295e..d232b78 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -68,10 +68,10 @@ export class WindowUtil { } BreakpointSystem.getInstance().updateWidthBp(data); let avoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'navigatorBarHeight', WindowUtil.uiContext.px2vp(avoidArea.bottomRect.height)); avoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusBarHeight', WindowUtil.uiContext.px2vp(avoidArea.topRect.height)); data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); data.on('avoidAreaChange', (avoidAreaOption) => { @@ -87,10 +87,10 @@ export class WindowUtil { // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusHeight', + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'statusBarHeight', WindowUtil.uiContext.px2vp(area.topRect.height)); } else { - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'bottomHeight', + AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'navigatorBarHeight', WindowUtil.uiContext.px2vp(area.bottomRect.height)); } } -- Gitee From 237eb79ec8b1f3fefdb9dd68c8219760afbc92f5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Mon, 14 Jul 2025 11:33:01 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/component/ComponentStackComponent.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index 72e4bc5..d57184a 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -29,7 +29,7 @@ export struct ComponentStackComponent { @State heightList2: number = StackConstant.HEIGHT_LIST_2_RAW; @State marginSpace: number = StackConstant.MAX_MARGIN_SPACE; @StorageLink(CommonConstants.KEY_PREFIX + 'statusBarHeight') statusHeight: number = 0; - @StorageLink(CommonConstants.KEY_PREFIX + 'navigatorBarHeight') bottomHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'navigatorBarHeight') navigatorBarHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private scroller: Scroller = new Scroller(); @@ -108,7 +108,7 @@ export struct ComponentStackComponent { ProductList() .width(StackConstant.FULL_PERCENT) - .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.bottomHeight) - + .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.navigatorBarHeight) - StackConstant.USED_SPACE) } .margin({ top: StackConstant.MARGIN_TOP }) -- Gitee From e1a38544ba8113fff8f8e411e11e4e2354a130ba Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Mon, 14 Jul 2025 16:08:15 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6,=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84,readme?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 41 ++++--- README.md | 33 +++--- .../ets/component/ComponentStackComponent.ets | 57 +++++----- .../main/ets/constants/CommonConstants.ets | 85 ++++++++++++++- .../src/main/ets/constants/StackConstant.ets | 101 ------------------ .../src/main/ets/view/IconView.ets | 26 ++--- .../src/main/ets/view/ProductList.ets | 15 ++- 7 files changed, 175 insertions(+), 183 deletions(-) delete mode 100644 componentstacklibrary/src/main/ets/constants/StackConstant.ets diff --git a/README.en.md b/README.en.md index a40cf35..8bbe43e 100644 --- a/README.en.md +++ b/README.en.md @@ -15,23 +15,30 @@ This sample describes how to use component stacking to build multi-layer stack v ### Project Directory ``` -componentstack -├──entry/src/main/ets -│ ├──constant -│ │ └──StackConstant.ets // Constant class -│ ├──entryability -│ │ └──EntryAbility.ets // Application lifecycle class -│ ├──model -│ │ └──IconModel.ets // Local data source -│ ├──pages -│ │ └──Index.ets // Home page of component stacking -│ ├──view -│ │ ├──IconView.ets // Custom component of the icon shortcut -│ │ └──ProductList.ets // Custom component of the product list -│ └──viewmodel -│ ├──DataSource.ets // List data model -│ └──IconModel.ets // Data type definition -└────entry/src/main/resources +component-stack +├──componentstacklibrary/src/main/ets +│ ├──component +│ │ └──ComponentStackComponent.ets // Component stacking component class +│ ├──constant +│ │ └──CommonConstants.ets // Constants class +│ ├──model +│ │ └──IconModel.ets // Local data source +│ ├──utils +│ │ ├───BreakpointSystem.ets // Responsive layout class (for multi-device adaptation) +│ │ └───WindowUtil.ets // General window utility class +│ ├──view +│ │ ├──IconView.ets // Quick access button custom component +│ │ └──ProductList.ets // Product list custom component +│ └──viewmodel +│ ├──DataSource.ets // List data model +│ └──IconModel.ets // Data type definition +└────componentstacklibrary/src/main/resources +├──componentstacksample/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // Application lifecycle class +│ ├──pages +│ │ └──Index.ets // Main page for component stacking +└────componentstacksample/src/main/resources ``` ### How to Implement diff --git a/README.md b/README.md index bb81ab7..c91059d 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,30 @@ ### 目录结构 ``` -componentstack -├──entry/src/main/ets +component-stack +├──componentstacklibrary/src/main/ets +│ ├──component +│ │ └──ComponentStackComponent.ets // 组件堆叠组件类 │ ├──constant -│ │ └──StackConstant.ets // 常量类 -│ ├──entryability -│ │ └──EntryAbility.ets // 应用生命周期类 +│ │ └──CommonConstants.ets // 常量类 │ ├──model -│ │ └──IconModel.ets // 本地数据源 -│ ├──pages -│ │ └──Index.ets // 组件堆叠主页面 +│ │ └──IconModel.ets // 本地数据源 +│ ├──utils +│ │ ├───BreakpointSystem.ets // 一多类 +│ │ └───WindowUtil.ets // 通用窗口类 │ ├──view -│ │ ├──IconView.ets // 按钮快捷入口自定义组件 -│ │ └──ProductList.ets // 商品列表自定义组件 +│ │ ├──IconView.ets // 按钮快捷入口自定义组件 +│ │ └──ProductList.ets // 商品列表自定义组件 │ └──viewmodel -│ ├──DataSource.ets // 列表数据模型 -│ └──IconModel.ets // 数据类型定义 -└────entry/src/main/resources +│ ├──DataSource.ets // 列表数据模型 +│ └──IconModel.ets // 数据类型定义 +└────componentstacklibrary/src/main/resources +├──componentstacksample/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 应用生命周期类 +│ ├──pages +│ │ └──Index.ets // 组件堆叠主页面 +└────componentstacksample/src/main/resources ``` ### 实现思路 diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index d57184a..dabef84 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -14,20 +14,19 @@ */ import { IconList1, IconList2, IconList3 } from '../view/IconView'; -import { StackConstant } from '../constants/StackConstant'; import { ProductList } from '../view/ProductList'; import { CommonConstants } from '../constants/CommonConstants'; import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Component export struct ComponentStackComponent { - @State searchHeight: number = StackConstant.SEARCH_HEIGHT_RAW; + @State searchHeight: number = CommonConstants.SEARCH_HEIGHT_RAW; @State opacityList: number = 1; @State opacityList2: number = 1; @State ratio: number = 1; @State isChange: boolean = false; - @State heightList2: number = StackConstant.HEIGHT_LIST_2_RAW; - @State marginSpace: number = StackConstant.MAX_MARGIN_SPACE; + @State heightList2: number = CommonConstants.HEIGHT_LIST_2_RAW; + @State marginSpace: number = CommonConstants.MAX_MARGIN_SPACE; @StorageLink(CommonConstants.KEY_PREFIX + 'statusBarHeight') statusHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'navigatorBarHeight') navigatorBarHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; @@ -51,7 +50,7 @@ export struct ComponentStackComponent { .padding({ top: $r('app.integer.flex_padding_top') }) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.flex_height')) Scroll(this.scroller) { @@ -68,7 +67,7 @@ export struct ComponentStackComponent { .fontSize($r('app.integer.search_font_size')) .margin({ left: $r('app.integer.search_text_margin_left') }) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height(this.searchHeight) .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.search_border_radius')) @@ -84,7 +83,7 @@ export struct ComponentStackComponent { IconList3({ marginSpace: this.marginSpace }) } .backgroundColor($r('sys.color.background_secondary')) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_list_height3')) .opacity(this.opacityList) .zIndex(1) @@ -92,7 +91,7 @@ export struct ComponentStackComponent { Row() { IconList1() } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_list_height1')) .opacity(this.opacityList) } @@ -102,18 +101,18 @@ export struct ComponentStackComponent { Row() { IconList2({ ratio: this.ratio }) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_view_height3')) .opacity(this.opacityList2) ProductList() - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.navigatorBarHeight) - - StackConstant.USED_SPACE) + CommonConstants.USED_SPACE) } - .margin({ top: StackConstant.MARGIN_TOP }) + .margin({ top: CommonConstants.MARGIN_TOP }) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .scrollBar(BarState.Off) // Sets the nested scrolling mode in the forward and backward directions to implement // scrolling linkage with the parent widget. @@ -126,47 +125,47 @@ export struct ComponentStackComponent { .onScrollFrameBegin((offset: number) => { // Change the values of margin and opacity to move and hide the component. let yOffset: number = this.scroller2.currentOffset().yOffset; - this.heightList2 = StackConstant.HEIGHT_LIST_2_RAW - yOffset * 0.5; + this.heightList2 = CommonConstants.HEIGHT_LIST_2_RAW - yOffset * 0.5; // Set the transparency of IconList2 based on the yOffset value. - if (1 - yOffset / StackConstant.ICON_LIST_2_RAW >= 0) { - this.opacityList2 = 1 - yOffset / StackConstant.ICON_LIST_2_RAW; + if (1 - yOffset / CommonConstants.ICON_LIST_2_RAW >= 0) { + this.opacityList2 = 1 - yOffset / CommonConstants.ICON_LIST_2_RAW; } else { - this.opacityList2 = 0; + this.opacityList2 = 0;11 } // Zoom with transparency settings. this.ratio = this.opacityList2; // Set the transparency of IconList1 and the margin of IconList3 based on yOffset. - if (1 - yOffset / StackConstant.ICON_LIST_1_RAW > 0) { + if (1 - yOffset / CommonConstants.ICON_LIST_1_RAW > 0) { this.isChange = false; - this.opacityList = 1 - yOffset / StackConstant.ICON_LIST_1_RAW; - this.marginSpace = StackConstant.MAX_MARGIN_SPACE; + this.opacityList = 1 - yOffset / CommonConstants.ICON_LIST_1_RAW; + this.marginSpace = CommonConstants.MAX_MARGIN_SPACE; } else { this.isChange = true; - this.opacityList = (yOffset - StackConstant.ICON_LIST_1_RAW) / StackConstant.MAX_MARGIN_SPACE; - this.marginSpace = StackConstant.ICON_LIST_3_RAW - yOffset > StackConstant.MIN_MARGIN_SPACE ? - (StackConstant.ICON_LIST_3_RAW - yOffset) : StackConstant.MIN_MARGIN_SPACE; + this.opacityList = (yOffset - CommonConstants.ICON_LIST_1_RAW) / CommonConstants.MAX_MARGIN_SPACE; + this.marginSpace = CommonConstants.ICON_LIST_3_RAW - yOffset > CommonConstants.MIN_MARGIN_SPACE ? + (CommonConstants.ICON_LIST_3_RAW - yOffset) : CommonConstants.MIN_MARGIN_SPACE; } return { offsetRemain: offset }; }) } } - .height(StackConstant.FULL_PERCENT) - .width(StackConstant.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .margin({ top: $r('app.integer.margin_search_view') }) } - .width(StackConstant.FULL_PERCENT) - .height(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) .scrollBar(BarState.Off) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .onScrollFrameBegin((offset: number) => { // Obtains the sliding distance. const yOffset: number = this.scroller.currentOffset().yOffset; - this.searchHeight = StackConstant.SEARCH_HEIGHT_RAW - yOffset * 0.6; + this.searchHeight = CommonConstants.SEARCH_HEIGHT_RAW - yOffset * 0.6; return { offsetRemain: offset }; }) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .layoutWeight(1) .backgroundColor($r('sys.color.background_secondary')) .padding({ diff --git a/componentstacklibrary/src/main/ets/constants/CommonConstants.ets b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets index 95b99a2..13a1f29 100644 --- a/componentstacklibrary/src/main/ets/constants/CommonConstants.ets +++ b/componentstacklibrary/src/main/ets/constants/CommonConstants.ets @@ -2,10 +2,91 @@ export class CommonConstants { /** - * AppStorage key prefix. + * Initial height of the backup search box. */ - public static readonly KEY_PREFIX: string = 'componentStack'; + public static readonly SEARCH_HEIGHT_RAW: number = 100; + + /** + * Backup height of quick capture icon area 2. + */ + public static readonly HEIGHT_LIST_2_RAW: number = 100; + + /** + * Default maximum spacing of icon list 3. + */ + public static readonly MAX_MARGIN_SPACE: number = 25; + + /** + * Default minimum spacing of icon list 3. + */ + public static readonly MIN_MARGIN_SPACE: number = 12; + + /** + * Calculates the transparency of icon list 1. + */ + public static readonly ICON_LIST_1_RAW: number = 100; + /** + * Calculates the transparency of icon list 2. + */ + public static readonly ICON_LIST_2_RAW: number = 120; + /** + * Calculates the transparency of icon list 3. + */ + public static readonly ICON_LIST_3_RAW: number = 140; + /** + * Occupied height. + */ + public static readonly USED_SPACE: number = 110; + + /** + * Product list column margin. + */ + public static readonly MARGIN_TOP: number = 200; + + /** + * Spacing between icons. + */ + public static readonly ICON_VIEW_SPACE: number = 10; + + /** + * Number of columns in list 1. + */ + public static readonly ICON_LIST_COLUMNS_1: number = 4; + + /** + * Number of columns in list 2. + */ + public static readonly ICON_LIST_COLUMNS_2: number = 5; + + /** + * Spacing between column subcomponents. + */ + public static readonly COLUMN_SPACE: number = 5; + + /** + * Price control offset. + */ + public static readonly OFFSET: number = -4; + + /** + * WaterFlow component vertical spacing. + */ + public static readonly COLUMNS_GAP: number = 12; + + /** + * Horizontal spacing between WaterFlow components. + */ + public static readonly ROWS_GAP: number = 12; + + /** + * 100 percent. + */ + public static readonly FULL_PERCENT: string = '100%'; + /** + * AppStorage key prefix. + */ + public static readonly KEY_PREFIX: string = 'componentStack'; } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/constants/StackConstant.ets b/componentstacklibrary/src/main/ets/constants/StackConstant.ets deleted file mode 100644 index 0c5a308..0000000 --- a/componentstacklibrary/src/main/ets/constants/StackConstant.ets +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2024 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. - */ - -export class StackConstant { - /** - * Initial height of the backup search box. - */ - public static readonly SEARCH_HEIGHT_RAW: number = 100; - - /** - * Backup height of quick capture icon area 2. - */ - public static readonly HEIGHT_LIST_2_RAW: number = 100; - - /** - * Default maximum spacing of icon list 3. - */ - public static readonly MAX_MARGIN_SPACE: number = 25; - - /** - * Default minimum spacing of icon list 3. - */ - public static readonly MIN_MARGIN_SPACE: number = 12; - - /** - * Calculates the transparency of icon list 1. - */ - public static readonly ICON_LIST_1_RAW: number = 100; - - /** - * Calculates the transparency of icon list 2. - */ - public static readonly ICON_LIST_2_RAW: number = 120; - - /** - * Calculates the transparency of icon list 3. - */ - public static readonly ICON_LIST_3_RAW: number = 140; - - /** - * Occupied height. - */ - public static readonly USED_SPACE: number = 110; - - /** - * Product list column margin. - */ - public static readonly MARGIN_TOP: number = 200; - - /** - * Spacing between icons. - */ - public static readonly ICON_VIEW_SPACE: number = 10; - - /** - * Number of columns in list 1. - */ - public static readonly ICON_LIST_COLUMNS_1: number = 4; - - /** - * Number of columns in list 2. - */ - public static readonly ICON_LIST_COLUMNS_2: number = 5; - - /** - * Spacing between column subcomponents. - */ - public static readonly COLUMN_SPACE: number = 5; - - /** - * Price control offset. - */ - public static readonly OFFSET: number = -4; - - /** - * WaterFlow component vertical spacing. - */ - public static readonly COLUMNS_GAP: number = 12; - - /** - * Horizontal spacing between WaterFlow components. - */ - public static readonly ROWS_GAP: number = 12; - - /** - * 100 percent. - */ - public static readonly FULL_PERCENT: string = '100%'; -} \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/view/IconView.ets b/componentstacklibrary/src/main/ets/view/IconView.ets index 49cca54..e0540e9 100644 --- a/componentstacklibrary/src/main/ets/view/IconView.ets +++ b/componentstacklibrary/src/main/ets/view/IconView.ets @@ -15,7 +15,7 @@ import { ICON_DATA1, ICON_DATA2 } from '../model/IconModel'; import { IconDataModel } from '../viewmodel/IconViewModel'; -import { StackConstant } from '../constants/StackConstant'; +import { CommonConstants } from '../constants/CommonConstants'; // White background style of the lower text in the preceding figure. @Component @@ -24,7 +24,7 @@ struct IconView1 { title: ResourceStr = ''; build() { - Column({ space: StackConstant.ICON_VIEW_SPACE }) { + Column({ space: CommonConstants.ICON_VIEW_SPACE }) { Image(this.icon) .width($r('app.integer.icon_view_width')) .aspectRatio(1) @@ -35,7 +35,7 @@ struct IconView1 { .fontColor($r('sys.color.font_primary')) .textAlign(TextAlign.Center) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_view_height')) .justifyContent(FlexAlign.Center) .backgroundColor($r('sys.color.comp_background_primary')) @@ -63,7 +63,7 @@ struct IconView2 { .objectFit(ImageFit.Contain) .margin({ left: $r('app.integer.icon_view_image_margin_left') }) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_view_height2')) .justifyContent(FlexAlign.Center) .backgroundColor($r('sys.color.comp_background_primary')) @@ -81,7 +81,7 @@ struct IconView3 { title: ResourceStr = ''; build() { - Column({ space: StackConstant.ICON_VIEW_SPACE }) { + Column({ space: CommonConstants.ICON_VIEW_SPACE }) { Image(this.icon) .width(30) .aspectRatio(1) @@ -91,7 +91,7 @@ struct IconView3 { .fontColor($r('sys.color.font_primary')) .textAlign(TextAlign.Center) } - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.icon_view_height3')) .justifyContent(FlexAlign.Center) .onClick(() => { @@ -104,10 +104,10 @@ struct IconView3 { export struct IconList1 { build() { GridRow({ - columns: StackConstant.ICON_LIST_COLUMNS_1, + columns: CommonConstants.ICON_LIST_COLUMNS_1, gutter: { - x: StackConstant.ICON_VIEW_SPACE, - y: StackConstant.ICON_VIEW_SPACE + x: CommonConstants.ICON_VIEW_SPACE, + y: CommonConstants.ICON_VIEW_SPACE } }) { ForEach(ICON_DATA1, (item: IconDataModel) => { @@ -129,10 +129,10 @@ export struct IconList2 { build() { GridRow({ - columns: StackConstant.ICON_LIST_COLUMNS_2, + columns: CommonConstants.ICON_LIST_COLUMNS_2, gutter: { - x: StackConstant.ICON_VIEW_SPACE, - y: StackConstant.ICON_VIEW_SPACE + x: CommonConstants.ICON_VIEW_SPACE, + y: CommonConstants.ICON_VIEW_SPACE } }) { ForEach(ICON_DATA2, (item: IconDataModel) => { @@ -160,7 +160,7 @@ export struct IconList3 { }, (item: IconDataModel) => item.id.toString()) } .height($r('app.integer.icon_view_height')) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .listDirection(Axis.Horizontal) .scrollBar(BarState.Off) } diff --git a/componentstacklibrary/src/main/ets/view/ProductList.ets b/componentstacklibrary/src/main/ets/view/ProductList.ets index bbfeb25..b063158 100644 --- a/componentstacklibrary/src/main/ets/view/ProductList.ets +++ b/componentstacklibrary/src/main/ets/view/ProductList.ets @@ -15,7 +15,6 @@ import { ProductDataModel } from '../viewmodel/IconViewModel'; import { ProductDataSource } from '../viewmodel/DataSource'; -import { StackConstant } from '../constants/StackConstant'; import { PRODUCT_DATA } from '../model/IconModel'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -33,7 +32,7 @@ export struct ProductList { @Builder waterFlowComponent(item: ProductDataModel) { - Column({ space: StackConstant.COLUMN_SPACE }) { + Column({ space: CommonConstants.COLUMN_SPACE }) { Image(item.uri) .width($r('app.integer.icon_view_image_width')) .aspectRatio(1) @@ -43,15 +42,15 @@ export struct ProductList { .padding({ right: $r('app.integer.icon_view_padding_right') }) Text(item.title) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .fontSize($r('app.integer.water_flow_title_font_size')) .fontWeight(FontWeight.Bold) .fontColor($r('sys.color.font_primary')) Text(item.price) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .fontSize($r('app.integer.water_flow_price_font_size')) - .offset({ x: StackConstant.OFFSET }) + .offset({ x: CommonConstants.OFFSET }) .fontWeight(FontWeight.Bold) .fontColor($r('app.color.ohos_id_color_warning')) @@ -71,7 +70,7 @@ export struct ProductList { } .alignItems(HorizontalAlign.Start) .padding({ left: $r('app.integer.water_flow_column_padding_left') }) - .width(StackConstant.FULL_PERCENT) + .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.water_flow_column_height')) .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('app.integer.water_flow_column_border_radius')) @@ -99,8 +98,8 @@ export struct ProductList { scrollBackward: NestedScrollMode.SELF_FIRST }) .columnsTemplate(this.curBp === 'sm' ? '1fr 1fr' : this.curBp === 'md' ? '1fr 1fr 1fr' : '1fr 1fr 1fr 1fr') - .columnsGap(StackConstant.COLUMNS_GAP) - .rowsGap(StackConstant.ROWS_GAP) + .columnsGap(CommonConstants.COLUMNS_GAP) + .rowsGap(CommonConstants.ROWS_GAP) .padding({ bottom: $r('app.integer.water_flow_padding_bottom') }) } } \ No newline at end of file -- Gitee From 3c7eae2983a6865a2b8c7f1f5772c7d08b54343f Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Tue, 15 Jul 2025 11:20:06 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6,=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/base/media/layered_image.json | 0 .../src/main/resources/base/media/startIcon.png | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename {componentstacklibrary => componentstacksample}/src/main/resources/base/media/layered_image.json (100%) rename {componentstacklibrary => componentstacksample}/src/main/resources/base/media/startIcon.png (100%) diff --git a/componentstacklibrary/src/main/resources/base/media/layered_image.json b/componentstacksample/src/main/resources/base/media/layered_image.json similarity index 100% rename from componentstacklibrary/src/main/resources/base/media/layered_image.json rename to componentstacksample/src/main/resources/base/media/layered_image.json diff --git a/componentstacklibrary/src/main/resources/base/media/startIcon.png b/componentstacksample/src/main/resources/base/media/startIcon.png similarity index 100% rename from componentstacklibrary/src/main/resources/base/media/startIcon.png rename to componentstacksample/src/main/resources/base/media/startIcon.png -- Gitee From d7be5941f5acaebd55510c366e560dcd53858e64 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 15:30:08 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/component/ComponentStackComponent.ets | 6 +++--- componentstacksample/src/main/module.json5 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets index dabef84..d2de0dd 100644 --- a/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets +++ b/componentstacklibrary/src/main/ets/component/ComponentStackComponent.ets @@ -27,7 +27,7 @@ export struct ComponentStackComponent { @State isChange: boolean = false; @State heightList2: number = CommonConstants.HEIGHT_LIST_2_RAW; @State marginSpace: number = CommonConstants.MAX_MARGIN_SPACE; - @StorageLink(CommonConstants.KEY_PREFIX + 'statusBarHeight') statusHeight: number = 0; + @StorageLink(CommonConstants.KEY_PREFIX + 'statusBarHeight') statusBarHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'navigatorBarHeight') navigatorBarHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'screenHeight') screenHeight: number = 0; @StorageLink(CommonConstants.KEY_PREFIX + 'currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @@ -107,7 +107,7 @@ export struct ComponentStackComponent { ProductList() .width(CommonConstants.FULL_PERCENT) - .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.navigatorBarHeight) - + .height(this.getUIContext().px2vp(this.screenHeight - this.statusBarHeight - this.navigatorBarHeight) - CommonConstants.USED_SPACE) } .margin({ top: CommonConstants.MARGIN_TOP }) @@ -169,7 +169,7 @@ export struct ComponentStackComponent { .layoutWeight(1) .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: this.statusHeight, + top: this.statusBarHeight, left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : diff --git a/componentstacksample/src/main/module.json5 b/componentstacksample/src/main/module.json5 index f3d8c7c..3342dca 100644 --- a/componentstacksample/src/main/module.json5 +++ b/componentstacksample/src/main/module.json5 @@ -9,7 +9,7 @@ "tablet", "2in1" ], - "deliveryWithInstall": true, + "deliveryWithInstall": false, "installationFree": false, "pages": "$profile:main_pages", "abilities": [ -- Gitee From 3bd5897f699e9706636c02055b7c5ce4e5ab08e3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 15:36:26 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/base/media/background.png | Bin .../src/main/resources/base/media/foreground.png | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename {componentstacklibrary => componentstacksample}/src/main/resources/base/media/background.png (100%) rename {componentstacklibrary => componentstacksample}/src/main/resources/base/media/foreground.png (100%) diff --git a/componentstacklibrary/src/main/resources/base/media/background.png b/componentstacksample/src/main/resources/base/media/background.png similarity index 100% rename from componentstacklibrary/src/main/resources/base/media/background.png rename to componentstacksample/src/main/resources/base/media/background.png diff --git a/componentstacklibrary/src/main/resources/base/media/foreground.png b/componentstacksample/src/main/resources/base/media/foreground.png similarity index 100% rename from componentstacklibrary/src/main/resources/base/media/foreground.png rename to componentstacksample/src/main/resources/base/media/foreground.png -- Gitee From d24c0f24d32d811b1a493ed9c2e882957d7e3e4c Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 15:47:34 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/utils/WindowUtil.ets | 2 +- .../main/resources/base/element/string.json | 8 -- .../main/resources/en_US/element/string.json | 8 -- .../main/resources/zh_CN/element/string.json | 16 --- .../main/resources/base/element/color.json | 16 +++ .../main/resources/base/element/integer.json | 136 ++++++++++++++++++ .../main/resources/base/element/string.json | 12 ++ .../main/resources/en_US/element/string.json | 12 ++ .../main/resources/zh_CN/element/string.json | 12 ++ 9 files changed, 189 insertions(+), 33 deletions(-) create mode 100644 componentstacksample/src/main/resources/base/element/color.json create mode 100644 componentstacksample/src/main/resources/base/element/integer.json create mode 100644 componentstacksample/src/main/resources/base/element/string.json create mode 100644 componentstacksample/src/main/resources/en_US/element/string.json create mode 100644 componentstacksample/src/main/resources/zh_CN/element/string.json diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index d232b78..4bfe060 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -51,7 +51,7 @@ export class WindowUtil { promise.then(() => { hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { - hilog.info(0x0000, TAG, + hilog.error(0x0000, TAG, `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); }); } catch { diff --git a/componentstacklibrary/src/main/resources/base/element/string.json b/componentstacklibrary/src/main/resources/base/element/string.json index c367070..2cbb281 100644 --- a/componentstacklibrary/src/main/resources/base/element/string.json +++ b/componentstacklibrary/src/main/resources/base/element/string.json @@ -1,13 +1,5 @@ { "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, { "name": "EntryAbility_label", "value": "组件堆叠" diff --git a/componentstacklibrary/src/main/resources/en_US/element/string.json b/componentstacklibrary/src/main/resources/en_US/element/string.json index a117d4a..554431f 100644 --- a/componentstacklibrary/src/main/resources/en_US/element/string.json +++ b/componentstacklibrary/src/main/resources/en_US/element/string.json @@ -1,13 +1,5 @@ { "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, { "name": "EntryAbility_label", "value": "Component stacking" diff --git a/componentstacklibrary/src/main/resources/zh_CN/element/string.json b/componentstacklibrary/src/main/resources/zh_CN/element/string.json index c367070..bc32604 100644 --- a/componentstacklibrary/src/main/resources/zh_CN/element/string.json +++ b/componentstacklibrary/src/main/resources/zh_CN/element/string.json @@ -1,21 +1,5 @@ { "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "组件堆叠" - }, - { - "name": "product_title00", - "value": "充电宝" - }, { "name": "product_title01", "value": "笔记本电脑" diff --git a/componentstacksample/src/main/resources/base/element/color.json b/componentstacksample/src/main/resources/base/element/color.json new file mode 100644 index 0000000..0fd74c8 --- /dev/null +++ b/componentstacksample/src/main/resources/base/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "ohos_id_color_list_alert", + "value": "#ED6F21" + }, + { + "name": "ohos_id_color_warning", + "value": "#E84026" + } + ] +} \ No newline at end of file diff --git a/componentstacksample/src/main/resources/base/element/integer.json b/componentstacksample/src/main/resources/base/element/integer.json new file mode 100644 index 0000000..5188f52 --- /dev/null +++ b/componentstacksample/src/main/resources/base/element/integer.json @@ -0,0 +1,136 @@ +{ + "integer": [ + { + "name": "user_portrait_width", + "value": 30 + }, + { + "name": "search_font_size", + "value": 16 + }, + { + "name": "flex_padding_top", + "value": 5 + }, + { + "name": "flex_height", + "value": 50 + }, + { + "name": "search_width", + "value": 24 + }, + { + "name": "search_icon_margin_left", + "value": 20 + }, + { + "name": "search_text_margin_left", + "value": 10 + }, + { + "name": "search_border_radius", + "value": 12 + }, + { + "name": "icon_list_height3", + "value": 110 + }, + { + "name": "icon_list_height1", + "value": 200 + }, + { + "name": "margin_search_view", + "value": 50 + }, + { + "name": "icon_view_width", + "value": 40 + }, + { + "name": "icon_view_width2", + "value": 50 + }, + { + "name": "icon_view_image_width", + "value": 120 + }, + { + "name": "icon_view_padding_right", + "value": 20 + }, + { + "name": "icon_view_height", + "value": 90 + }, + { + "name": "icon_view_height2", + "value": 85 + }, + { + "name": "icon_view_height3", + "value": 70 + }, + { + "name": "icon_view_border_radius", + "value": 10 + }, + { + "name": "icon_view_image_margin_left", + "value": 20 + }, + { + "name": "water_flow_image_margin_top", + "value": 5 + }, + { + "name": "water_flow_title_font_size", + "value": 16 + }, + { + "name": "water_flow_price_font_size", + "value": 20 + }, + { + "name": "water_flow_insurance_font_size", + "value": 12 + }, + { + "name": "water_flow_insurance_border_width", + "value": 1 + }, + { + "name": "water_flow_insurance_border_radius", + "value": 4 + }, + { + "name": "water_flow_insurance_padding_horizontal", + "value": 8 + }, + { + "name": "water_flow_insurance_padding_vertical", + "value": 3 + }, + { + "name": "water_flow_insurance_margin_top", + "value": 10 + }, + { + "name": "water_flow_column_padding_left", + "value": 20 + }, + { + "name": "water_flow_column_height", + "value": 250 + }, + { + "name": "water_flow_column_border_radius", + "value": 10 + }, + { + "name": "water_flow_padding_bottom", + "value": 80 + } + ] +} \ No newline at end of file diff --git a/componentstacksample/src/main/resources/base/element/string.json b/componentstacksample/src/main/resources/base/element/string.json new file mode 100644 index 0000000..a03dbe2 --- /dev/null +++ b/componentstacksample/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/componentstacksample/src/main/resources/en_US/element/string.json b/componentstacksample/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..a03dbe2 --- /dev/null +++ b/componentstacksample/src/main/resources/en_US/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/componentstacksample/src/main/resources/zh_CN/element/string.json b/componentstacksample/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..3db26fc --- /dev/null +++ b/componentstacksample/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "EntryAbility_label", + "value": "组件堆叠" + }, + { + "name": "product_title00", + "value": "充电宝" + } + ] +} \ No newline at end of file -- Gitee From e15e36d67bf6abc4e022e09cc54cee4e2dd61a8d Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 16:12:49 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/base/element/color.json | 4 - .../main/resources/base/element/color.json | 8 -- .../main/resources/base/element/integer.json | 136 ------------------ 3 files changed, 148 deletions(-) delete mode 100644 componentstacksample/src/main/resources/base/element/integer.json diff --git a/componentstacklibrary/src/main/resources/base/element/color.json b/componentstacklibrary/src/main/resources/base/element/color.json index 0fd74c8..c828f7e 100644 --- a/componentstacklibrary/src/main/resources/base/element/color.json +++ b/componentstacklibrary/src/main/resources/base/element/color.json @@ -1,9 +1,5 @@ { "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - }, { "name": "ohos_id_color_list_alert", "value": "#ED6F21" diff --git a/componentstacksample/src/main/resources/base/element/color.json b/componentstacksample/src/main/resources/base/element/color.json index 0fd74c8..3c71296 100644 --- a/componentstacksample/src/main/resources/base/element/color.json +++ b/componentstacksample/src/main/resources/base/element/color.json @@ -3,14 +3,6 @@ { "name": "start_window_background", "value": "#FFFFFF" - }, - { - "name": "ohos_id_color_list_alert", - "value": "#ED6F21" - }, - { - "name": "ohos_id_color_warning", - "value": "#E84026" } ] } \ No newline at end of file diff --git a/componentstacksample/src/main/resources/base/element/integer.json b/componentstacksample/src/main/resources/base/element/integer.json deleted file mode 100644 index 5188f52..0000000 --- a/componentstacksample/src/main/resources/base/element/integer.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "integer": [ - { - "name": "user_portrait_width", - "value": 30 - }, - { - "name": "search_font_size", - "value": 16 - }, - { - "name": "flex_padding_top", - "value": 5 - }, - { - "name": "flex_height", - "value": 50 - }, - { - "name": "search_width", - "value": 24 - }, - { - "name": "search_icon_margin_left", - "value": 20 - }, - { - "name": "search_text_margin_left", - "value": 10 - }, - { - "name": "search_border_radius", - "value": 12 - }, - { - "name": "icon_list_height3", - "value": 110 - }, - { - "name": "icon_list_height1", - "value": 200 - }, - { - "name": "margin_search_view", - "value": 50 - }, - { - "name": "icon_view_width", - "value": 40 - }, - { - "name": "icon_view_width2", - "value": 50 - }, - { - "name": "icon_view_image_width", - "value": 120 - }, - { - "name": "icon_view_padding_right", - "value": 20 - }, - { - "name": "icon_view_height", - "value": 90 - }, - { - "name": "icon_view_height2", - "value": 85 - }, - { - "name": "icon_view_height3", - "value": 70 - }, - { - "name": "icon_view_border_radius", - "value": 10 - }, - { - "name": "icon_view_image_margin_left", - "value": 20 - }, - { - "name": "water_flow_image_margin_top", - "value": 5 - }, - { - "name": "water_flow_title_font_size", - "value": 16 - }, - { - "name": "water_flow_price_font_size", - "value": 20 - }, - { - "name": "water_flow_insurance_font_size", - "value": 12 - }, - { - "name": "water_flow_insurance_border_width", - "value": 1 - }, - { - "name": "water_flow_insurance_border_radius", - "value": 4 - }, - { - "name": "water_flow_insurance_padding_horizontal", - "value": 8 - }, - { - "name": "water_flow_insurance_padding_vertical", - "value": 3 - }, - { - "name": "water_flow_insurance_margin_top", - "value": 10 - }, - { - "name": "water_flow_column_padding_left", - "value": 20 - }, - { - "name": "water_flow_column_height", - "value": 250 - }, - { - "name": "water_flow_column_border_radius", - "value": 10 - }, - { - "name": "water_flow_padding_bottom", - "value": 80 - } - ] -} \ No newline at end of file -- Gitee From c07a0d056644509e4eb67dedab113b136fc79b09 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 16:26:24 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/base/element/string.json | 8 -------- .../src/main/resources/en_US/element/string.json | 8 -------- .../src/main/resources/base/element/string.json | 8 ++++++++ .../src/main/resources/en_US/element/string.json | 8 ++++++++ .../src/main/resources/zh_CN/element/string.json | 8 ++++++++ 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/componentstacklibrary/src/main/resources/base/element/string.json b/componentstacklibrary/src/main/resources/base/element/string.json index 2cbb281..bc32604 100644 --- a/componentstacklibrary/src/main/resources/base/element/string.json +++ b/componentstacklibrary/src/main/resources/base/element/string.json @@ -1,13 +1,5 @@ { "string": [ - { - "name": "EntryAbility_label", - "value": "组件堆叠" - }, - { - "name": "product_title00", - "value": "充电宝" - }, { "name": "product_title01", "value": "笔记本电脑" diff --git a/componentstacklibrary/src/main/resources/en_US/element/string.json b/componentstacklibrary/src/main/resources/en_US/element/string.json index 554431f..f3cda33 100644 --- a/componentstacklibrary/src/main/resources/en_US/element/string.json +++ b/componentstacklibrary/src/main/resources/en_US/element/string.json @@ -1,13 +1,5 @@ { "string": [ - { - "name": "EntryAbility_label", - "value": "Component stacking" - }, - { - "name": "product_title00", - "value": "powerbank" - }, { "name": "product_title01", "value": "laptop" diff --git a/componentstacksample/src/main/resources/base/element/string.json b/componentstacksample/src/main/resources/base/element/string.json index a03dbe2..9c08197 100644 --- a/componentstacksample/src/main/resources/base/element/string.json +++ b/componentstacksample/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "EntryAbility_desc", "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "组件堆叠" + }, + { + "name": "product_title00", + "value": "充电宝" } ] } \ No newline at end of file diff --git a/componentstacksample/src/main/resources/en_US/element/string.json b/componentstacksample/src/main/resources/en_US/element/string.json index a03dbe2..3ddc584 100644 --- a/componentstacksample/src/main/resources/en_US/element/string.json +++ b/componentstacksample/src/main/resources/en_US/element/string.json @@ -7,6 +7,14 @@ { "name": "EntryAbility_desc", "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Component stacking" + }, + { + "name": "product_title00", + "value": "powerbank" } ] } \ No newline at end of file diff --git a/componentstacksample/src/main/resources/zh_CN/element/string.json b/componentstacksample/src/main/resources/zh_CN/element/string.json index 3db26fc..9c08197 100644 --- a/componentstacksample/src/main/resources/zh_CN/element/string.json +++ b/componentstacksample/src/main/resources/zh_CN/element/string.json @@ -1,5 +1,13 @@ { "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, { "name": "EntryAbility_label", "value": "组件堆叠" -- Gitee From f97214c2e083e397dc4940581e74c32383c94031 Mon Sep 17 00:00:00 2001 From: "DESKTOP-9FJNTIC\\gyb" <121287102@qq.com> Date: Wed, 16 Jul 2025 17:06:14 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/ComponentStackController.ets | 6 +++++- .../src/main/ets/utils/WindowUtil.ets | 12 +++--------- .../src/main/ets/entryability/EntryAbility.ets | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/componentstacklibrary/src/main/ets/ComponentStackController.ets b/componentstacklibrary/src/main/ets/ComponentStackController.ets index 919bf38..cf9a4f6 100644 --- a/componentstacklibrary/src/main/ets/ComponentStackController.ets +++ b/componentstacklibrary/src/main/ets/ComponentStackController.ets @@ -15,10 +15,14 @@ import { window } from '@kit.ArkUI'; import { WindowUtil } from './utils/WindowUtil'; - +import { common } from '@kit.AbilityKit'; export class ComponentStackController { public static initWindowConfig(windowStage: window.WindowStage): void { WindowUtil.initialize(windowStage); } + + public static updatedColorMode(context: common.UIAbilityContext): void { + WindowUtil.updatedColorMode(context); + } } \ No newline at end of file diff --git a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets index 4bfe060..6a37e2b 100644 --- a/componentstacklibrary/src/main/ets/utils/WindowUtil.ets +++ b/componentstacklibrary/src/main/ets/utils/WindowUtil.ets @@ -16,7 +16,7 @@ import { window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { Configuration, ConfigurationConstant } from '@kit.AbilityKit'; +import { common, Configuration, ConfigurationConstant } from '@kit.AbilityKit'; import { CommonConstants } from '../constants/CommonConstants'; import { BreakpointSystem } from './BreakpointSystem'; @@ -95,13 +95,7 @@ export class WindowUtil { } } - public static updatedColorMode(newConfig: Configuration): void { - let newColorMode: ConfigurationConstant.ColorMode = - newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = - AppStorage.get(CommonConstants.KEY_PREFIX + 'systemColorMode'); - if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate(CommonConstants.KEY_PREFIX + 'systemColorMode', newColorMode); - } + public static updatedColorMode(context: common.UIAbilityContext): void { + context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } } \ No newline at end of file diff --git a/componentstacksample/src/main/ets/entryability/EntryAbility.ets b/componentstacksample/src/main/ets/entryability/EntryAbility.ets index b8c5c7d..3b0c2e1 100644 --- a/componentstacksample/src/main/ets/entryability/EntryAbility.ets +++ b/componentstacksample/src/main/ets/entryability/EntryAbility.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Configuration, UIAbility } from '@kit.AbilityKit'; +import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; import { ComponentStackController } from 'componentstacklibrary'; @@ -24,6 +24,7 @@ export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate'); + ComponentStackController.updatedColorMode(this.context); } onDestroy(): void { -- Gitee