diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index abb1cd342d22289edb382b3ce3113940c3c9104e..e60ff240f11413c298f4c0ed5187c4a7e58ce7e5 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 bbe918e6f44f787a91a3ce69c8a782776ea6366a..0255dca4c14252c4826eca1daedac36b458190dd 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 630b87d0919f566f6eda0161142defa550223bc1..e9224e3a5074344934e977b2e2713a889a2e5b77 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 0000000000000000000000000000000000000000..d9378e173e7d22c1465193ef4fe5c1e420d7cda3 --- /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 0000000000000000000000000000000000000000..90092cd05ce33e126dc4d2e97470e2ee41c0428c --- /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 ac08e60eea73923612618bb90cbfae0c675377e3..0c23e0d006ea846032ac33fe1437b2e69a2319c6 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 2a6211e7fb2415dc95f717320a34dbe096ae53a7..7f0b5ff1bd01a704514f2f5d0bb291ab6403d333 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 c8fedd181534f3440ce45e84cdff18ddfbfd0392..7f0b5ff1bd01a704514f2f5d0bb291ab6403d333 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 53f9ddd2e0516d8e453be2545f31f3d13dda7da5..b7c173ca2e0707b911a37ae4da5450d519a56727 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",