diff --git a/README.en.md b/README.en.md index 6f90868c818011fe7e2b186180a149e0fa6e2d4a..efc6d4769b2e0178a6fecd1305ae4684664b0215 100644 --- a/README.en.md +++ b/README.en.md @@ -65,7 +65,7 @@ N/A ### Constraints -1. The sample app is supported only on Huawei phones, tablets, and 2in1 devices running the standard system. +1. The sample app is supported only on Huawei phones, tablets, and PC/2in1 devices running the standard system. 2. The HarmonyOS version must be HarmonyOS 5.0.0 Release or later. 3. The DevEco Studio version must be DevEco Studio 5.0.0 Release or later. 4. The HarmonyOS SDK version must be HarmonyOS 5.0.0 Release or later. diff --git a/README.md b/README.md index 08cfc50db2bb7149d4c81970f37b703b1d368895..06a8fd3dad8b3f7ffe81e337b9a56b6373211a1c 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ ### 约束与限制 -1.本示例仅支持标准系统上运行,支持设备:phone,tablet,2in1。 +1.本示例仅支持标准系统上运行,支持设备:phone,tablet,PC/2in1。 2.HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4278fb0641d84107c3c134047ac487368e..67601e413c2656d5ee4f352541f9c1cc15e4c81b 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -20,8 +20,8 @@ }, "modules": [ { - "name": "entry", - "srcPath": "./entry", + "name": "multiticketclasssample", + "srcPath": "./multiticketclasssample", "targets": [ { "name": "default", @@ -30,6 +30,10 @@ ] } ] + }, + { + "name": "multiticketclasslibrary", + "srcPath": "./multiticketclasslibrary", } ] } \ No newline at end of file diff --git a/multiticketclasslibrary/.gitignore b/multiticketclasslibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/multiticketclasslibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/multiticketclasslibrary/Index.ets b/multiticketclasslibrary/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a7cd91a7d569645c1f8179ca9d8d9af6cbb31da --- /dev/null +++ b/multiticketclasslibrary/Index.ets @@ -0,0 +1,2 @@ +export { MultiTicketClassPage} from './src/main/ets/pages/MultiTicketClassPage' +export { WindowUtil} from './src/main/ets/utils/WindowUtil' diff --git a/multiticketclasslibrary/build-profile.json5 b/multiticketclasslibrary/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/multiticketclasslibrary/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/multiticketclasslibrary/consumer-rules.txt b/multiticketclasslibrary/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/multiticketclasslibrary/hvigorfile.ts b/multiticketclasslibrary/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/multiticketclasslibrary/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/multiticketclasslibrary/obfuscation-rules.txt b/multiticketclasslibrary/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/multiticketclasslibrary/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/multiticketclasslibrary/oh-package.json5 similarity index 58% rename from entry/oh-package.json5 rename to multiticketclasslibrary/oh-package.json5 index 248c3b7541a589682a250f86a6d3ecf7414d2d6a..58f9d0afa08567cdaa131a24e6aaa1e323514b34 100644 --- a/entry/oh-package.json5 +++ b/multiticketclasslibrary/oh-package.json5 @@ -1,10 +1,9 @@ { - "name": "entry", + "name": "multiticketclasslibrary", "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/constants/CommonConstants.ets b/multiticketclasslibrary/src/main/ets/constants/CommonConstants.ets similarity index 100% rename from entry/src/main/ets/constants/CommonConstants.ets rename to multiticketclasslibrary/src/main/ets/constants/CommonConstants.ets diff --git a/entry/src/main/ets/constants/ListDataConstants.ets b/multiticketclasslibrary/src/main/ets/constants/ListDataConstants.ets similarity index 100% rename from entry/src/main/ets/constants/ListDataConstants.ets rename to multiticketclasslibrary/src/main/ets/constants/ListDataConstants.ets diff --git a/entry/src/main/ets/pages/AdaptiveTabCenteringIndex.ets b/multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets similarity index 81% rename from entry/src/main/ets/pages/AdaptiveTabCenteringIndex.ets rename to multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets index 32947ec5024a1585cee3a47b1f057084afd4e32f..f80f2ef75c1beba8bc90cd6ca812a5139c3ff0a4 100644 --- a/entry/src/main/ets/pages/AdaptiveTabCenteringIndex.ets +++ b/multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets @@ -15,7 +15,7 @@ import { ListDataConstants } from '../constants/ListDataConstants'; import { CommonConstants } from '../constants/CommonConstants'; -import { BreakpointType } from '../utils/BreakpointType'; +import { BreakpointType } from '../utils/BreakpointSystem'; @Component export struct AdaptiveTabCenteringIndex { @@ -44,10 +44,14 @@ export struct AdaptiveTabCenteringIndex { .fontColor($r('sys.color.font_primary')) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .width(CommonConstants.FULL_WIDTH_PERCENT) .height($r('app.float.bar_height')) @@ -84,10 +88,14 @@ export struct AdaptiveTabCenteringIndex { .listDirection(Axis.Horizontal) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .backgroundColor($r('sys.color.background_secondary')) .height($r('app.float.height_56')) diff --git a/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets b/multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets similarity index 80% rename from entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets rename to multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets index bbe918e6f44f787a91a3ce69c8a782776ea6366a..4f5a951b6c574708f1aee566daaaab66afd228da 100644 --- a/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets +++ b/multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets @@ -15,7 +15,7 @@ import { ListDataConstants } from '../constants/ListDataConstants'; import { CommonConstants } from '../constants/CommonConstants'; -import { BreakpointType } from '../utils/BreakpointType'; +import { BreakpointType } from '../utils/BreakpointSystem'; @Component export struct DoubleTabAdaptiveCenteringIndex { @@ -45,10 +45,14 @@ export struct DoubleTabAdaptiveCenteringIndex { .fontColor($r('sys.color.font_primary')) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .width(CommonConstants.FULL_WIDTH_PERCENT) .height($r('app.float.bar_height')) @@ -58,8 +62,10 @@ export struct DoubleTabAdaptiveCenteringIndex { Row() { Column() { List({ - space: new BreakpointType(CommonConstants.TABLE_LIST_PADDING_SM, CommonConstants.TABLE_LIST_PADDING_MD, - CommonConstants.TABLE_LIST_PADDING_LG).getValue(this.breakPoint) + space: new BreakpointType({ + sm: CommonConstants.TABLE_LIST_PADDING_SM, md: CommonConstants.TABLE_LIST_PADDING_MD, + lg: CommonConstants.TABLE_LIST_PADDING_LG + }).getValue(this.breakPoint) }) { ForEach(ListDataConstants.STOCK_OPTIONS_LIST1, (item: Resource, index: number) => { ListItem() { @@ -99,8 +105,10 @@ export struct DoubleTabAdaptiveCenteringIndex { .margin({ bottom: $r('app.float.stock_options_margin') }) .alignItems(HorizontalAlign.Start) .justifyContent(FlexAlign.Start) - .width(new BreakpointType($r('app.float.width_296'), $r('app.float.width_312'), - $r('app.float.width_312')).getValue(this.breakPoint)) + .width(new BreakpointType({ + sm: $r('app.float.width_296'), md: $r('app.float.width_312'), + lg: $r('app.float.width_312') + }).getValue(this.breakPoint)) .height($r('app.float.height_56')) .layoutWeight(CommonConstants.COMMON_FAL_1) @@ -112,10 +120,14 @@ export struct DoubleTabAdaptiveCenteringIndex { .justifyContent(FlexAlign.Start) .backgroundColor($r('sys.color.background_secondary')) .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .height($r('app.float.height_56')) .width(CommonConstants.FULL_WIDTH_PERCENT) @@ -123,8 +135,10 @@ export struct DoubleTabAdaptiveCenteringIndex { Row() { Column() { List({ - space: new BreakpointType(CommonConstants.DOUBLE_TAB_PADDING_SM, CommonConstants.DOUBLE_TAB_PADDING_MD2, - CommonConstants.DOUBLE_TAB_PADDING_LG2).getValue(this.breakPoint) + space: new BreakpointType({ + sm: CommonConstants.DOUBLE_TAB_PADDING_SM, md: CommonConstants.DOUBLE_TAB_PADDING_MD2, + lg: CommonConstants.DOUBLE_TAB_PADDING_LG2 + }).getValue(this.breakPoint) }) { ForEach(ListDataConstants.STOCK_OPTIONS_LIST2, (item: Resource, index: number) => { ListItem() { diff --git a/entry/src/main/ets/pages/Index.ets b/multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets similarity index 79% rename from entry/src/main/ets/pages/Index.ets rename to multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets index 5c0812e597479e26cb4e8c41804b13a06bdf1b80..9dc4b4eaaa770e3ebe5681b1306f6d4400a155b4 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets @@ -18,7 +18,7 @@ import { ListDataConstants } from '../constants/ListDataConstants'; import { AdaptiveTabCenteringIndex } from './AdaptiveTabCenteringIndex'; import { TableAdaptiveExtensionIndex } from './TableAdaptiveExtensionIndex'; import { DoubleTabAdaptiveCenteringIndex } from './DoubleTabAdaptiveCenteringIndex'; -import { BreakpointType } from '../utils/BreakpointType'; +import { BreakpointType } from '../utils/BreakpointSystem'; class DirectoryItem { public title: ResourceStr = ''; @@ -26,9 +26,8 @@ class DirectoryItem { public id: string = ''; } -@Entry @Component -struct Index { +export struct MultiTicketClassPage { @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; @StorageProp('bottomRectHeight') bottomRectHeight: number = 0; @@ -91,8 +90,10 @@ struct Index { .fontSize($r('sys.float.Title_L')) .alignSelf(ItemAlign.Start) .margin({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) Column() { ForEach(this.directory, (item: DirectoryItem) => { @@ -109,15 +110,21 @@ struct Index { }) }, (item: DirectoryItem) => JSON.stringify(item)) } - .width(new BreakpointType($r('app.string.fullwidth'), $r('app.float.index_button_width_md'), - $r('app.float.index_button_width_lg')).getValue(this.breakPoint)) + .width(new BreakpointType({ + sm: $r('app.string.fullwidth'), md: $r('app.float.index_button_width_md'), + lg: $r('app.float.index_button_width_lg') + }).getValue(this.breakPoint)) .padding({ - left: new BreakpointType($r('app.float.index_button_width_sm'), - $r('app.float.index_button_padding_md_lg'), - $r('app.float.index_button_padding_md_lg')).getValue(this.breakPoint), - right: new BreakpointType($r('app.float.index_button_width_sm'), - $r('app.float.index_button_padding_md_lg'), - $r('app.float.index_button_padding_md_lg')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('app.float.index_button_width_sm'), + md: $r('app.float.index_button_padding_md_lg'), + lg: $r('app.float.index_button_padding_md_lg') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('app.float.index_button_width_sm'), + md: $r('app.float.index_button_padding_md_lg'), + lg: $r('app.float.index_button_padding_md_lg') + }).getValue(this.breakPoint) }) } .backgroundColor($r('sys.color.background_primary')) @@ -135,6 +142,8 @@ struct Index { .mode(NavigationMode.Stack) .hideBackButton(true) .titleMode(NavigationTitleMode.Mini) + .hideTitleBar(true) + .padding({ top: this.topRectHeight }) } } } diff --git a/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets b/multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets similarity index 88% rename from entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets rename to multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets index 630b87d0919f566f6eda0161142defa550223bc1..e4cd51be89f0cb7ca1831a042ae7cfa9e4f2602e 100644 --- a/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets +++ b/multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets @@ -15,7 +15,7 @@ import { ListDataConstants } from '../constants/ListDataConstants'; import { CommonConstants } from '../constants/CommonConstants'; -import { BreakpointType } from '../utils/BreakpointType'; +import { BreakpointType } from '../utils/BreakpointSystem'; @Component export struct TableAdaptiveExtensionIndex { @@ -58,10 +58,14 @@ export struct TableAdaptiveExtensionIndex { .fontColor($r('sys.color.font_primary')) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .width(CommonConstants.FULL_WIDTH_PERCENT) .height($r('app.float.bar_height')) @@ -169,10 +173,14 @@ export struct TableAdaptiveExtensionIndex { CommonConstants.FIFTY_PERCENT : CommonConstants.FULL_WIDTH_PERCENT) } .padding({ - left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint), - right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), - $r('sys.float.padding_level16')).getValue(this.breakPoint) + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) }) .width(CommonConstants.FULL_WIDTH_PERCENT) } diff --git a/multiticketclasslibrary/src/main/ets/utils/BreakpointSystem.ets b/multiticketclasslibrary/src/main/ets/utils/BreakpointSystem.ets new file mode 100644 index 0000000000000000000000000000000000000000..47355e059a70090a40ab75e12fdd5426e2dfcfcb --- /dev/null +++ b/multiticketclasslibrary/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('breakPoint', 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/multiticketclasslibrary/src/main/ets/utils/WindowUtil.ets b/multiticketclasslibrary/src/main/ets/utils/WindowUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..e059b5d42a30b23c32d1a60fc6c899fb809a72d2 --- /dev/null +++ b/multiticketclasslibrary/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('topRectHeight', px2vp(area.topRect.height)); + } else { + AppStorage.setOrCreate('bottomRectHeight', px2vp(area.bottomRect.height)); + } + } +} \ No newline at end of file diff --git a/multiticketclasslibrary/src/main/module.json5 b/multiticketclasslibrary/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c60520f63feee39b0300e100a595ab496584fff0 --- /dev/null +++ b/multiticketclasslibrary/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "multiticketclasslibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/entry/src/main/resources/base/element/color.json b/multiticketclasslibrary/src/main/resources/base/element/color.json similarity index 100% rename from entry/src/main/resources/base/element/color.json rename to multiticketclasslibrary/src/main/resources/base/element/color.json diff --git a/entry/src/main/resources/base/element/float.json b/multiticketclasslibrary/src/main/resources/base/element/float.json similarity index 100% rename from entry/src/main/resources/base/element/float.json rename to multiticketclasslibrary/src/main/resources/base/element/float.json diff --git a/entry/src/main/resources/base/element/string.json b/multiticketclasslibrary/src/main/resources/base/element/string.json similarity index 100% rename from entry/src/main/resources/base/element/string.json rename to multiticketclasslibrary/src/main/resources/base/element/string.json diff --git a/entry/src/main/resources/base/media/ic_public_info.png b/multiticketclasslibrary/src/main/resources/base/media/ic_public_info.png similarity index 100% rename from entry/src/main/resources/base/media/ic_public_info.png rename to multiticketclasslibrary/src/main/resources/base/media/ic_public_info.png diff --git a/entry/src/main/resources/base/media/ic_public_right.png b/multiticketclasslibrary/src/main/resources/base/media/ic_public_right.png similarity index 100% rename from entry/src/main/resources/base/media/ic_public_right.png rename to multiticketclasslibrary/src/main/resources/base/media/ic_public_right.png diff --git a/entry/src/main/resources/base/media/icon.png b/multiticketclasslibrary/src/main/resources/base/media/icon.png similarity index 100% rename from entry/src/main/resources/base/media/icon.png rename to multiticketclasslibrary/src/main/resources/base/media/icon.png diff --git a/entry/src/main/resources/base/media/startIcon.png b/multiticketclasslibrary/src/main/resources/base/media/startIcon.png similarity index 100% rename from entry/src/main/resources/base/media/startIcon.png rename to multiticketclasslibrary/src/main/resources/base/media/startIcon.png diff --git a/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json b/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..2505f0162c3bd8d484ac414fa68890260d0ff8bf --- /dev/null +++ b/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/MultiTicketClassPage" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/multiticketclasslibrary/src/main/resources/en_US/element/string.json similarity index 100% rename from entry/src/main/resources/en_US/element/string.json rename to multiticketclasslibrary/src/main/resources/en_US/element/string.json diff --git a/entry/src/main/resources/zh_CN/element/string.json b/multiticketclasslibrary/src/main/resources/zh_CN/element/string.json similarity index 100% rename from entry/src/main/resources/zh_CN/element/string.json rename to multiticketclasslibrary/src/main/resources/zh_CN/element/string.json diff --git a/entry/build-profile.json5 b/multiticketclasssample/build-profile.json5 similarity index 100% rename from entry/build-profile.json5 rename to multiticketclasssample/build-profile.json5 diff --git a/entry/hvigorfile.ts b/multiticketclasssample/hvigorfile.ts similarity index 100% rename from entry/hvigorfile.ts rename to multiticketclasssample/hvigorfile.ts diff --git a/entry/obfuscation-rules.txt b/multiticketclasssample/obfuscation-rules.txt similarity index 100% rename from entry/obfuscation-rules.txt rename to multiticketclasssample/obfuscation-rules.txt diff --git a/multiticketclasssample/oh-package.json5 b/multiticketclasssample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1fd02c49ac5a704c0d85492fbeb98f5967d3c1b1 --- /dev/null +++ b/multiticketclasssample/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "multiticketclasssample", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "multiticketclasslibrary": 'file:../multiticketclasslibrary' + } +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/.gitignore b/multiticketclasssample/oh_modules/multiticketclasslibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/Index.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a7cd91a7d569645c1f8179ca9d8d9af6cbb31da --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/Index.ets @@ -0,0 +1,2 @@ +export { MultiTicketClassPage} from './src/main/ets/pages/MultiTicketClassPage' +export { WindowUtil} from './src/main/ets/utils/WindowUtil' diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/build-profile.json5 b/multiticketclasssample/oh_modules/multiticketclasslibrary/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/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/multiticketclasssample/oh_modules/multiticketclasslibrary/consumer-rules.txt b/multiticketclasssample/oh_modules/multiticketclasslibrary/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/hvigorfile.ts b/multiticketclasssample/oh_modules/multiticketclasslibrary/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/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/multiticketclasssample/oh_modules/multiticketclasslibrary/obfuscation-rules.txt b/multiticketclasssample/oh_modules/multiticketclasslibrary/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/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/multiticketclasssample/oh_modules/multiticketclasslibrary/oh-package.json5 b/multiticketclasssample/oh_modules/multiticketclasslibrary/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..58f9d0afa08567cdaa131a24e6aaa1e323514b34 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "multiticketclasslibrary", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/CommonConstants.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/CommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bc69fbd01520b1fb49470b7043ee855a2080623 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/CommonConstants.ets @@ -0,0 +1,140 @@ +/* + * 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 { + /** + * 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'; + /** + * The break point value. + */ + public static readonly BREAK_POINTS_VALUE: Array = ['300', '600', '840']; + /** + * The number of columns for SM device. + */ + public static readonly COLUMN_SM: number = 4; + /** + * The number of columns for MD device. + */ + public static readonly COLUMN_MD: number = 8; + /** + * The number of columns for LG device. + */ + public static readonly COLUMN_LG: number = 12; + /** + * Tab adaptive padding sm. + */ + public static readonly TAB_PADDING_SM: string = '8vp'; + /** + * number 2 + */ + public static readonly NUMBER_TWO: number = 2; + /** + * Double tab adaptive padding sm. + */ + public static readonly DOUBLE_TAB_PADDING_SM: string = '16vp'; + /** + * Double tab adaptive padding md. + */ + public static readonly DOUBLE_TAB_PADDING_MD2: string = '70vp'; + /** + * Double tab adaptive padding lg. + */ + public static readonly DOUBLE_TAB_PADDING_LG2: string = '130vp'; + /** + * The full percentage of component. + */ + public static readonly FULL_WIDTH_PERCENT: string = '100%'; + /** + * The eighty percent. + */ + public static readonly EIGHTY_PERCENT: string = '80%'; + /** + * The fifty percent. + */ + public static readonly FIFTY_PERCENT: string = '50%'; + /** + * Common font weight. + */ + public static readonly FONT_WEIGHT_500: number = 500; + /** + * Border radius. + */ + public static readonly BORDER_RADIUS: number = 16; + /** + * Common flexShrink and layoutWeight. + */ + public static readonly COMMON_FAL_1: number = 1; + /** + * Text font size. + */ + public static readonly TEXT_FONT_SIZE: number = 10; + /** + * Index page padding top size. + */ + public static readonly PADDING_TOP_INDEX: number = 16; + /** + * Index page padding bottom size. + */ + public static readonly PADDING_BOTTOM_INDEX: number = 16; + /** + * Gray font flag. + */ + public static readonly GRAY_FONT_FLAG: string = 'Gray'; + /** + * Red font flag. + */ + public static readonly RED_FONT_FLAG: string = 'Red'; + /** + * Single tab title. + */ + public static readonly SINGLETAB_TITLE: string = 'tab自适应居中'; + /** + * Single tab title. + */ + public static readonly TABLE_TITLE: string = '表格自适应延伸'; + /** + * Single tab title. + */ + public static readonly DOUBLETAB_TITLE: string = '双tab自适应居中'; + /** + * Common font weight. + */ + public static readonly FONT_WEIGHT_700: number = 700; + /** + * Table list padding sm. + */ + public static readonly TABLE_LIST_PADDING_SM: number = 24; + /** + * Table list padding md. + */ + public static readonly TABLE_LIST_PADDING_MD: number = 90; + /** + * Table list padding lg. + */ + public static readonly TABLE_LIST_PADDING_LG: number = 150; +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/ListDataConstants.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/ListDataConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..938e316f8f4efc301b3847cbc3a8724204c7154d --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/constants/ListDataConstants.ets @@ -0,0 +1,80 @@ +/* + * 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 constants for all features. + */ +export class ListDataConstants { + /** + * Tab adaptive uri. + */ + public static readonly TAB_ADAPTIVE_URI: string = 'AdaptiveTabCenteringIndex'; + /** + * Table adaptive uri. + */ + public static readonly TABLE_ADAPTIVE_URI: string = 'TableAdaptiveExtensionIndex'; + /** + * Double tab adaptive uri. + */ + public static readonly DOUBLE_TAB_ADAPTIVE_URI: string = 'DoubleTabAdaptiveCenteringIndex'; + /** + * Recommendation tab list. + */ + public static readonly RECOMMENDATION_TAB_LIST: Resource[] = + [$r('app.string.recommendation'), $r('app.string.all_time'), $r('app.string.focus_news'), $r('app.string.calendar'), + $r('app.string.follow'), $r('app.string.share_a')]; + /** + * Stock options tab list 1. + */ + public static readonly STOCK_OPTIONS_LIST1: Resource[] = + [$r('app.string.share_a'), $r('app.string.global'), $r('app.string.share_b'), $r('app.string.share_c'), + $r('app.string.e_mul_f'), $r('app.string.futures')]; + /** + * Stock options tab list 2. + */ + public static readonly STOCK_OPTIONS_LIST2: Resource[] = + [$r('app.string.large_market'), $r('app.string.plate'), $r('app.string.chinext_board'), $r('app.string.science'), + $r('app.string.beijing_stock_exchange')]; + /** + * Indicator name list. + */ + public static readonly INDICATOR_NAME_LIST: Resource[] = + [$r('app.string.indicator_name'), $r('app.string.x_changhong'), $r('app.string.x_technology'), + $r('app.string.x_satellite')]; + /** + * Indicator name column. + */ + public static readonly INDICATOR_NAME_COLUMN: Resource[] = + [$r('app.string.core_indicators'), $r('app.string.industry_affiliation'), $r('app.string.latest_stock_price'), + $r('app.string.price_fluctuation_range'), $r('app.string.earning_ratio')]; + /** + * Stock index data 1. + */ + public static readonly STOCK_INDEX_DATA1: Resource[] = + [$r('app.string.blank'), $r('app.string.computer'), $r('app.string.price'), $r('app.string.range1'), + $r('app.string.earning1')]; + /** + * Stock index data 2. + */ + public static readonly STOCK_INDEX_DATA2: Resource[] = + [$r('app.string.blank'), $r('app.string.computer'), $r('app.string.price'), $r('app.string.range2'), + $r('app.string.earning2')]; + /** + * Stock index data 3. + */ + public static readonly STOCK_INDEX_DATA3: Resource[] = + [$r('app.string.blank'), $r('app.string.computer'), $r('app.string.price'), $r('app.string.range2'), + $r('app.string.earning2')]; +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..f80f2ef75c1beba8bc90cd6ca812a5139c3ff0a4 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/AdaptiveTabCenteringIndex.ets @@ -0,0 +1,111 @@ +/* + * 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 { ListDataConstants } from '../constants/ListDataConstants'; +import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointType } from '../utils/BreakpointSystem'; + +@Component +export struct AdaptiveTabCenteringIndex { + @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; + @Consume('pageInfos') pageInfos: NavPathStack; + @State tabIndexSelected: number = 0; + @StorageProp('topRectHeight') topRectHeight: number = 0; + + build() { + NavDestination() { + Column() { + Row() { + Button({ type: ButtonType.Circle }) { + SymbolGlyph($r('sys.symbol.chevron_backward')) + .fontColor([$r('sys.color.icon_primary')]) + .fontSize($r('sys.float.Title_M')) + } + .height($r('app.float.back_button_height')) + .aspectRatio(1) + .backgroundColor($r('sys.color.comp_background_tertiary')) + .onClick(() => this.pageInfos.pop()) + + Text($r('app.string.table_adaptive')) + .margin({ left: $r('sys.float.padding_level4') }) + .font({ size: $r('app.float.bar_font_size'), weight: CommonConstants.FONT_WEIGHT_700 }) + .fontColor($r('sys.color.font_primary')) + } + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .height($r('app.float.bar_height')) + .zIndex(CommonConstants.NUMBER_TWO) + + Row() { + List({ space: CommonConstants.TAB_PADDING_SM }) { + ForEach(ListDataConstants.RECOMMENDATION_TAB_LIST, (item: Resource, index: number) => { + ListItem() { + Button(item) + .fontSize($r('app.float.font_size_16')) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .backgroundColor(this.tabIndexSelected === index ? $r('sys.color.comp_background_emphasize') : + $r('sys.color.comp_background_tertiary')) + .fontColor(this.tabIndexSelected === index ? $r('sys.color.font_on_primary') : + $r('sys.color.font_primary')) + .width($r('app.float.text_width1')) + .height($r('app.float.text_height')) + .focusable(true) + .groupDefaultFocus(index === 0 ? true : false) + } + .width($r('app.float.text_width1')) + .margin({ + top: $r('app.float.recommendation_margin_top'), + bottom: $r('app.float.recommendation_margin_bottom') + }) + .onClick(() => { + this.tabIndexSelected = index; + }) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .alignListItem(ListItemAlign.Start) + .scrollBar(BarState.Off) + .listDirection(Axis.Horizontal) + } + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .backgroundColor($r('sys.color.background_secondary')) + .height($r('app.float.height_56')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + } + .height('100%') + } + .hideTitleBar(true) + .padding({ top: px2vp(this.topRectHeight) }) + .backgroundColor($r('sys.color.background_secondary')) + .title(CommonConstants.SINGLETAB_TITLE, { backgroundColor: $r('sys.color.background_primary') }) + } +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f5a951b6c574708f1aee566daaaab66afd228da --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets @@ -0,0 +1,191 @@ +/* + * 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 { ListDataConstants } from '../constants/ListDataConstants'; +import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointType } from '../utils/BreakpointSystem'; + +@Component +export struct DoubleTabAdaptiveCenteringIndex { + @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; + @Consume('pageInfos') pageInfos: NavPathStack; + @State tabIndexSelected: number = 0; + @State tabIndexSelected2: number = 0; + @StorageProp('topRectHeight') topRectHeight: number = 0; + + build() { + NavDestination() { + Column() { + Row() { + Button({ type: ButtonType.Circle }) { + SymbolGlyph($r('sys.symbol.chevron_backward')) + .fontColor([$r('sys.color.icon_primary')]) + .fontSize($r('sys.float.Title_M')) + } + .height($r('app.float.back_button_height')) + .aspectRatio(1) + .backgroundColor($r('sys.color.comp_background_tertiary')) + .onClick(() => this.pageInfos.pop()) + + Text($r('app.string.double_tab_adaptive')) + .margin({ left: $r('sys.float.padding_level4') }) + .font({ size: $r('app.float.bar_font_size'), weight: CommonConstants.FONT_WEIGHT_700 }) + .fontColor($r('sys.color.font_primary')) + } + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .height($r('app.float.bar_height')) + .zIndex(CommonConstants.NUMBER_TWO) + + //Column() { + Row() { + Column() { + List({ + space: new BreakpointType({ + sm: CommonConstants.TABLE_LIST_PADDING_SM, md: CommonConstants.TABLE_LIST_PADDING_MD, + lg: CommonConstants.TABLE_LIST_PADDING_LG + }).getValue(this.breakPoint) + }) { + ForEach(ListDataConstants.STOCK_OPTIONS_LIST1, (item: Resource, index: number) => { + ListItem() { + Column() { + Text(item) + .fontSize($r('app.float.font_size_16')) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .fontColor(this.tabIndexSelected === index ? $r('sys.color.font_emphasize') : + $r('sys.color.font_primary')) + .height($r('app.float.text_height')) + .focusable(true) + .groupDefaultFocus(index === 0 ? true : false) + } + } + .margin({ top: $r('app.float.stock_options_margin') }) + .border({ + width: { + bottom: this.tabIndexSelected === index ? + $r('app.float.bottom_width_2') : $r('app.float.bottom_width_0') + }, + color: { + bottom: this.tabIndexSelected === index ? $r('sys.color.font_emphasize') : '' + }, + style: { + bottom: BorderStyle.Solid + } + }) + .onClick(() => { + this.tabIndexSelected = index; + }) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .alignListItem(ListItemAlign.Center) + .scrollBar(BarState.Off) + .listDirection(Axis.Horizontal) + } + .margin({ bottom: $r('app.float.stock_options_margin') }) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + .width(new BreakpointType({ + sm: $r('app.float.width_296'), md: $r('app.float.width_312'), + lg: $r('app.float.width_312') + }).getValue(this.breakPoint)) + .height($r('app.float.height_56')) + + .layoutWeight(CommonConstants.COMMON_FAL_1) + + SymbolGlyph($r('sys.symbol.line_3_horizontal')) + .fontColor([$r('sys.color.icon_primary')]) + .fontSize($r('sys.float.Title_M')) + } + .justifyContent(FlexAlign.Start) + .backgroundColor($r('sys.color.background_secondary')) + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .height($r('app.float.height_56')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + + Row() { + Column() { + List({ + space: new BreakpointType({ + sm: CommonConstants.DOUBLE_TAB_PADDING_SM, md: CommonConstants.DOUBLE_TAB_PADDING_MD2, + lg: CommonConstants.DOUBLE_TAB_PADDING_LG2 + }).getValue(this.breakPoint) + }) { + ForEach(ListDataConstants.STOCK_OPTIONS_LIST2, (item: Resource, index: number) => { + ListItem() { + Column() { + Text(item) + .fontSize($r('app.float.font_size_14')) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .fontColor(this.tabIndexSelected2 === index ? $r('sys.color.font_on_primary') : + $r('sys.color.font_primary')) + .margin({ + top: $r('app.float.text_margin_top_and_bottom'), + bottom: $r('app.float.text_margin_top_and_bottom'), + left: $r('app.float.text_margin_left_and_right'), + right: $r('app.float.text_margin_left_and_right') + }) + .textAlign(TextAlign.Center) + .focusable(true) + .groupDefaultFocus(index === 0 ? true : false) + } + } + .backgroundColor( + this.tabIndexSelected2 === index ? $r('sys.color.font_emphasize') : + $r('sys.color.comp_background_tertiary') + ) + .border({ radius: CommonConstants.BORDER_RADIUS }) + .onClick(() => { + this.tabIndexSelected2 = index; + }) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .scrollBar(BarState.Off) + .listDirection(Axis.Horizontal) + } + .width($r('app.float.width_296')) + .height($r('app.float.height_56')) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(CommonConstants.COMMON_FAL_1) + } + .padding({ left: $r('sys.float.padding_level8') }) + .height($r('app.float.height_56')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + } + } + .hideTitleBar(true) + .padding({ top: px2vp(this.topRectHeight) }) + .backgroundColor($r('sys.color.background_secondary')) + .title(CommonConstants.DOUBLETAB_TITLE) + } +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dc4b4eaaa770e3ebe5681b1306f6d4400a155b4 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/MultiTicketClassPage.ets @@ -0,0 +1,150 @@ +/* + * 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 { CommonConstants } from '../constants/CommonConstants'; +import { ListDataConstants } from '../constants/ListDataConstants'; +import { AdaptiveTabCenteringIndex } from './AdaptiveTabCenteringIndex'; +import { TableAdaptiveExtensionIndex } from './TableAdaptiveExtensionIndex'; +import { DoubleTabAdaptiveCenteringIndex } from './DoubleTabAdaptiveCenteringIndex'; +import { BreakpointType } from '../utils/BreakpointSystem'; + +class DirectoryItem { + public title: ResourceStr = ''; + public uri: string = ''; + public id: string = ''; +} + +@Component +export struct MultiTicketClassPage { + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; + @StorageProp('bottomRectHeight') bottomRectHeight: number = 0; + @StorageProp('topRectHeight') topRectHeight: number = 0; + private title: string | Resource = $r('app.string.EntryAbility_label'); + private directory: DirectoryItem[] = [ + { + title: $r('app.string.tab_adaptive'), + uri: ListDataConstants.TAB_ADAPTIVE_URI, + id: 'AdaptiveTabCenteringIndex' + }, + { + title: $r('app.string.table_adaptive'), + uri: ListDataConstants.TABLE_ADAPTIVE_URI, + id: 'TableAdaptiveExtensionIndex' + }, + { + title: $r('app.string.double_tab_adaptive'), + uri: ListDataConstants.DOUBLE_TAB_ADAPTIVE_URI, + id: 'DoubleTabAdaptiveCenteringIndex' + } + ]; + + @Builder + PageMap(name: string) { + if (name === ListDataConstants.TAB_ADAPTIVE_URI) { + AdaptiveTabCenteringIndex() + } else if (name === ListDataConstants.TABLE_ADAPTIVE_URI) { + TableAdaptiveExtensionIndex() + } else { + DoubleTabAdaptiveCenteringIndex() + } + } + + build() { + GridRow({ + breakpoints: { + value: CommonConstants.BREAK_POINTS_VALUE, + reference: BreakpointsReference.WindowSize + }, + columns: { + sm: CommonConstants.COLUMN_SM, + md: CommonConstants.COLUMN_MD, + lg: CommonConstants.COLUMN_LG + }, + direction: GridRowDirection.Row + }) { + GridCol({ + span: { + sm: CommonConstants.COLUMN_SM, + md: CommonConstants.COLUMN_MD, + lg: CommonConstants.COLUMN_LG + } + }) { + Navigation(this.pageInfos) { + Column() { + Text(this.title) + .fontWeight(FontWeight.Bold) + .fontColor($r('sys.color.font_primary')) + .fontSize($r('sys.float.Title_L')) + .alignSelf(ItemAlign.Start) + .margin({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + Column() { + ForEach(this.directory, (item: DirectoryItem) => { + Button(item.title) + .id(item.id) + .fontSize($r('sys.float.Subtitle_M')) + .fontColor($r('sys.color.font_on_primary')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .height($r('app.float.button_height')) + .margin({ top: $r('sys.float.padding_level6') }) + .backgroundColor($r('sys.color.comp_background_emphasize')) + .onClick(() => { + this.pageInfos.pushPath(new NavPathInfo(item.uri, [])); + }) + }, (item: DirectoryItem) => JSON.stringify(item)) + } + .width(new BreakpointType({ + sm: $r('app.string.fullwidth'), md: $r('app.float.index_button_width_md'), + lg: $r('app.float.index_button_width_lg') + }).getValue(this.breakPoint)) + .padding({ + left: new BreakpointType({ + sm: $r('app.float.index_button_width_sm'), + md: $r('app.float.index_button_padding_md_lg'), + lg: $r('app.float.index_button_padding_md_lg') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('app.float.index_button_width_sm'), + md: $r('app.float.index_button_padding_md_lg'), + lg: $r('app.float.index_button_padding_md_lg') + }).getValue(this.breakPoint) + }) + } + .backgroundColor($r('sys.color.background_primary')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .height(CommonConstants.FULL_WIDTH_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + top: CommonConstants.PADDING_TOP_INDEX + px2vp(this.topRectHeight), + bottom: CommonConstants.PADDING_BOTTOM_INDEX + px2vp(this.bottomRectHeight) + }) + } + .height(CommonConstants.FULL_WIDTH_PERCENT) + .backgroundColor($r('sys.color.background_primary')) + .navDestination(this.PageMap) + .mode(NavigationMode.Stack) + .hideBackButton(true) + .titleMode(NavigationTitleMode.Mini) + .hideTitleBar(true) + .padding({ top: this.topRectHeight }) + } + } + } +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..e4cd51be89f0cb7ca1831a042ae7cfa9e4f2602e --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/ets/pages/TableAdaptiveExtensionIndex.ets @@ -0,0 +1,193 @@ +/* + * 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 { ListDataConstants } from '../constants/ListDataConstants'; +import { CommonConstants } from '../constants/CommonConstants'; +import { BreakpointType } from '../utils/BreakpointSystem'; + +@Component +export struct TableAdaptiveExtensionIndex { + @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; + @Consume('pageInfos') pageInfos: NavPathStack; + @StorageProp('topRectHeight') topRectHeight: number = 0; + + @Builder + Item(item: Resource, index: number, color: string) { + Row() { + Text(item) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontSize($r('app.float.font_size_14')) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .fontColor(color === CommonConstants.GRAY_FONT_FLAG ? (index > 0 ? Color.Gray : $r('sys.color.font_primary')) : + ((index === 2 || index === 3) ? $r('sys.color.font_emphasize') : $r('sys.color.font_primary'))) + .height($r('app.float.text_height')) + } + .flexShrink(CommonConstants.COMMON_FAL_1) + } + + build() { + NavDestination() { + Column() { + Row() { + Button({ type: ButtonType.Circle }) { + SymbolGlyph($r('sys.symbol.chevron_backward')) + .fontColor([$r('sys.color.icon_primary')]) + .fontSize($r('sys.float.Title_M')) + } + .height($r('app.float.back_button_height')) + .aspectRatio(1) + .backgroundColor($r('sys.color.comp_background_tertiary')) + .onClick(() => this.pageInfos.pop()) + + Text($r('app.string.table_adaptive')) + .margin({ left: $r('sys.float.padding_level4') }) + .font({ size: $r('app.float.bar_font_size'), weight: CommonConstants.FONT_WEIGHT_700 }) + .fontColor($r('sys.color.font_primary')) + } + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .height($r('app.float.bar_height')) + .zIndex(CommonConstants.NUMBER_TWO) + + Row() { + if (this.breakPoint === CommonConstants.BREAK_POINT_LG) { + Column() { + // Left Placeholder Area + } + .width(CommonConstants.FIFTY_PERCENT) + .height(CommonConstants.FULL_WIDTH_PERCENT) + .border({ + width: { right: 1 }, + color: { right: Color.Gray }, + style: { right: BorderStyle.Solid } + }) + } + Column() { + Row() { + Column() { + Row() { + ForEach(ListDataConstants.INDICATOR_NAME_LIST, (item: Resource, index: number) => { + Column() { + Row() { + Text(item) + .fontSize($r('app.float.font_size_14')) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .fontColor($r('sys.color.font_primary')) + .height($r('app.float.text_height')) + Image(index > 0 ? $r('app.media.ic_public_right') : $r('app.media.ic_public_info')) + .width($r('app.float.icon_size')) + .height($r('app.float.icon_size')) + } + + if (index > 0) { + Text('60**39') + .fontSize(CommonConstants.TEXT_FONT_SIZE) + .fontWeight(CommonConstants.FONT_WEIGHT_500) + .fontColor($r('sys.color.font_secondary')) + .height($r('app.float.text_height')) + } + } + .flexShrink(CommonConstants.COMMON_FAL_1) + .width(index === 0 ? $r('app.float.indicator_name_width') : 'auto') + .alignItems(HorizontalAlign.Start) + + if (index < 3) { + Blank() + } + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .height($r('app.float.indicator_name_height')) + .width(CommonConstants.FULL_WIDTH_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .color($r('sys.color.comp_foreground_primary')) + + Row() { + Column() { + ForEach(ListDataConstants.INDICATOR_NAME_COLUMN, (item: Resource, index: number) => { + this.Item(item, index, CommonConstants.GRAY_FONT_FLAG) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .alignItems(HorizontalAlign.Start) + + Blank() + + Column() { + ForEach(ListDataConstants.STOCK_INDEX_DATA1, (item: Resource, index: number) => { + this.Item(item, index, CommonConstants.RED_FONT_FLAG) + }, (item: Resource, index: number) => index + JSON.stringify(item)) + } + .width($r('app.float.stock_data_width')) + .alignItems(HorizontalAlign.End) + + Blank() + + Column() { + ForEach(ListDataConstants.STOCK_INDEX_DATA2, (item: Resource, index: number) => { + this.Item(item, index, CommonConstants.RED_FONT_FLAG) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .width($r('app.float.stock_data_width')) + .alignItems(HorizontalAlign.End) + + Blank() + + Column() { + ForEach(ListDataConstants.STOCK_INDEX_DATA3, (item: Resource, index: number) => { + this.Item(item, index, CommonConstants.RED_FONT_FLAG) + }, (item: string, index: number) => index + JSON.stringify(item)) + } + .width($r('app.float.stock_data_width')) + .alignItems(HorizontalAlign.End) + } + .width(CommonConstants.FULL_WIDTH_PERCENT) + .margin({ top: $r('app.float.indicator_name_margin') }) + } + } + } + .height(CommonConstants.EIGHTY_PERCENT) + .width(this.breakPoint === CommonConstants.BREAK_POINT_LG ? + CommonConstants.FIFTY_PERCENT : CommonConstants.FULL_WIDTH_PERCENT) + } + .padding({ + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.breakPoint) + }) + .width(CommonConstants.FULL_WIDTH_PERCENT) + } + } + .hideTitleBar(true) + .padding({ top: px2vp(this.topRectHeight) }) + .backgroundColor($r('sys.color.background_secondary')) + .title(CommonConstants.TABLE_TITLE) + } +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/module.json5 b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c60520f63feee39b0300e100a595ab496584fff0 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "multiticketclasslibrary", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/color.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/float.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..ac08e60eea73923612618bb90cbfae0c675377e3 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/float.json @@ -0,0 +1,112 @@ +{ + "float": [ + { + "name": "button_height", + "value": "40vp" + }, + { + "name": "index_button_width_sm", + "value": "16vp" + }, + { + "name": "index_button_padding_md_lg", + "value": "0vp" + }, + { + "name": "back_button_height", + "value": "40vp" + }, + { + "name": "bar_font_size", + "value": "20vp" + }, + { + "name": "bar_height", + "value": "56vp" + }, + { + "name": "index_button_width_md", + "value": "448vp" + }, + { + "name": "index_button_width_lg", + "value": "448vp" + }, + { + "name": "font_size_16", + "value": "15fp" + }, + { + "name": "font_size_14", + "value": "14fp" + }, + { + "name": "icon_size", + "value": "16vp" + }, + { + "name": "stock_data_width", + "value": "60vp" + }, + { + "name": "text_height", + "value": "36vp" + }, + { + "name": "text_width1", + "value": "70vp" + }, + { + "name": "height_56", + "value": "56vp" + }, + { + "name": "width_296", + "value": "296vp" + }, + { + "name": "width_312", + "value": "312vp" + }, + { + "name": "bottom_width_2", + "value": "2vp" + }, + { + "name": "bottom_width_0", + "value": "0vp" + }, + { + "name": "text_margin_left_and_right", + "value": "14vp" + }, + { + "name": "text_margin_top_and_bottom", + "value": "5vp" + }, + { + "name": "indicator_name_width", + "value": "99vp" + }, + { + "name": "indicator_name_height", + "value": "48vp" + }, + { + "name": "indicator_name_margin", + "value": "12vp" + }, + { + "name": "stock_options_margin", + "value": "18vp" + }, + { + "name": "recommendation_margin_top", + "value": "20vp" + }, + { + "name": "recommendation_margin_bottom", + "value": "13vp" + } + ] +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/string.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2a6211e7fb2415dc95f717320a34dbe096ae53a7 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/element/string.json @@ -0,0 +1,160 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "MultiTicketClass" + }, + { + "name": "tab_adaptive", + "value": "Adaptive tab centering" + }, + { + "name": "table_adaptive", + "value": "Table Adaptive Stretch" + }, + { + "name": "double_tab_adaptive", + "value": "Double tab adaptive centering" + }, + { + "name": "computer", + "value": "Computer" + }, + { + "name": "fullwidth", + "value": "100%" + }, + { + "name": "recommendation", + "value": "Recommendation" + }, + { + "name": "all_time", + "value": "7X24" + }, + { + "name": "focus_news", + "value": "Focus News" + }, + { + "name": "calendar", + "value": "Calendar" + }, + { + "name": "follow", + "value": "Follow" + }, + { + "name": "global", + "value": "Global" + }, + { + "name": "share_b", + "value": "B-shares" + }, + { + "name": "share_c", + "value": "C-shares" + }, + { + "name": "share_a", + "value": "A-shares" + }, + { + "name": "e_mul_f", + "value": "E*F" + }, + { + "name": "futures", + "value": "Futures" + }, + { + "name": "large_market", + "value": "Large market" + }, + { + "name": "plate", + "value": "Plate" + }, + { + "name": "chinext_board", + "value": "ChiNext board" + }, + { + "name": "science", + "value": "Science and Technology Innovation Board" + }, + { + "name": "beijing_stock_exchange", + "value": "Stock Exchange" + }, + { + "name": "indicator_name", + "value": "Indicator Name" + }, + { + "name": "x_changhong", + "value": "XChangeHong" + }, + { + "name": "x_satellite", + "value": "XSatellite" + }, + { + "name": "x_technology", + "value": "XTechnology" + }, + { + "name": "core_indicators", + "value": "Core indicators" + }, + { + "name": "industry_affiliation", + "value": "Industry affiliation" + }, + { + "name": "latest_stock_price", + "value": "Latest stock price" + }, + { + "name": "price_fluctuation_range", + "value": "Price fluctuation range" + }, + { + "name": "earning_ratio", + "value": "Price to earnings ratio" + }, + { + "name": "blank", + "value": " " + }, + { + "name": "price", + "value": "19.86" + }, + { + "name": "range1", + "value": "5.15%" + }, + { + "name": "range2", + "value": "10.02%" + }, + { + "name": "earning1", + "value": "171.54" + }, + { + "name": "earning2", + "value": "95.58" + } + ] +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_info.png b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_info.png new file mode 100644 index 0000000000000000000000000000000000000000..9d50cc007b1d1245e3e8af8abe86956213275623 Binary files /dev/null and b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_info.png differ diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_right.png b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_right.png new file mode 100644 index 0000000000000000000000000000000000000000..489e1109334751f60b66a036df613d2895dd5281 Binary files /dev/null and b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/ic_public_right.png differ diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/icon.png b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/icon.png differ diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/startIcon.png b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..366f76459ffd4494ec40d0ddd5c59385b9c5da11 Binary files /dev/null and b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/media/startIcon.png differ diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..2505f0162c3bd8d484ac414fa68890260d0ff8bf --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/MultiTicketClassPage" + ] +} diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/en_US/element/string.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c8fedd181534f3440ce45e84cdff18ddfbfd0392 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/en_US/element/string.json @@ -0,0 +1,160 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "MultiTicketClass" + }, + { + "name": "tab_adaptive", + "value": "Adaptive tab centering" + }, + { + "name": "table_adaptive", + "value": "Table Adaptive Stretch" + }, + { + "name": "double_tab_adaptive", + "value": "Double tab adaptive centering" + }, + { + "name": "computer", + "value": "Computer" + }, + { + "name": "fullwidth", + "value": "100%" + }, + { + "name": "recommendation", + "value": "Recommendation" + }, + { + "name": "all_time", + "value": "7X24" + }, + { + "name": "focus_news", + "value": "Focus News" + }, + { + "name": "calendar", + "value": "Calendar" + }, + { + "name": "follow", + "value": "Follow" + }, + { + "name": "global", + "value": "Global" + }, + { + "name": "share_b", + "value": "B-shares" + }, + { + "name": "share_c", + "value": "C-shares" + }, + { + "name": "share_a", + "value": "A-shares" + }, + { + "name": "e_mul_f", + "value": "E*F" + }, + { + "name": "futures", + "value": "Futures" + }, + { + "name": "large_market", + "value": "Large market" + }, + { + "name": "plate", + "value": "Plate" + }, + { + "name": "chinext_board", + "value": "ChiNext board" + }, + { + "name": "science", + "value": "Science and Technology Innovation Board" + }, + { + "name": "beijing_stock_exchange", + "value": "Stock Exchange" + }, + { + "name": "indicator_name", + "value": "Indicator Name" + }, + { + "name": "x_changhong", + "value": "XChangeHong" + }, + { + "name": "x_satellite", + "value": "XSatellite" + }, + { + "name": "x_technology", + "value": "XTechnology" + }, + { + "name": "core_indicators", + "value": "Core indicators" + }, + { + "name": "industry_affiliation", + "value": "Industry affiliation" + }, + { + "name": "latest_stock_price", + "value": "Latest stock price" + }, + { + "name": "price_fluctuation_range", + "value": "Price fluctuation range" + }, + { + "name": "earning_ratio", + "value": "Price to earnings ratio" + }, + { + "name": "blank", + "value": " " + }, + { + "name": "price", + "value": "19.86" + }, + { + "name": "range1", + "value": "5.15%" + }, + { + "name": "range2", + "value": "10.02%" + }, + { + "name": "earning1", + "value": "171.54" + }, + { + "name": "earning2", + "value": "95.58" + } + ] +} \ No newline at end of file diff --git a/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/zh_CN/element/string.json b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..53f9ddd2e0516d8e453be2545f31f3d13dda7da5 --- /dev/null +++ b/multiticketclasssample/oh_modules/multiticketclasslibrary/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,160 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "一多股票类" + }, + { + "name": "tab_adaptive", + "value": "tab自适应居中" + }, + { + "name": "table_adaptive", + "value": "表格自适应延伸" + }, + { + "name": "double_tab_adaptive", + "value": "双tab自适应居中" + }, + { + "name": "computer", + "value": "计算机" + }, + { + "name": "fullwidth", + "value": "100%" + }, + { + "name": "recommendation", + "value": "推荐" + }, + { + "name": "all_time", + "value": "7X24" + }, + { + "name": "focus_news", + "value": "要闻" + }, + { + "name": "calendar", + "value": "日历" + }, + { + "name": "follow", + "value": "关注" + }, + { + "name": "global", + "value": "全球" + }, + { + "name": "share_b", + "value": "B股" + }, + { + "name": "share_c", + "value": "C股" + }, + { + "name": "share_a", + "value": "A股" + }, + { + "name": "e_mul_f", + "value": "E*F" + }, + { + "name": "futures", + "value": "期货" + }, + { + "name": "large_market", + "value": "大盘" + }, + { + "name": "plate", + "value": "板块" + }, + { + "name": "chinext_board", + "value": "创业板" + }, + { + "name": "science", + "value": "科创版" + }, + { + "name": "beijing_stock_exchange", + "value": "交易所" + }, + { + "name": "indicator_name", + "value": "指标名称" + }, + { + "name": "x_changhong", + "value": "某某长虹" + }, + { + "name": "x_satellite", + "value": "某某卫星" + }, + { + "name": "x_technology", + "value": "某某科技" + }, + { + "name": "core_indicators", + "value": "核心指标" + }, + { + "name": "industry_affiliation", + "value": "所属行业" + }, + { + "name": "latest_stock_price", + "value": "最新股价(元)" + }, + { + "name": "price_fluctuation_range", + "value": "涨跌幅" + }, + { + "name": "earning_ratio", + "value": "市盈率(TTM)" + }, + { + "name": "blank", + "value": " " + }, + { + "name": "price", + "value": "19.86" + }, + { + "name": "range1", + "value": "5.15%" + }, + { + "name": "range2", + "value": "10.02%" + }, + { + "name": "earning1", + "value": "171.54" + }, + { + "name": "earning2", + "value": "95.58" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/multiticketclasssample/src/main/ets/entryability/EntryAbility.ets similarity index 48% rename from entry/src/main/ets/entryability/EntryAbility.ets rename to multiticketclasssample/src/main/ets/entryability/EntryAbility.ets index abb1cd342d22289edb382b3ce3113940c3c9104e..3cb63e1a026a54c1e018ba84d40930580ef88f6d 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/multiticketclasssample/src/main/ets/entryability/EntryAbility.ets @@ -15,9 +15,8 @@ import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { display, window } from '@kit.ArkUI'; -import { CommonConstants } from '../constants/CommonConstants'; -import { BusinessError } from '@kit.BasicServicesKit'; +import { window } from '@kit.ArkUI'; +import {WindowUtil} from 'multiticketclasslibrary' export default class EntryAbility extends UIAbility { onCreate(): void { @@ -33,33 +32,9 @@ export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.getMainWindow().then((data: window.Window) => { - let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - try { - let avoidArea = data.getWindowAvoidArea(type); - let bottomRectHeight = avoidArea.bottomRect.height; - AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); - type = window.AvoidAreaType.TYPE_SYSTEM; - avoidArea = data.getWindowAvoidArea(type); - let topRectHeight = avoidArea.topRect.height; - AppStorage.setOrCreate('topRectHeight', topRectHeight); - this.updateBreakpoint(data.getWindowProperties().windowRect.width); + WindowUtil.requestFullScreen(windowStage) + WindowUtil.registerBreakPoint(windowStage) - data.on('windowSizeChange', (windowSize: window.Size) => { - this.updateBreakpoint(windowSize.width); - }); - - data.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 main window fail. Cause: ' + err.message); - } - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', `Failed to get main window. Cause: ${err.message}`); - }); windowStage.loadContent('pages/Index', (err) => { if (err.code) { hilog.error(0x0000, 'testTag', '%{public}s', 'Failed to load the content. Cause: ' + err.code); @@ -69,24 +44,6 @@ export default class EntryAbility extends UIAbility { }); } - private updateBreakpoint(windowWidth: number): void { - try { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let curBp: string = ''; - if (windowWidthVp < Number(CommonConstants.BREAK_POINTS_VALUE[1])) { - curBp = CommonConstants.BREAK_POINT_SM; - } else if (windowWidthVp < Number(CommonConstants.BREAK_POINTS_VALUE[2])) { - curBp = CommonConstants.BREAK_POINT_MD; - } else { - curBp = CommonConstants.BREAK_POINT_LG; - } - AppStorage.setOrCreate('breakPoint', curBp); - } catch (exception) { - hilog.error(0x0000, 'testTag', '%{public}s', - `UpdateBreakpoint fail, error code: ${(exception as BusinessError).code}`); - } - } - onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); diff --git a/entry/src/main/ets/utils/BreakpointType.ets b/multiticketclasssample/src/main/ets/pages/Index.ets similarity index 61% rename from entry/src/main/ets/utils/BreakpointType.ets rename to multiticketclasssample/src/main/ets/pages/Index.ets index 5838943c205f2f88871ac6d6389fe640c8c6ca6d..d3f897b2c03ed29cb415fffa2812259831bd2d36 100644 --- a/entry/src/main/ets/utils/BreakpointType.ets +++ b/multiticketclasssample/src/main/ets/pages/Index.ets @@ -13,25 +13,14 @@ * limitations under the License. */ -export class BreakpointType { - private sm: T; - private md: T; - private lg: T; +import { MultiTicketClassPage } from 'multiticketclasslibrary' - constructor(sm: T, md: T, lg: T) { - this.sm = sm; - this.md = md; - this.lg = lg; - } - - getValue(currentBreakpoint: string): T { - if (currentBreakpoint === 'md') { - return this.md; - } - if (currentBreakpoint === 'lg') { - return this.lg; - } else { - return this.sm; +@Entry +@Component +struct Index { + build() { + Stack() { + MultiTicketClassPage() } } } \ No newline at end of file diff --git a/entry/src/main/module.json5 b/multiticketclasssample/src/main/module.json5 similarity index 88% rename from entry/src/main/module.json5 rename to multiticketclasssample/src/main/module.json5 index 4ce13180c363e69c1fc454fba00c230b668cb871..d2fa0fda19cf08b6c96fe864d6bcf0b7073cd744 100644 --- a/entry/src/main/module.json5 +++ b/multiticketclasssample/src/main/module.json5 @@ -1,6 +1,6 @@ { "module": { - "name": "entry", + "name": "multiticketclasssample", "type": "entry", "description": "$string:module_desc", "mainElement": "EntryAbility", @@ -14,14 +14,14 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "EntryAbility", + "name": "MultiticketclasssampleAbility", "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/multiticketclasssample/src/main/resources/base/profile/main_pages.json similarity index 100% rename from entry/src/main/resources/base/profile/main_pages.json rename to multiticketclasssample/src/main/resources/base/profile/main_pages.json