From 85757f18e3742519bea4b6370dc495ee3ba134bc Mon Sep 17 00:00:00 2001 From: WX1377357 Date: Tue, 27 May 2025 15:57:10 +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 +- scrollcomponentlibrary/.gitignore | 6 + scrollcomponentlibrary/Index.ets | 2 + scrollcomponentlibrary/build-profile.json5 | 31 +++++ scrollcomponentlibrary/consumer-rules.txt | 0 scrollcomponentlibrary/hvigorfile.ts | 6 + scrollcomponentlibrary/obfuscation-rules.txt | 23 ++++ .../oh-package.json5 | 7 +- .../ets/common/constants/CommonConstants.ets | 0 .../ScrollComponentNestedSlidingPage.ets | 21 ++-- .../src/main/ets/utils/BreakpointSystem.ets | 118 ++++++++++++++++++ .../src/main/ets/utils/WindowUtil.ets | 70 +++++++++++ .../src/main/ets/viewmodel/InitData.ets | 0 scrollcomponentlibrary/src/main/module.json5 | 11 ++ .../main/resources/base/element/color.json | 0 .../main/resources/base/element/float.json | 0 .../main/resources/base/element/string.json | 0 .../src/main/resources/base/media/icon.png | Bin .../main/resources/base/media/startIcon.png | Bin .../resources/base/profile/main_pages.json | 5 + .../main/resources/en_US/element/string.json | 0 .../main/resources/zh_CN/element/string.json | 0 .../build-profile.json5 | 0 .../hvigorfile.ts | 0 .../obfuscation-rules.txt | 0 scrollcomponentsample/oh-package.json5 | 11 ++ .../scrollcomponentlibrary/.gitignore | 6 + .../scrollcomponentlibrary/BuildProfile.ets | 17 +++ .../scrollcomponentlibrary/Index.ets | 2 + .../build-profile.json5 | 31 +++++ .../scrollcomponentlibrary/consumer-rules.txt | 0 .../scrollcomponentlibrary/hvigorfile.ts | 6 + .../obfuscation-rules.txt | 23 ++++ .../scrollcomponentlibrary/oh-package.json5 | 9 ++ .../ets/common/constants/CommonConstants.ets | 44 +++++++ .../src/main/ets/utils/WindowUtil.ets | 70 +++++++++++ .../src/main/ets/viewmodel/InitData.ets | 21 ++++ .../src/main/module.json5 | 11 ++ .../main/resources/base/element/color.json | 8 ++ .../main/resources/base/element/float.json | 40 ++++++ .../main/resources/base/element/string.json | 36 ++++++ .../src/main/resources/base/media/icon.png | Bin 0 -> 2041 bytes .../main/resources/base/media/startIcon.png | Bin 0 -> 4351 bytes .../resources/base/profile/main_pages.json | 5 + .../main/resources/en_US/element/string.json | 36 ++++++ .../main/resources/zh_CN/element/string.json | 36 ++++++ .../main/ets/entryability/EntryAbility.ets | 59 +-------- .../src/main/ets/pages/Index.ets | 26 ++-- .../src/main/module.json5 | 6 +- .../resources/base/profile/main_pages.json | 0 50 files changed, 719 insertions(+), 92 deletions(-) create mode 100644 scrollcomponentlibrary/.gitignore create mode 100644 scrollcomponentlibrary/Index.ets create mode 100644 scrollcomponentlibrary/build-profile.json5 create mode 100644 scrollcomponentlibrary/consumer-rules.txt create mode 100644 scrollcomponentlibrary/hvigorfile.ts create mode 100644 scrollcomponentlibrary/obfuscation-rules.txt rename {entry => scrollcomponentlibrary}/oh-package.json5 (58%) rename {entry => scrollcomponentlibrary}/src/main/ets/common/constants/CommonConstants.ets (100%) rename entry/src/main/ets/pages/Index.ets => scrollcomponentlibrary/src/main/ets/pages/ScrollComponentNestedSlidingPage.ets (89%) create mode 100644 scrollcomponentlibrary/src/main/ets/utils/BreakpointSystem.ets create mode 100644 scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets rename {entry => scrollcomponentlibrary}/src/main/ets/viewmodel/InitData.ets (100%) create mode 100644 scrollcomponentlibrary/src/main/module.json5 rename {entry => scrollcomponentlibrary}/src/main/resources/base/element/color.json (100%) rename {entry => scrollcomponentlibrary}/src/main/resources/base/element/float.json (100%) rename {entry => scrollcomponentlibrary}/src/main/resources/base/element/string.json (100%) rename {entry => scrollcomponentlibrary}/src/main/resources/base/media/icon.png (100%) rename {entry => scrollcomponentlibrary}/src/main/resources/base/media/startIcon.png (100%) create mode 100644 scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json rename {entry => scrollcomponentlibrary}/src/main/resources/en_US/element/string.json (100%) rename {entry => scrollcomponentlibrary}/src/main/resources/zh_CN/element/string.json (100%) rename {entry => scrollcomponentsample}/build-profile.json5 (100%) rename {entry => scrollcomponentsample}/hvigorfile.ts (100%) rename {entry => scrollcomponentsample}/obfuscation-rules.txt (100%) create mode 100644 scrollcomponentsample/oh-package.json5 create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/.gitignore create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/BuildProfile.ets create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/Index.ets create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/build-profile.json5 create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/consumer-rules.txt create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/hvigorfile.ts create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/obfuscation-rules.txt create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/oh-package.json5 create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/module.json5 create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/color.json create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/float.json create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/string.json create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/icon.png create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/startIcon.png create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/en_US/element/string.json create mode 100644 scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json rename {entry => scrollcomponentsample}/src/main/ets/entryability/EntryAbility.ets (47%) rename entry/src/main/ets/common/utils/Utils.ets => scrollcomponentsample/src/main/ets/pages/Index.ets (55%) rename {entry => scrollcomponentsample}/src/main/module.json5 (88%) rename {entry => scrollcomponentsample}/src/main/resources/base/profile/main_pages.json (100%) diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4..e82b0bb 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -20,8 +20,8 @@ }, "modules": [ { - "name": "entry", - "srcPath": "./entry", + "name": "scrollcomponentsample", + "srcPath": "./scrollcomponentsample", "targets": [ { "name": "default", @@ -30,6 +30,10 @@ ] } ] + }, + { + "name": "scrollcomponentlibrary", + "srcPath": "./scrollcomponentlibrary", } ] } \ No newline at end of file diff --git a/scrollcomponentlibrary/.gitignore b/scrollcomponentlibrary/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/scrollcomponentlibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/scrollcomponentlibrary/Index.ets b/scrollcomponentlibrary/Index.ets new file mode 100644 index 0000000..4626d60 --- /dev/null +++ b/scrollcomponentlibrary/Index.ets @@ -0,0 +1,2 @@ +export { ScrollComponentNestedSlidingPage} from './src/main/ets/pages/ScrollComponentNestedSlidingPage' +export { WindowUtil } from './src/main/ets/utils/WindowUtil'; \ No newline at end of file diff --git a/scrollcomponentlibrary/build-profile.json5 b/scrollcomponentlibrary/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/scrollcomponentlibrary/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/scrollcomponentlibrary/consumer-rules.txt b/scrollcomponentlibrary/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/scrollcomponentlibrary/hvigorfile.ts b/scrollcomponentlibrary/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/scrollcomponentlibrary/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/scrollcomponentlibrary/obfuscation-rules.txt b/scrollcomponentlibrary/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/scrollcomponentlibrary/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/scrollcomponentlibrary/oh-package.json5 similarity index 58% rename from entry/oh-package.json5 rename to scrollcomponentlibrary/oh-package.json5 index 248c3b7..5454d3e 100644 --- a/entry/oh-package.json5 +++ b/scrollcomponentlibrary/oh-package.json5 @@ -1,10 +1,9 @@ { - "name": "entry", + "name": "scrollcomponentlibrary", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "", + "main": "Index.ets", "author": "", - "license": "", + "license": "Apache-2.0", "dependencies": {} } - diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets similarity index 100% rename from entry/src/main/ets/common/constants/CommonConstants.ets rename to scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets diff --git a/entry/src/main/ets/pages/Index.ets b/scrollcomponentlibrary/src/main/ets/pages/ScrollComponentNestedSlidingPage.ets similarity index 89% rename from entry/src/main/ets/pages/Index.ets rename to scrollcomponentlibrary/src/main/ets/pages/ScrollComponentNestedSlidingPage.ets index 713a34a..2a2ab5d 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/scrollcomponentlibrary/src/main/ets/pages/ScrollComponentNestedSlidingPage.ets @@ -15,7 +15,7 @@ import { listArr } from '../viewmodel/InitData'; import { CommonConstants } from '../common/constants/CommonConstants'; -import { BreakpointType } from '../common/utils/Utils'; +import { BreakpointType } from '../utils/BreakpointSystem'; import { ItemRestriction, SegmentButton, @@ -23,9 +23,8 @@ import { SegmentButtonTextItem } from '@ohos.arkui.advanced.SegmentButton'; -@Entry @Component -struct NestedCeiling { +export struct ScrollComponentNestedSlidingPage { @State @Watch('onSegmentButtonChange') tabSelectedIndexes: number[] = [0]; @State currentIndex: number = 0; @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.tab({ @@ -103,7 +102,7 @@ struct NestedCeiling { }, (item: string) => JSON.stringify(item)) } .borderRadius($r('app.float.list_item_radius')) - .lanes(new BreakpointType(1, 2, 2).getValue(this.curBp)) + .lanes(new BreakpointType({ sm: 1, md: 2, lg: 2 }).getValue(this.curBp)) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) .edgeEffect(EdgeEffect.None) @@ -140,15 +139,19 @@ struct NestedCeiling { } } } - .height(new BreakpointType('210%', '120%', '120%').getValue(this.curBp)) + .height(new BreakpointType({ sm: '210%', md: '120%', lg: '120%' }).getValue(this.curBp)) .scrollBar(BarState.Off) .width(CommonConstants.FULL_WIDTH) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.curBp), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.curBp), + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.curBp), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.curBp), top: px2vp(this.topRectHeight) }) .width(CommonConstants.FULL_WIDTH) diff --git a/scrollcomponentlibrary/src/main/ets/utils/BreakpointSystem.ets b/scrollcomponentlibrary/src/main/ets/utils/BreakpointSystem.ets new file mode 100644 index 0000000..aa7581b --- /dev/null +++ b/scrollcomponentlibrary/src/main/ets/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 || param.lg; + } + + 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('currentBreakpoint', 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/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets b/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets new file mode 100644 index 0000000..5b26bd8 --- /dev/null +++ b/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets @@ -0,0 +1,70 @@ +/* + * 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 { BreakpointSystem } from './BreakpointSystem'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[WindowUtil]'; + +export class WindowUtil { + 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 { + 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. '); + } + }); + } + + 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; + } + BreakpointSystem.getInstance().updateWidthBp(data); + data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); + data.on('avoidAreaChange', (avoidAreaOption) => { + if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || + avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); + } + }); + }) + } + + // 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/viewmodel/InitData.ets b/scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets similarity index 100% rename from entry/src/main/ets/viewmodel/InitData.ets rename to scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets diff --git a/scrollcomponentlibrary/src/main/module.json5 b/scrollcomponentlibrary/src/main/module.json5 new file mode 100644 index 0000000..6eb1064 --- /dev/null +++ b/scrollcomponentlibrary/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "scrollcomponentlibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/entry/src/main/resources/base/element/color.json b/scrollcomponentlibrary/src/main/resources/base/element/color.json similarity index 100% rename from entry/src/main/resources/base/element/color.json rename to scrollcomponentlibrary/src/main/resources/base/element/color.json diff --git a/entry/src/main/resources/base/element/float.json b/scrollcomponentlibrary/src/main/resources/base/element/float.json similarity index 100% rename from entry/src/main/resources/base/element/float.json rename to scrollcomponentlibrary/src/main/resources/base/element/float.json diff --git a/entry/src/main/resources/base/element/string.json b/scrollcomponentlibrary/src/main/resources/base/element/string.json similarity index 100% rename from entry/src/main/resources/base/element/string.json rename to scrollcomponentlibrary/src/main/resources/base/element/string.json diff --git a/entry/src/main/resources/base/media/icon.png b/scrollcomponentlibrary/src/main/resources/base/media/icon.png similarity index 100% rename from entry/src/main/resources/base/media/icon.png rename to scrollcomponentlibrary/src/main/resources/base/media/icon.png diff --git a/entry/src/main/resources/base/media/startIcon.png b/scrollcomponentlibrary/src/main/resources/base/media/startIcon.png similarity index 100% rename from entry/src/main/resources/base/media/startIcon.png rename to scrollcomponentlibrary/src/main/resources/base/media/startIcon.png diff --git a/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json b/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..b7abdcd --- /dev/null +++ b/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/ScrollComponentNestedSlidingPage" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/scrollcomponentlibrary/src/main/resources/en_US/element/string.json similarity index 100% rename from entry/src/main/resources/en_US/element/string.json rename to scrollcomponentlibrary/src/main/resources/en_US/element/string.json diff --git a/entry/src/main/resources/zh_CN/element/string.json b/scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json similarity index 100% rename from entry/src/main/resources/zh_CN/element/string.json rename to scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json diff --git a/entry/build-profile.json5 b/scrollcomponentsample/build-profile.json5 similarity index 100% rename from entry/build-profile.json5 rename to scrollcomponentsample/build-profile.json5 diff --git a/entry/hvigorfile.ts b/scrollcomponentsample/hvigorfile.ts similarity index 100% rename from entry/hvigorfile.ts rename to scrollcomponentsample/hvigorfile.ts diff --git a/entry/obfuscation-rules.txt b/scrollcomponentsample/obfuscation-rules.txt similarity index 100% rename from entry/obfuscation-rules.txt rename to scrollcomponentsample/obfuscation-rules.txt diff --git a/scrollcomponentsample/oh-package.json5 b/scrollcomponentsample/oh-package.json5 new file mode 100644 index 0000000..60a91ce --- /dev/null +++ b/scrollcomponentsample/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "scrollcomponentsample", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "scrollcomponentlibrary": "file:../scrollcomponentlibrary" + } +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/.gitignore b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/BuildProfile.ets b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/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/scrollcomponentsample/oh_modules/scrollcomponentlibrary/Index.ets b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/Index.ets new file mode 100644 index 0000000..4626d60 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/Index.ets @@ -0,0 +1,2 @@ +export { ScrollComponentNestedSlidingPage} from './src/main/ets/pages/ScrollComponentNestedSlidingPage' +export { WindowUtil } from './src/main/ets/utils/WindowUtil'; \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/build-profile.json5 b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/consumer-rules.txt b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/hvigorfile.ts b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/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/scrollcomponentsample/oh_modules/scrollcomponentlibrary/obfuscation-rules.txt b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/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/scrollcomponentsample/oh_modules/scrollcomponentlibrary/oh-package.json5 b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/oh-package.json5 new file mode 100644 index 0000000..5454d3e --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "scrollcomponentlibrary", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets new file mode 100644 index 0000000..ffaf983 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/common/constants/CommonConstants.ets @@ -0,0 +1,44 @@ +/* + * 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. + */ + +/** + * Common constants for all features. + */ +export class CommonConstants { + /** + * font weight is 500. + */ + public static readonly FONT_WEIGHT_FIVE: number = 500; + /** + * Width the percentage of the 100. + */ + public static readonly FULL_WIDTH: string = '100%'; + /** + * Height the percentage of the 100. + */ + public static readonly FULL_HEIGHT: string = '100%'; + /** + * Breakpoint sm. + */ + public static readonly BREAK_POINT_SM: string = 'sm'; + /** + * Breakpoint md. + */ + public static readonly BREAK_POINT_MD: string = 'md'; + /** + * Breakpoint lg. + */ + public static readonly BREAK_POINT_LG: string = 'lg'; +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets new file mode 100644 index 0000000..5b26bd8 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/utils/WindowUtil.ets @@ -0,0 +1,70 @@ +/* + * 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 { BreakpointSystem } from './BreakpointSystem'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[WindowUtil]'; + +export class WindowUtil { + 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 { + 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. '); + } + }); + } + + 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; + } + BreakpointSystem.getInstance().updateWidthBp(data); + data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); + data.on('avoidAreaChange', (avoidAreaOption) => { + if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || + avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); + } + }); + }) + } + + // 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/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets new file mode 100644 index 0000000..cf04449 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/ets/viewmodel/InitData.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +/** + * List data + */ +export const listArr: string[] = + ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', + '22', '23', '24']; \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/module.json5 b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/module.json5 new file mode 100644 index 0000000..6eb1064 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "scrollcomponentlibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/color.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/color.json new file mode 100644 index 0000000..81279aa --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#F1F3F5" + } + ] +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/float.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/float.json new file mode 100644 index 0000000..4c2b7be --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/float.json @@ -0,0 +1,40 @@ +{ + "float": [ + { + "name": "middle_font_size", + "value": "14fp" + }, + { + "name": "button_border_radius", + "value": "21fp" + }, + { + "name": "button_height", + "value": "36fp" + }, + { + "name": "button_width", + "value": "84fp" + }, + { + "name": "list_item_radius", + "value": "16vp" + }, + { + "name": "list_item_padding", + "value": "12vp" + }, + { + "name": "list_item_height", + "value": "56vp" + }, + { + "name": "big_font_size", + "value": "30fp" + }, + { + "name": "discover_bottom_padding", + "value": "16vp" + } + ] +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/string.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/string.json new file mode 100644 index 0000000..e64f625 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Scroll组件嵌套滑动" + }, + { + "name": "title", + "value": "Scroll组件嵌套滑动" + }, + { + "name": "Promotional", + "value": "促销活动" + }, + { + "name": "Travel", + "value": "行程服务" + }, + { + "name": "goods", + "value": "促销商品" + }, + { + "name": "Itinerary", + "value": "行程安排" + } + ] +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/icon.png b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 GIT binary patch literal 2041 zcmaJ?c~nzZ9u6@;0AXaYAVN(;Kr(@>EJ+}skOWf=BA~*l4us@ELY9{%0m5QX6pnb} z(jZF|S&pLAS}3BZAfeQSvJ_h>F2Q1PYqi?o5`;m_yjZdG$1v}l_wK#F^L^iMz2}uD z#K$>1dON~kFlWvhW+Jp=tuN9J`ZlM-rl4h+ij|^D0y9;4JOuz-EdVnB6i3R-0ulk9 zApi4zAQA>!N9@-o026$1@L`d124`3G5<@_m`0f)Ug_Ie~;HT2q<_a=HH> zDwTdfD^-cW-|_xWVP$f@93UhDN-#&khZ>jZXLTi~$0`7x3REP6pk%&^2|`c>DutjN zMJD4Zs6Z}{FOpd;*mo2zm(GzXRXiCV;4m3zNCYnu3Fy=i5;2An&Lp!#LP;bRD~1&s z%VH6UY+}r6YDgG+p34OJIZ{BTn&%4s=CT&#TBkuOhdeU@g(w#guoa*b^)73=XyI65 z7Swys6)YS}?1EeZ6b!-I+yCnIya^g0>-NLsLWd8t56GZ_S3r|ZGbR+mV2ErEb9J)X zIF!njY-D-7{qtF2(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fhv!cR|RmAD$+w6j`rVf=-?-D@q>kOseUVSb*~jbAS^*1h?ZL)n(9 zDa}`4etXO6`}9;{k5E^N{rcfnV_(LPwsDg``wtyS*V<19c3!PGJ3Kqy9ksvkwbJ%Z z*N(fT0{e*Wji-Ck5!3YE0j|PZ@&z`v=kitWL$bqSt!e4bH!+(|Q)CZ30^nVPfkx{s zX{6of`p=BiPb@u@IyL!tRk>?qgBqCmo-Zlt!636g?z`s~zdfwuB7DXZHvV`Usp+%Z zo*&;Biu@MHE&2j+?j^o`Cr12u<>vOe=a&8a2hlcmFjJiDR>XnD4c4DAhZWCkiAgW{ E51q9-lK=n! literal 0 HcmV?d00001 diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/startIcon.png b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..366f76459ffd4494ec40d0ddd5c59385b9c5da11 GIT binary patch literal 4351 zcmaJ_c{r5o`$trELZWDz?8}%L>x?yK$i9!UFJmyqEM`W=l13t1vK18?bc9Hft+FQB zvZWA7vQ{XHEY)wEb2{JOAK&wRuj_rE=e@7{{@mN=ey`_xlk9BF_<1CG*x1mL!?jn!jg+b4^2 zLetRJR&Wf70P@|_0nrI$mNgrjo*|v=i@{@Q06%OXj;Ie@ebfR3;QaN0E}GV0YqAM8 z2zNS?f_03val%C6F))9ip#eaT4rc)nuryx)oe)B#!s+_JKXKu#{hnA22>4TlhSvxF z6%^Xq4q!r}U;$bnuqp-&)&gk5KoBhrZB2C*02B;`sDYts5KUDG1g;5%L(~C(UqF^O zihlsy0b%;LFV>qrFo;GY!`0Nn!^1)0>L3y&Pz?fu!S*nqP*s+ODm8*g^QEg2sV9FU zAh1*n1xKdgNJPLMqOTt*jHVA{Mfz6?1oA(yMC#vVViin{?n_pKfWUhx{Z_QL{@IO$Y>u zG)8KgAdz6ODcJawj)s=$Z(9Tj6Gp%iX}@j#|6_aVUv2l;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Uk}&Ls(m6u%F4L`YyePS3oL4jqq0<~BnXmrUq_SE|?M~j!BdLw~HoaTstBb7=HK+WcPWE@_ cIQZCt9|&h0`tm_w@0Wx*(gtzY*ysHJ0mylrOaK4? literal 0 HcmV?d00001 diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..b7abdcd --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/ScrollComponentNestedSlidingPage" + ] +} diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/en_US/element/string.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..cf462b7 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/en_US/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ScrollComponentNestedSliding" + }, + { + "name": "title", + "value": "Nested scrolling of the Scroll component" + }, + { + "name": "Promotional", + "value": "Promotion activity" + }, + { + "name": "Travel", + "value": "Travel service" + }, + { + "name": "goods", + "value": "Promotion goods" + }, + { + "name": "Itinerary", + "value": "Itinerary arrangement" + } + ] +} \ No newline at end of file diff --git a/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..e64f625 --- /dev/null +++ b/scrollcomponentsample/oh_modules/scrollcomponentlibrary/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Scroll组件嵌套滑动" + }, + { + "name": "title", + "value": "Scroll组件嵌套滑动" + }, + { + "name": "Promotional", + "value": "促销活动" + }, + { + "name": "Travel", + "value": "行程服务" + }, + { + "name": "goods", + "value": "促销商品" + }, + { + "name": "Itinerary", + "value": "行程安排" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/scrollcomponentsample/src/main/ets/entryability/EntryAbility.ets similarity index 47% rename from entry/src/main/ets/entryability/EntryAbility.ets rename to scrollcomponentsample/src/main/ets/entryability/EntryAbility.ets index 51b3851..dd6cbe1 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/scrollcomponentsample/src/main/ets/entryability/EntryAbility.ets @@ -14,34 +14,11 @@ */ import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; -import { display, window } from '@kit.ArkUI'; +import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import { resourceManager } from '@kit.LocalizationKit'; +import { WindowUtil } from 'scrollcomponentlibrary'; export default class EntryAbility extends UIAbility { - private curBp: string = ''; - - private updateBreakpoint(windowWidth: number): void { - try { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let newBp: string = ''; - if (windowWidthVp < 600) { - newBp = 'sm'; - } else if (windowWidthVp < 840) { - newBp = 'md'; - } else { - newBp = 'lg'; - } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); - } - } catch (exception) { - hilog.error(0x0000, 'testTag', '%{public}s', - `UpdateBreakpoint fail, error code: ${(exception as BusinessError).code}`); - } - } onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); @@ -54,38 +31,10 @@ export default class EntryAbility extends UIAbility { } onWindowStageCreate(windowStage: window.WindowStage): void { - windowStage.getMainWindow().then((windowObj: window.Window) => { - let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - try { - let avoidArea = windowObj.getWindowAvoidArea(type); - let bottomRectHeight = avoidArea.bottomRect.height; - AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); - type = window.AvoidAreaType.TYPE_SYSTEM; - avoidArea = windowObj.getWindowAvoidArea(type); - let topRectHeight = avoidArea.topRect.height; - AppStorage.setOrCreate('topRectHeight', topRectHeight); - this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); - - windowObj.on('windowSizeChange', (windowSize) => { - this.updateBreakpoint(windowSize.width); - }); - - windowObj.setWindowLayoutFullScreen(true).then(() => { - hilog.info(0x0000, 'testTag', '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', `Failed to set the window layout to full-screen mode. Cause: ${err.message}`); - }); - } catch (err) { - hilog.error(0x0000, 'testTag', '%{public}s', `config window fail. Cause: ${err.code}`); - } - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', `Failed to get main window. Cause: ${err.message}`); - }); + WindowUtil.requestFullScreen(windowStage) + WindowUtil.registerBreakPoint(windowStage) // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - let context = this.context; - let resourceManager: resourceManager.ResourceManager = context.resourceManager; - AppStorage.setOrCreate('resourceManager', resourceManager); windowStage.loadContent('pages/Index', (err) => { if (err.code) { hilog.error(0x0000, 'testTag', '%{public}s', `Failed to load the content. Cause: ${err.code}`); diff --git a/entry/src/main/ets/common/utils/Utils.ets b/scrollcomponentsample/src/main/ets/pages/Index.ets similarity index 55% rename from entry/src/main/ets/common/utils/Utils.ets rename to scrollcomponentsample/src/main/ets/pages/Index.ets index 271114e..629ac83 100644 --- a/entry/src/main/ets/common/utils/Utils.ets +++ b/scrollcomponentsample/src/main/ets/pages/Index.ets @@ -12,27 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { CommonConstants } from '../constants/CommonConstants'; -export class BreakpointType { - private sm: T; - private md: T; - private lg: T; +import { ScrollComponentNestedSlidingPage } from 'scrollcomponentlibrary' - constructor(sm: T, md: T, lg: T) { - this.sm = sm; - this.md = md; - this.lg = lg; - } - - getValue(currentBreakpoint: string): T { - if (currentBreakpoint === CommonConstants.BREAK_POINT_MD) { - return this.md; - } - if (currentBreakpoint === CommonConstants.BREAK_POINT_LG) { - return this.lg; - } else { - return this.sm; +@Entry +@Component +struct Index { + build() { + Stack(){ + ScrollComponentNestedSlidingPage() } } } \ No newline at end of file diff --git a/entry/src/main/module.json5 b/scrollcomponentsample/src/main/module.json5 similarity index 88% rename from entry/src/main/module.json5 rename to scrollcomponentsample/src/main/module.json5 index 4ce1318..b33a6d4 100644 --- a/entry/src/main/module.json5 +++ b/scrollcomponentsample/src/main/module.json5 @@ -1,6 +1,6 @@ { "module": { - "name": "entry", + "name": "scrollcomponentsample", "type": "entry", "description": "$string:module_desc", "mainElement": "EntryAbility", @@ -14,14 +14,14 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "EntryAbility", + "name": "ScrollcomponentsampleAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:icon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", - "exported": false, + "exported": true, "skills": [ { "entities": [ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/scrollcomponentsample/src/main/resources/base/profile/main_pages.json similarity index 100% rename from entry/src/main/resources/base/profile/main_pages.json rename to scrollcomponentsample/src/main/resources/base/profile/main_pages.json -- Gitee