From 2f356a4b7d1725f3724f10aa86a19e9e21b23d0f Mon Sep 17 00:00:00 2001 From: EasyGuohf <163991322+EasyGuohf@users.noreply.github.com> Date: Mon, 19 May 2025 20:31:35 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=A1=A8=E6=A0=BC=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E5=AF=B9=E9=BD=90=E4=BF=AE=E6=94=B9=202?= =?UTF-8?q?=E3=80=81=E5=8F=8CTab=E5=B1=85=E4=B8=AD=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 3 ++ .../pages/DoubleTabAdaptiveCenteringIndex.ets | 28 +++++++++--- .../ets/pages/TableAdaptiveExtensionIndex.ets | 9 ---- entry/src/main/ets/utils/Logger.ets | 45 +++++++++++++++++++ entry/src/main/ets/utils/WindowUtil.ets | 37 +++++++++++++++ .../main/resources/base/element/float.json | 4 ++ .../main/resources/base/element/string.json | 2 +- .../main/resources/en_US/element/string.json | 2 +- .../main/resources/zh_CN/element/string.json | 2 +- 9 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 entry/src/main/ets/utils/Logger.ets create mode 100644 entry/src/main/ets/utils/WindowUtil.ets diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index abb1cd3..e60ff24 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -18,6 +18,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; import { CommonConstants } from '../constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; +import { WindowUtil } from '../utils/WindowUtil'; export default class EntryAbility extends UIAbility { onCreate(): void { @@ -44,9 +45,11 @@ export default class EntryAbility extends UIAbility { let topRectHeight = avoidArea.topRect.height; AppStorage.setOrCreate('topRectHeight', topRectHeight); this.updateBreakpoint(data.getWindowProperties().windowRect.width); + WindowUtil.getDeviceSize(getContext(this)); data.on('windowSizeChange', (windowSize: window.Size) => { this.updateBreakpoint(windowSize.width); + WindowUtil.getDeviceSize(getContext(this)); }); data.setWindowLayoutFullScreen(true).then(() => { diff --git a/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets b/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets index bbe918e..0255dca 100644 --- a/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets +++ b/entry/src/main/ets/pages/DoubleTabAdaptiveCenteringIndex.ets @@ -17,6 +17,8 @@ import { ListDataConstants } from '../constants/ListDataConstants'; import { CommonConstants } from '../constants/CommonConstants'; import { BreakpointType } from '../utils/BreakpointType'; +const TAB_MORE_SIZE: number = 24; // Size of More Menus + @Component export struct DoubleTabAdaptiveCenteringIndex { @StorageLink('breakPoint') breakPoint: string = CommonConstants.BREAK_POINT_SM; @@ -24,6 +26,23 @@ export struct DoubleTabAdaptiveCenteringIndex { @State tabIndexSelected: number = 0; @State tabIndexSelected2: number = 0; @StorageProp('topRectHeight') topRectHeight: number = 0; + @StorageProp('window.width') winWidth: number = 0; // Width of Window + + private getTabPadding(breakPoint: string): number { + let padding: number = 16; + switch (breakPoint) { + case CommonConstants.BREAK_POINT_MD: + padding = 24; + break; + case CommonConstants.BREAK_POINT_LG: + padding = 32; + break; + default: + padding = 16; + break; + } + return padding; + } build() { NavDestination() { @@ -54,13 +73,9 @@ export struct DoubleTabAdaptiveCenteringIndex { .height($r('app.float.bar_height')) .zIndex(CommonConstants.NUMBER_TWO) - //Column() { Row() { Column() { - List({ - space: new BreakpointType(CommonConstants.TABLE_LIST_PADDING_SM, CommonConstants.TABLE_LIST_PADDING_MD, - CommonConstants.TABLE_LIST_PADDING_LG).getValue(this.breakPoint) - }) { + List() { ForEach(ListDataConstants.STOCK_OPTIONS_LIST1, (item: Resource, index: number) => { ListItem() { Column() { @@ -74,6 +89,8 @@ export struct DoubleTabAdaptiveCenteringIndex { .groupDefaultFocus(index === 0 ? true : false) } } + .width((this.winWidth - this.getTabPadding(this.breakPoint) * 2 - TAB_MORE_SIZE) / + ListDataConstants.STOCK_OPTIONS_LIST1.length) .margin({ top: $r('app.float.stock_options_margin') }) .border({ width: { @@ -102,7 +119,6 @@ export struct DoubleTabAdaptiveCenteringIndex { .width(new BreakpointType($r('app.float.width_296'), $r('app.float.width_312'), $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')) diff --git a/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets b/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets index 630b87d..e9224e3 100644 --- a/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets +++ b/entry/src/main/ets/pages/TableAdaptiveExtensionIndex.ets @@ -96,14 +96,6 @@ export struct TableAdaptiveExtensionIndex { .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') @@ -114,7 +106,6 @@ export struct TableAdaptiveExtensionIndex { } }, (item: string, index: number) => index + JSON.stringify(item)) } - .height($r('app.float.indicator_name_height')) .width(CommonConstants.FULL_WIDTH_PERCENT) .justifyContent(FlexAlign.SpaceBetween) diff --git a/entry/src/main/ets/utils/Logger.ets b/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000..d9378e1 --- /dev/null +++ b/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,45 @@ +/* + * 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 { hilog } from '@kit.PerformanceAnalysisKit'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + public constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + public debug(...args: Object[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + public info(...args: Object[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + public warn(...args: Object[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + public error(...args: Object[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger('[multiTicketClass]'); \ No newline at end of file diff --git a/entry/src/main/ets/utils/WindowUtil.ets b/entry/src/main/ets/utils/WindowUtil.ets new file mode 100644 index 0000000..90092cd --- /dev/null +++ b/entry/src/main/ets/utils/WindowUtil.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import Logger from './Logger'; + +const TAG: string = '[WindowUtil]'; + +export class WindowUtil { + public static getDeviceSize(context: Context): void { + window.getLastWindow(context).then((data: window.Window) => { + try { + const properties = data.getWindowProperties(); + const winWidth = px2vp(properties.windowRect.width); + AppStorage.setOrCreate('window.width', winWidth); + } catch (err) { + const error = err as BusinessError; + Logger.error(TAG, `Get and setDeviceSize failed. code: ${error.code}, message: ${error.message}`); + } + }).catch((error: BusinessError) => { + Logger.error(TAG, `GetLastWindow failed. code: ${error.code}, message: ${error.message}`); + }); + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index ac08e60..0c23e0d 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -52,6 +52,10 @@ "name": "text_height", "value": "36vp" }, + { + "name": "text_sub_height", + "value": "21vp" + }, { "name": "text_width1", "value": "70vp" diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 2a6211e..7f0b5ff 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -134,7 +134,7 @@ }, { "name": "blank", - "value": " " + "value": "60**39" }, { "name": "price", diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index c8fedd1..7f0b5ff 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -134,7 +134,7 @@ }, { "name": "blank", - "value": " " + "value": "60**39" }, { "name": "price", diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 53f9ddd..b7c173c 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -134,7 +134,7 @@ }, { "name": "blank", - "value": " " + "value": "60**39" }, { "name": "price", -- Gitee