From e8452500c430635fe2732f37650bbb5460be41b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=A4=A7=E4=BE=A0?= <794397348@qq.com> Date: Sat, 24 May 2025 14:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=B8=BF=E8=92=99=E4=B8=96=E7=95=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 8 +- .../main/ets/common/utils/BreakpointType.ets | 42 ------- .../main/resources/base/element/color.json | 8 -- .../resources/base/profile/backup_config.json | 3 - multinavbarlibrary/.gitignore | 6 + multinavbarlibrary/BuildProfile.ets | 17 +++ multinavbarlibrary/Index.ets | 1 + multinavbarlibrary/build-profile.json5 | 28 +++++ multinavbarlibrary/consumer-rules.txt | 0 multinavbarlibrary/hvigorfile.ts | 6 + multinavbarlibrary/obfuscation-rules.txt | 23 ++++ .../oh-package.json5 | 7 +- .../ets/common/utils/BreakpointSystem.ets | 118 ++++++++++++++++++ .../src/main/ets/common/utils/WindowUtils.ets | 89 +++++++------ .../src/main/ets/model/TabDataModel.ets | 0 .../src/main/ets/model/VideoDataModel.ets | 0 .../src/main/ets/pages/MultiNavBarPage.ets | 13 ++ .../src/main/ets/view/Home.ets | 0 .../src/main/ets/view/SideBarView.ets | 0 .../src/main/ets/view/TopTabView.ets | 8 +- .../src/main/ets/view/VideoInfoView.ets | 16 +-- .../src/main/ets/viewmodel/TabViewModel.ets | 0 .../src/main/ets/viewmodel/VideoViewModel.ets | 0 multinavbarlibrary/src/main/module.json5 | 11 ++ .../main/resources/base}/element/color.json | 0 .../main/resources/base/element/string.json | 0 .../main/resources/base/media/arrow_down.png | Bin .../main/resources/base/media/background.png | Bin .../main/resources/base/media/chevron_up.svg | 0 .../main/resources/base/media/foreground.png | Bin .../main/resources/base/media/ic_video_1.png | Bin .../main/resources/base/media/ic_video_2.png | Bin .../main/resources/base/media/ic_video_3.png | Bin .../main/resources/base/media/ic_video_4.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../build-profile.json5 | 3 - {entry => multinavbarsample}/hvigorfile.ts | 0 .../obfuscation-rules.txt | 0 multinavbarsample/oh-package.json5 | 11 ++ .../main/ets/entryability/EntryAbility.ets | 32 +---- .../src/main/ets/pages/Index.ets | 8 +- .../src/main/module.json5 | 6 +- .../resources/base/profile/main_pages.json | 0 46 files changed, 306 insertions(+), 158 deletions(-) delete mode 100644 entry/src/main/ets/common/utils/BreakpointType.ets delete mode 100644 entry/src/main/resources/base/element/color.json delete mode 100644 entry/src/main/resources/base/profile/backup_config.json create mode 100644 multinavbarlibrary/.gitignore create mode 100644 multinavbarlibrary/BuildProfile.ets create mode 100644 multinavbarlibrary/Index.ets create mode 100644 multinavbarlibrary/build-profile.json5 create mode 100644 multinavbarlibrary/consumer-rules.txt create mode 100644 multinavbarlibrary/hvigorfile.ts create mode 100644 multinavbarlibrary/obfuscation-rules.txt rename {entry => multinavbarlibrary}/oh-package.json5 (59%) create mode 100644 multinavbarlibrary/src/main/ets/common/utils/BreakpointSystem.ets rename {entry => multinavbarlibrary}/src/main/ets/common/utils/WindowUtils.ets (31%) rename {entry => multinavbarlibrary}/src/main/ets/model/TabDataModel.ets (100%) rename {entry => multinavbarlibrary}/src/main/ets/model/VideoDataModel.ets (100%) create mode 100644 multinavbarlibrary/src/main/ets/pages/MultiNavBarPage.ets rename {entry => multinavbarlibrary}/src/main/ets/view/Home.ets (100%) rename {entry => multinavbarlibrary}/src/main/ets/view/SideBarView.ets (100%) rename {entry => multinavbarlibrary}/src/main/ets/view/TopTabView.ets (87%) rename {entry => multinavbarlibrary}/src/main/ets/view/VideoInfoView.ets (71%) rename {entry => multinavbarlibrary}/src/main/ets/viewmodel/TabViewModel.ets (100%) rename {entry => multinavbarlibrary}/src/main/ets/viewmodel/VideoViewModel.ets (100%) create mode 100644 multinavbarlibrary/src/main/module.json5 rename {entry/src/main/resources/dark => multinavbarlibrary/src/main/resources/base}/element/color.json (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/element/string.json (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/arrow_down.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/background.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/chevron_up.svg (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/foreground.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/ic_video_1.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/ic_video_2.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/ic_video_3.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/ic_video_4.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/layered_image.json (100%) rename {entry => multinavbarlibrary}/src/main/resources/base/media/startIcon.png (100%) rename {entry => multinavbarlibrary}/src/main/resources/en_US/element/string.json (100%) rename {entry => multinavbarlibrary}/src/main/resources/zh_CN/element/string.json (100%) rename {entry => multinavbarsample}/build-profile.json5 (90%) rename {entry => multinavbarsample}/hvigorfile.ts (100%) rename {entry => multinavbarsample}/obfuscation-rules.txt (100%) create mode 100644 multinavbarsample/oh-package.json5 rename {entry => multinavbarsample}/src/main/ets/entryability/EntryAbility.ets (50%) rename {entry => multinavbarsample}/src/main/ets/pages/Index.ets (86%) rename {entry => multinavbarsample}/src/main/module.json5 (89%) rename {entry => multinavbarsample}/src/main/resources/base/profile/main_pages.json (100%) diff --git a/build-profile.json5 b/build-profile.json5 index 1e69556..e583120 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -26,8 +26,8 @@ }, "modules": [ { - "name": "entry", - "srcPath": "./entry", + "name": "multinavbarsample", + "srcPath": "./multinavbarsample", "targets": [ { "name": "default", @@ -36,6 +36,10 @@ ] } ] + }, + { + "name": "multinavbarlibrary", + "srcPath": "./multinavbarlibrary", } ] } \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/BreakpointType.ets b/entry/src/main/ets/common/utils/BreakpointType.ets deleted file mode 100644 index 698ace5..0000000 --- a/entry/src/main/ets/common/utils/BreakpointType.ets +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2025 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 BreakpointType { - private sm: T; - private md: T; - private lg: T; - private xl: T; - - constructor(sm: T, md: T, lg: T, xl: T) { - this.sm = sm; - this.md = md; - this.lg = lg; - this.xl = xl; - } - - getValue(currentWidthBreakpoint: string): T { - let result: T; - if (currentWidthBreakpoint === 'sm') { - result = this.sm; - } else if (currentWidthBreakpoint === 'md') { - result = this.md; - } else if (currentWidthBreakpoint === 'lg') { - result = this.lg; - } else { - result = this.xl; - } - return result; - } -} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 3c71296..0000000 --- a/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100644 index 78f40ae..0000000 --- a/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/multinavbarlibrary/.gitignore b/multinavbarlibrary/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/multinavbarlibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/multinavbarlibrary/BuildProfile.ets b/multinavbarlibrary/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/multinavbarlibrary/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/multinavbarlibrary/Index.ets b/multinavbarlibrary/Index.ets new file mode 100644 index 0000000..49ca810 --- /dev/null +++ b/multinavbarlibrary/Index.ets @@ -0,0 +1 @@ +export { MultiNavBarPage } from './src/main/ets/pages/MultiNavBarPage'; diff --git a/multinavbarlibrary/build-profile.json5 b/multinavbarlibrary/build-profile.json5 new file mode 100644 index 0000000..312d38e --- /dev/null +++ b/multinavbarlibrary/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/multinavbarlibrary/consumer-rules.txt b/multinavbarlibrary/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/multinavbarlibrary/hvigorfile.ts b/multinavbarlibrary/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/multinavbarlibrary/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/multinavbarlibrary/obfuscation-rules.txt b/multinavbarlibrary/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/multinavbarlibrary/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/multinavbarlibrary/oh-package.json5 similarity index 59% rename from entry/oh-package.json5 rename to multinavbarlibrary/oh-package.json5 index 248c3b7..fcc72a9 100644 --- a/entry/oh-package.json5 +++ b/multinavbarlibrary/oh-package.json5 @@ -1,10 +1,9 @@ { - "name": "entry", + "name": "multinavbarlibrary", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "", + "main": "Index.ets", "author": "", - "license": "", + "license": "Apache-2.0", "dependencies": {} } - diff --git a/multinavbarlibrary/src/main/ets/common/utils/BreakpointSystem.ets b/multinavbarlibrary/src/main/ets/common/utils/BreakpointSystem.ets new file mode 100644 index 0000000..0799771 --- /dev/null +++ b/multinavbarlibrary/src/main/ets/common/utils/BreakpointSystem.ets @@ -0,0 +1,118 @@ +/* + * 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 type { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[BreakpointSystem]'; + +export enum BreakpointTypeEnum { + XS = 'xs', + SM = 'sm', + MD = 'md', + LG = 'lg', + XL = 'xl', +} + +export interface BreakpointTypes { + xs?: T; + sm: T; + md: T; + lg: T; + xl: T; +} + +export class BreakpointType { + private xs: T; + private sm: T; + private md: T; + private lg: T; + private xl: T; + + public constructor(param: BreakpointTypes) { + this.xs = param.xs || param.sm; + this.sm = param.sm; + this.md = param.md; + this.lg = param.lg; + this.xl = param.xl; + } + + public getValue(currentBreakpoint: string): T { + if (currentBreakpoint === BreakpointTypeEnum.XS) { + return this.xs; + } + if (currentBreakpoint === BreakpointTypeEnum.SM) { + return this.sm; + } + if (currentBreakpoint === BreakpointTypeEnum.MD) { + return this.md; + } + if (currentBreakpoint === BreakpointTypeEnum.XL) { + return this.xl; + } + return this.lg; + } +} + +export class BreakpointSystem { + private static instance: BreakpointSystem; + private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.MD; + + private constructor() { + } + + public static getInstance(): BreakpointSystem { + if (!BreakpointSystem.instance) { + BreakpointSystem.instance = new BreakpointSystem(); + } + return BreakpointSystem.instance; + } + + public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { + if (this.currentBreakpoint !== breakpoint) { + this.currentBreakpoint = breakpoint; + AppStorage.setOrCreate('currentWidthBreakpoint', this.currentBreakpoint); + } + } + + public onWindowSizeChange(window: window.Window): void { + this.updateWidthBp(window); + } + + public updateWidthBp(window: window.Window): void { + try { + const mainWindow: window.WindowProperties = window.getWindowProperties(); + const windowWidth: number = mainWindow.windowRect.width; + const windowWidthVp = px2vp(windowWidth); + let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.MD; + if (windowWidthVp < 320) { + widthBp = BreakpointTypeEnum.XS; + } else if (windowWidthVp >= 320 && windowWidthVp < 600) { + widthBp = BreakpointTypeEnum.SM; + } else if (windowWidthVp >= 600 && windowWidthVp < 840) { + widthBp = BreakpointTypeEnum.MD; + } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { + widthBp = BreakpointTypeEnum.LG; + } else { + widthBp = BreakpointTypeEnum.XL; + } + this.updateCurrentBreakpoint(widthBp); + } catch (error) { + const err: BusinessError = error as BusinessError; + hilog.error(0x0000, TAG, `UpdateBreakpoint fail, error code: ${err.code}, message: ${err.message}`); + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/WindowUtils.ets b/multinavbarlibrary/src/main/ets/common/utils/WindowUtils.ets similarity index 31% rename from entry/src/main/ets/common/utils/WindowUtils.ets rename to multinavbarlibrary/src/main/ets/common/utils/WindowUtils.ets index a6cbf22..dd767c0 100644 --- a/entry/src/main/ets/common/utils/WindowUtils.ets +++ b/multinavbarlibrary/src/main/ets/common/utils/WindowUtils.ets @@ -16,64 +16,61 @@ import { window } from '@kit.ArkUI'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BreakpointSystem } from './BreakpointSystem'; const TAG: string = '[WindowUtil]'; export class WindowUtil { - static getInstance(): WindowUtil | undefined { - if (!AppStorage.get('windowUtil')) { - AppStorage.setOrCreate('windowUtil', new WindowUtil()); - } else { - hilog.info(0x0000, TAG, 'WindowUtil already exists.'); - } - return AppStorage.get('windowUtil'); - } - - static setStatusBarHeight(context: Context, avoidArea?: window.AvoidArea): void { - window.getLastWindow(context).then((data: window.Window) => { + public static requestFullScreen(windowStage: window.WindowStage): void { + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + if (err.code) { + return; + } + const windowClass: window.Window = data; + // Realize the immersive effect. try { - let naviBarArea: window.AvoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); - let statusBarHeight: number = 0; - let naviIndicatorHeight: number = 0; - if (avoidArea) { - statusBarHeight = avoidArea.topRect.height; - } else { - let area: window.AvoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - statusBarHeight = area.topRect.height; - } - statusBarHeight = px2vp(statusBarHeight); - naviIndicatorHeight = px2vp(naviBarArea.bottomRect.height); - AppStorage.setOrCreate('statusBarHeight', statusBarHeight); - AppStorage.setOrCreate('naviIndicatorHeight', naviIndicatorHeight); - } catch (error) { - hilog.error(0x0000, TAG, 'Get and set DeviceSize failed. Cause: ' + (error as BusinessError).message); + const promise: Promise = windowClass.setWindowLayoutFullScreen(true); + promise.then(() => { + hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.info(0x0000, TAG, + `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. '); } - }).catch((error: BusinessError) => { - hilog.error(0x0000, TAG, `Failed to get last window. Cause: ${error.message}`); }); } - updateWidthBp(windowWidth: number): void { - try { - let windowWidthVp = px2vp(windowWidth); - if (deviceInfo.deviceType === '2in1') { - windowWidthVp -= 2 * 5.4; + public static registerBreakPoint(windowStage: window.WindowStage) { + windowStage.getMainWindow((err: BusinessError, data: window.Window) => { + if (err.code) { + hilog.error(0x0000, TAG, `Failed to get main window: ${err.message}`); + return; } - let widthBp: string = ''; - if (windowWidthVp < 320) { - widthBp = 'xs'; - } else if (windowWidthVp >= 320 && windowWidthVp < 600) { - widthBp = 'sm'; - } else if (windowWidthVp >= 600 && windowWidthVp < 840) { - widthBp = 'md'; - } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { - widthBp = 'lg'; + BreakpointSystem.getInstance().updateWidthBp(data); + data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); + if (deviceInfo.deviceType === '2in1') { + data.setWindowDecorVisible(false); + data.setWindowDecorHeight(64); } else { - widthBp = 'xl'; + WindowUtil.requestFullScreen(windowStage) + data.on('avoidAreaChange', (avoidAreaOption) => { + if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || + avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); + } + }); } - AppStorage.setOrCreate('currentWidthBreakpoint', widthBp); - } catch (error) { - hilog.error(0x0000, TAG, 'updateWidthBp failed. Cause: ' + (error as BusinessError).message); + }) + } + + // Get status bar height and indicator height. + public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { + if (type === window.AvoidAreaType.TYPE_SYSTEM) { + AppStorage.setOrCreate('statusBarHeight', px2vp(area.topRect.height)); + } else { + AppStorage.setOrCreate('naviIndicatorHeight', px2vp(area.bottomRect.height)); } } } \ No newline at end of file diff --git a/entry/src/main/ets/model/TabDataModel.ets b/multinavbarlibrary/src/main/ets/model/TabDataModel.ets similarity index 100% rename from entry/src/main/ets/model/TabDataModel.ets rename to multinavbarlibrary/src/main/ets/model/TabDataModel.ets diff --git a/entry/src/main/ets/model/VideoDataModel.ets b/multinavbarlibrary/src/main/ets/model/VideoDataModel.ets similarity index 100% rename from entry/src/main/ets/model/VideoDataModel.ets rename to multinavbarlibrary/src/main/ets/model/VideoDataModel.ets diff --git a/multinavbarlibrary/src/main/ets/pages/MultiNavBarPage.ets b/multinavbarlibrary/src/main/ets/pages/MultiNavBarPage.ets new file mode 100644 index 0000000..1ea96f0 --- /dev/null +++ b/multinavbarlibrary/src/main/ets/pages/MultiNavBarPage.ets @@ -0,0 +1,13 @@ +import { Home } from "../view/Home" + +@Component +export struct MultiNavBarPage { + + build() { + Column() { + Home() + } + .width('100%') + .height('100%') + } +} diff --git a/entry/src/main/ets/view/Home.ets b/multinavbarlibrary/src/main/ets/view/Home.ets similarity index 100% rename from entry/src/main/ets/view/Home.ets rename to multinavbarlibrary/src/main/ets/view/Home.ets diff --git a/entry/src/main/ets/view/SideBarView.ets b/multinavbarlibrary/src/main/ets/view/SideBarView.ets similarity index 100% rename from entry/src/main/ets/view/SideBarView.ets rename to multinavbarlibrary/src/main/ets/view/SideBarView.ets diff --git a/entry/src/main/ets/view/TopTabView.ets b/multinavbarlibrary/src/main/ets/view/TopTabView.ets similarity index 87% rename from entry/src/main/ets/view/TopTabView.ets rename to multinavbarlibrary/src/main/ets/view/TopTabView.ets index e10257f..c0b9a42 100644 --- a/entry/src/main/ets/view/TopTabView.ets +++ b/multinavbarlibrary/src/main/ets/view/TopTabView.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointType } from '../common/utils/BreakpointType'; +import { BreakpointType } from '../common/utils/BreakpointSystem'; import { TabDataModel } from '../model/TabDataModel'; import { VideoInfoView } from './VideoInfoView'; import { hilog } from '@kit.PerformanceAnalysisKit'; @@ -53,7 +53,7 @@ export struct TopTabView { } .align(Alignment.Center) .padding({ - right: new BreakpointType(8, 12, 18, 0).getValue(this.currentWidthBreakpoint) + right: new BreakpointType({sm:8, md:12, lg:18, xl:0}).getValue(this.currentWidthBreakpoint) }) .onClick(() => { this.secondLevelIndex = index; @@ -63,8 +63,8 @@ export struct TopTabView { .scrollBar(BarState.Off) .listDirection(Axis.Horizontal) .padding({ - left: new BreakpointType(16, 24, 36, 24).getValue(this.currentWidthBreakpoint), - right: new BreakpointType(16, 24, 36, 24).getValue(this.currentWidthBreakpoint), + left: new BreakpointType({sm:16, md:24, lg:36, xl:24}).getValue(this.currentWidthBreakpoint), + right: new BreakpointType({sm:16, md:24, lg:36, xl:24}).getValue(this.currentWidthBreakpoint), top: $r('sys.float.padding_level5') }) .height(56) diff --git a/entry/src/main/ets/view/VideoInfoView.ets b/multinavbarlibrary/src/main/ets/view/VideoInfoView.ets similarity index 71% rename from entry/src/main/ets/view/VideoInfoView.ets rename to multinavbarlibrary/src/main/ets/view/VideoInfoView.ets index cf22a2f..da7f559 100644 --- a/entry/src/main/ets/view/VideoInfoView.ets +++ b/multinavbarlibrary/src/main/ets/view/VideoInfoView.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BreakpointType } from '../common/utils/BreakpointType'; +import { BreakpointType } from '../common/utils/BreakpointSystem'; import { VideoViewModel } from '../viewmodel/VideoViewModel'; @Component @@ -39,7 +39,7 @@ export struct VideoInfoView { .borderRadius(12) .backgroundColor($r('sys.color.ohos_id_color_click_effect')) .margin({ - top: new BreakpointType(10, 10, 12, 11).getValue(this.currentWidthBreakpoint), + top: new BreakpointType({sm:10, md:10, lg:12, xl:11}).getValue(this.currentWidthBreakpoint), bottom: 6 }) @@ -57,16 +57,16 @@ export struct VideoInfoView { } .layoutWeight(1) .scrollBar(BarState.Off) - .columnsTemplate(new BreakpointType('1fr 1fr', '1fr 1fr 1fr', '1fr 1fr 1fr 1fr', '1fr 1fr 1fr') + .columnsTemplate(new BreakpointType({sm:'1fr 1fr', md:'1fr 1fr 1fr', lg:'1fr 1fr 1fr 1fr', xl:'1fr 1fr 1fr'}) .getValue(this.currentWidthBreakpoint)) .width('100%') - .rowsGap(new BreakpointType(12, 16, 16, 16).getValue(this.currentWidthBreakpoint)) - .columnsGap(new BreakpointType(16, 12, 16, 16).getValue(this.currentWidthBreakpoint)) + .rowsGap(new BreakpointType({sm:12, md:16, lg:16, xl:16}).getValue(this.currentWidthBreakpoint)) + .columnsGap(new BreakpointType({sm:16, md:12, lg:16, xl:16}).getValue(this.currentWidthBreakpoint)) .padding({ - left: new BreakpointType(16, 24, 36, 24).getValue(this.currentWidthBreakpoint), - right: new BreakpointType(16, 24, 36, 24).getValue(this.currentWidthBreakpoint), + left: new BreakpointType({sm:16, md:24, lg:36, xl:24}).getValue(this.currentWidthBreakpoint), + right: new BreakpointType({sm:16, md:24, lg:36, xl:24}).getValue(this.currentWidthBreakpoint), top: 12, - bottom: new BreakpointType(6, 6, 20, 20).getValue(this.currentWidthBreakpoint) + bottom: new BreakpointType({sm:6, md:6, lg:20, xl:20}).getValue(this.currentWidthBreakpoint) }) } } \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/TabViewModel.ets b/multinavbarlibrary/src/main/ets/viewmodel/TabViewModel.ets similarity index 100% rename from entry/src/main/ets/viewmodel/TabViewModel.ets rename to multinavbarlibrary/src/main/ets/viewmodel/TabViewModel.ets diff --git a/entry/src/main/ets/viewmodel/VideoViewModel.ets b/multinavbarlibrary/src/main/ets/viewmodel/VideoViewModel.ets similarity index 100% rename from entry/src/main/ets/viewmodel/VideoViewModel.ets rename to multinavbarlibrary/src/main/ets/viewmodel/VideoViewModel.ets diff --git a/multinavbarlibrary/src/main/module.json5 b/multinavbarlibrary/src/main/module.json5 new file mode 100644 index 0000000..ef4e58e --- /dev/null +++ b/multinavbarlibrary/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "multinavbarlibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/entry/src/main/resources/dark/element/color.json b/multinavbarlibrary/src/main/resources/base/element/color.json similarity index 100% rename from entry/src/main/resources/dark/element/color.json rename to multinavbarlibrary/src/main/resources/base/element/color.json diff --git a/entry/src/main/resources/base/element/string.json b/multinavbarlibrary/src/main/resources/base/element/string.json similarity index 100% rename from entry/src/main/resources/base/element/string.json rename to multinavbarlibrary/src/main/resources/base/element/string.json diff --git a/entry/src/main/resources/base/media/arrow_down.png b/multinavbarlibrary/src/main/resources/base/media/arrow_down.png similarity index 100% rename from entry/src/main/resources/base/media/arrow_down.png rename to multinavbarlibrary/src/main/resources/base/media/arrow_down.png diff --git a/entry/src/main/resources/base/media/background.png b/multinavbarlibrary/src/main/resources/base/media/background.png similarity index 100% rename from entry/src/main/resources/base/media/background.png rename to multinavbarlibrary/src/main/resources/base/media/background.png diff --git a/entry/src/main/resources/base/media/chevron_up.svg b/multinavbarlibrary/src/main/resources/base/media/chevron_up.svg similarity index 100% rename from entry/src/main/resources/base/media/chevron_up.svg rename to multinavbarlibrary/src/main/resources/base/media/chevron_up.svg diff --git a/entry/src/main/resources/base/media/foreground.png b/multinavbarlibrary/src/main/resources/base/media/foreground.png similarity index 100% rename from entry/src/main/resources/base/media/foreground.png rename to multinavbarlibrary/src/main/resources/base/media/foreground.png diff --git a/entry/src/main/resources/base/media/ic_video_1.png b/multinavbarlibrary/src/main/resources/base/media/ic_video_1.png similarity index 100% rename from entry/src/main/resources/base/media/ic_video_1.png rename to multinavbarlibrary/src/main/resources/base/media/ic_video_1.png diff --git a/entry/src/main/resources/base/media/ic_video_2.png b/multinavbarlibrary/src/main/resources/base/media/ic_video_2.png similarity index 100% rename from entry/src/main/resources/base/media/ic_video_2.png rename to multinavbarlibrary/src/main/resources/base/media/ic_video_2.png diff --git a/entry/src/main/resources/base/media/ic_video_3.png b/multinavbarlibrary/src/main/resources/base/media/ic_video_3.png similarity index 100% rename from entry/src/main/resources/base/media/ic_video_3.png rename to multinavbarlibrary/src/main/resources/base/media/ic_video_3.png diff --git a/entry/src/main/resources/base/media/ic_video_4.png b/multinavbarlibrary/src/main/resources/base/media/ic_video_4.png similarity index 100% rename from entry/src/main/resources/base/media/ic_video_4.png rename to multinavbarlibrary/src/main/resources/base/media/ic_video_4.png diff --git a/entry/src/main/resources/base/media/layered_image.json b/multinavbarlibrary/src/main/resources/base/media/layered_image.json similarity index 100% rename from entry/src/main/resources/base/media/layered_image.json rename to multinavbarlibrary/src/main/resources/base/media/layered_image.json diff --git a/entry/src/main/resources/base/media/startIcon.png b/multinavbarlibrary/src/main/resources/base/media/startIcon.png similarity index 100% rename from entry/src/main/resources/base/media/startIcon.png rename to multinavbarlibrary/src/main/resources/base/media/startIcon.png diff --git a/entry/src/main/resources/en_US/element/string.json b/multinavbarlibrary/src/main/resources/en_US/element/string.json similarity index 100% rename from entry/src/main/resources/en_US/element/string.json rename to multinavbarlibrary/src/main/resources/en_US/element/string.json diff --git a/entry/src/main/resources/zh_CN/element/string.json b/multinavbarlibrary/src/main/resources/zh_CN/element/string.json similarity index 100% rename from entry/src/main/resources/zh_CN/element/string.json rename to multinavbarlibrary/src/main/resources/zh_CN/element/string.json diff --git a/entry/build-profile.json5 b/multinavbarsample/build-profile.json5 similarity index 90% rename from entry/build-profile.json5 rename to multinavbarsample/build-profile.json5 index b695582..808380f 100644 --- a/entry/build-profile.json5 +++ b/multinavbarsample/build-profile.json5 @@ -20,9 +20,6 @@ "targets": [ { "name": "default" - }, - { - "name": "ohosTest", } ] } \ No newline at end of file diff --git a/entry/hvigorfile.ts b/multinavbarsample/hvigorfile.ts similarity index 100% rename from entry/hvigorfile.ts rename to multinavbarsample/hvigorfile.ts diff --git a/entry/obfuscation-rules.txt b/multinavbarsample/obfuscation-rules.txt similarity index 100% rename from entry/obfuscation-rules.txt rename to multinavbarsample/obfuscation-rules.txt diff --git a/multinavbarsample/oh-package.json5 b/multinavbarsample/oh-package.json5 new file mode 100644 index 0000000..82c2342 --- /dev/null +++ b/multinavbarsample/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "multinavbarsample", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "multinavbarlibrary": "file:../multinavbarlibrary" + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/multinavbarsample/src/main/ets/entryability/EntryAbility.ets similarity index 50% rename from entry/src/main/ets/entryability/EntryAbility.ets rename to multinavbarsample/src/main/ets/entryability/EntryAbility.ets index de5da38..c1acff5 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/multinavbarsample/src/main/ets/entryability/EntryAbility.ets @@ -17,12 +17,11 @@ import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { WindowUtil } from '../common/utils/WindowUtils'; +import { WindowUtil } from 'multinavbarlibrary/src/main/ets/common/utils/WindowUtils'; const TAG: string = '[EntryAbility]'; export default class EntryAbility extends UIAbility { - private windowUtil?: WindowUtil = WindowUtil.getInstance(); onCreate(): void { hilog.info(0x0000, TAG, 'Ability onCreate'); @@ -38,33 +37,6 @@ export default class EntryAbility extends UIAbility { } hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); }); - let windowClass: window.Window | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data: window.Window) => { - if (err.code) { - hilog.error(0x0000, TAG, `Failed to get the main window. Cause: ${err.message}`); - return; - } - try { - this.windowUtil!.updateWidthBp(data.getWindowProperties().windowRect.width); - data.on('windowSizeChange', (windowSize) => { - this.windowUtil!.updateWidthBp(windowSize.width); - }); - windowClass = data; - if (deviceInfo.deviceType === '2in1') { - data.setWindowDecorVisible(false); - data.setWindowDecorHeight(64); - } else { - windowClass.setWindowLayoutFullScreen(true).then(() => { - hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, TAG, `Failed to set the window layout to full-screen mode. Cause: ${err.message}`); - }); - let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); - WindowUtil.setStatusBarHeight(this.context, area); - } - } catch (error) { - hilog.error(0x0000, TAG, 'Failed to get the main window. Cause' + (error as BusinessError).message); - } - }); + WindowUtil.registerBreakPoint(windowStage) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/multinavbarsample/src/main/ets/pages/Index.ets similarity index 86% rename from entry/src/main/ets/pages/Index.ets rename to multinavbarsample/src/main/ets/pages/Index.ets index ca14ff7..1d5e4ed 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/multinavbarsample/src/main/ets/pages/Index.ets @@ -13,16 +13,14 @@ * limitations under the License. */ -import { Home } from '../view/Home'; +import { MultiNavBarPage } from 'multinavbarlibrary'; @Entry @Component struct Index { build() { - Column() { - Home() + Stack() { + MultiNavBarPage() } - .width('100%') - .height('100%') } } \ No newline at end of file diff --git a/entry/src/main/module.json5 b/multinavbarsample/src/main/module.json5 similarity index 89% rename from entry/src/main/module.json5 rename to multinavbarsample/src/main/module.json5 index 8bf7660..eedde12 100644 --- a/entry/src/main/module.json5 +++ b/multinavbarsample/src/main/module.json5 @@ -1,6 +1,6 @@ { "module": { - "name": "entry", + "name": "multinavbarsample", "type": "entry", "description": "$string:module_desc", "mainElement": "EntryAbility", @@ -14,14 +14,14 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "EntryAbility", + "name": "MultinavbarsampleAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:layered_image", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", - "exported": false, + "exported": true, "minWindowWidth": 1452, "skills": [ { diff --git a/entry/src/main/resources/base/profile/main_pages.json b/multinavbarsample/src/main/resources/base/profile/main_pages.json similarity index 100% rename from entry/src/main/resources/base/profile/main_pages.json rename to multinavbarsample/src/main/resources/base/profile/main_pages.json -- Gitee