From 4f9a7c06443cff4f4aabb84d1bb5ce8c4eb2bcdc Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 28 Feb 2025 20:06:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?HMOSWorld=E6=95=B4=E6=94=B9=20(1)UX?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E9=80=82=E9=85=8D;=20(2)=E6=B7=B1=E6=B5=85?= =?UTF-8?q?=E8=89=B2=E9=80=82=E9=85=8D;=20(3)=E6=B2=89=E6=B5=B8=E5=BC=8F?= =?UTF-8?q?=E9=80=82=E9=85=8D;=20(4)=E4=B8=80=E5=A4=9A=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=95=B4=E6=94=B9;=20(5)=E5=9B=BE=E6=A0=87/=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2;=20(6)=E5=9B=BD=E9=99=85=E5=8C=96=E6=95=B4?= =?UTF-8?q?=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 15 +++ entry/src/main/ets/common/utils/Utils.ets | 38 +++++++ .../main/ets/entryability/EntryAbility.ets | 63 ++++++++++- entry/src/main/ets/pages/Index.ets | 105 ++++++++++-------- entry/src/main/ets/viewmodel/InitData.ets | 4 +- .../main/resources/base/element/float.json | 28 ++++- 6 files changed, 195 insertions(+), 58 deletions(-) create mode 100644 entry/src/main/ets/common/utils/Utils.ets diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index c5894a3..4c8dfb7 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -82,4 +82,19 @@ export class CommonConstants { * Height the percentage of the 100. */ static readonly FULL_HEIGHT: string = '100%'; + + /** + * Breakpoint sm. + */ + static readonly BREAK_POINT_SM: string = 'sm'; + + /** + * Breakpoint md. + */ + static readonly BREAK_POINT_MD: string = 'md'; + + /** + * Breakpoint lg. + */ + static readonly BREAK_POINT_LG: string = 'lg'; } \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Utils.ets b/entry/src/main/ets/common/utils/Utils.ets new file mode 100644 index 0000000..820d7bb --- /dev/null +++ b/entry/src/main/ets/common/utils/Utils.ets @@ -0,0 +1,38 @@ +/* + * 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"; + +export class BreakpointType { + sm: T; + md: T; + lg: T; + + constructor(sm: T, md: T, lg: T) { + this.sm = sm; + this.md = md; + this.lg = lg; + } + + getValue(currentBreakpoint: string): T { + if (currentBreakpoint === CommonConstants.BREAK_POINT_MD) { + return this.md; + } + if (currentBreakpoint === CommonConstants.BREAK_POINT_LG) { + return this.lg; + } else { + return this.sm; + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 034ae42..579b04b 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,13 +13,45 @@ * limitations under the License. */ -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { AbilityConstant, Configuration, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { display, window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { resourceManager } from '@kit.LocalizationKit'; export default class EntryAbility extends UIAbility { + private windowObj?: window.Window; + private curBp: string = ''; + + private updateBreakpoint(windowWidth: number): void { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < 600) { + newBp = 'sm'; + } else if (windowWidthVp < 840) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } + + onConfigurationUpdate(newConfig: Configuration): void { + let newColorMode: ConfigurationConstant.ColorMode = + newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; + let currentColorMode = AppStorage.get('systemColorMode'); + if (newColorMode !== currentColorMode) { + AppStorage.setOrCreate('systemColorMode', newColorMode); + } } onDestroy(): void { @@ -27,16 +59,39 @@ export default class EntryAbility extends UIAbility { } onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.getMainWindow().then((windowObj: window.Window) => { + let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + let avoidArea = windowObj.getWindowAvoidArea(type); + let bottomRectHeight = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + type = window.AvoidAreaType.TYPE_SYSTEM; + avoidArea = windowObj.getWindowAvoidArea(type); + let topRectHeight = avoidArea.topRect.height; + AppStorage.setOrCreate('topRectHeight', topRectHeight); + this.windowObj = windowObj; + this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); + windowObj.on('windowSizeChange', (windowSize) => { + this.updateBreakpoint(windowSize.width); + }) + }); // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - + let context = this.context; + let resourceManager: resourceManager.ResourceManager = context.resourceManager; + AppStorage.setOrCreate('resourceManager', resourceManager); windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - windowStage.getMainWindowSync().setWindowBackgroundColor('#F1F3F5'); + let windowClass: window.Window = windowStage.getMainWindowSync(); + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); }); } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index f69ab3e..fd7a90a 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -15,11 +15,15 @@ import { listArr } from '../viewmodel/InitData'; import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType } from '../common/utils/Utils'; @Entry @Component struct NestedCeiling { @State currentIndex: number = 0; + @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageProp('topRectHeight') + topRectHeight: number = 0; private scrollerForScroll: Scroller = new Scroller(); private scrollerForList: Scroller = new Scroller(); @@ -27,51 +31,53 @@ struct NestedCeiling { tabBuilder(index: number, name: ResourceStr) { Column() { Text(name) - .fontColor(this.currentIndex === index ? $r('app.color.active_font_color') : $r('app.color.font_color')) + .fontColor(this.currentIndex === index ? $r('sys.color.font_on_primary') : $r('sys.color.brand')) .fontSize($r('app.float.middle_font_size')) - .fontWeight(this.currentIndex === index ? CommonConstants.FONT_WEIGHT_FIVE : CommonConstants.FONT_WEIGHT_FOUR) - .lineHeight($r('app.float.title_line_height')) - .margin({ - top: $r('app.float.title_margin_top'), - bottom: $r('app.float.title_margin_bottom') - }) - Divider() - .strokeWidth(CommonConstants.STROKE_WIDTH) - .width($r('app.float.divider_width')) - .color($r('app.color.active_font_color')) - .opacity(this.currentIndex === index ? CommonConstants.FULL_OPACITY : CommonConstants.ZERO_OPACITY) } + .borderRadius($r('app.float.button_border_radius')) + .justifyContent(FlexAlign.Center) + .height($r('app.float.button_height')) + .width($r('app.float.button_width')) + .backgroundColor(this.currentIndex === index ? $r('sys.color.brand') : $r('sys.color.comp_background_tertiary')) } @Builder listBuilder(listName: ResourceStr, tabName: ResourceStr, index: number) { TabContent() { - List({ space: CommonConstants.LIST_SPACE, scroller: this.scrollerForList }) { - ForEach(listArr, (item: string) => { + List({ scroller: this.scrollerForList }) { + ForEach(listArr, (item: string, index: number) => { ListItem() { Row() { Text(listName) .fontSize($r('app.float.middle_font_size')) + .fontColor($r('sys.color.font_primary')) .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) Text(item) .fontSize($r('app.float.middle_font_size')) .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) + .fontColor($r('sys.color.font_primary')) } - .padding({ left: $r('app.float.list_item_padding') }) - .backgroundColor(Color.White) + .justifyContent(FlexAlign.Center) + .borderColor($r('sys.color.comp_divider')) + .borderWidth({ bottom: 0.5 }) + .backgroundColor($r('sys.color.comp_background_primary')) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) - .borderRadius($r('app.float.list_item_radius')) - } + .borderRadius({ + bottomLeft: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : + ((index === listArr.length - 2) ? $r('app.float.list_item_radius') : 0), + bottomRight: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : + ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) + }) + .backgroundColor($r('sys.color.comp_background_primary')) + .padding({ left: $r('app.float.list_item_padding'), right: $r('app.float.list_item_padding') }) .width(CommonConstants.FULL_WIDTH) .height($r('app.float.list_item_height')) }, (item: string) => JSON.stringify(item)) } - .padding({ - left: $r('app.float.list_padding'), - right: $r('app.float.list_padding') - }) + .borderRadius($r('app.float.list_item_radius')) + .lanes(new BreakpointType(1, 2, 2).getValue(this.curBp)) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) .edgeEffect(EdgeEffect.None) @@ -92,41 +98,42 @@ struct NestedCeiling { .height($r('app.float.list_item_height')) .textAlign(TextAlign.Start) .width(CommonConstants.FULL_WIDTH) - .padding({ - left: $r('app.float.discover_left_padding'), + .fontColor($r('sys.color.font_primary')) + .margin({ bottom: $r('app.float.discover_bottom_padding'), - top: $r('app.float.discover_top_padding') + top: $r('sys.float.padding_level32') }) - Stack({ alignContent: Alignment.Top }) { - Scroll(this.scrollerForScroll) { - Column() { - Image($r("app.media.banner")) - .width(CommonConstants.FULL_WIDTH) - .height($r('app.float.image_height')) - .borderRadius($r('app.float.list_item_radius')) - .padding({ - left: $r('app.float.list_item_padding'), - right: $r('app.float.list_item_padding') - }) - Tabs() { - this.listBuilder($r('app.string.goods'), $r('app.string.Promotional'), 0) - this.listBuilder($r('app.string.Itinerary'), $r('app.string.Travel'), 1) - } - .barWidth($r('app.float.bar_width')) - .onAnimationStart((_index: number, targetIndex: number, _event: TabsAnimationEvent) => { - this.currentIndex = targetIndex; - }) + Scroll(this.scrollerForScroll) { + Column() { + Image($r("app.media.banner")) + .width(CommonConstants.FULL_WIDTH) + .height($r('app.float.image_height')) + .borderRadius($r('app.float.list_item_radius')) + Tabs() { + this.listBuilder($r('app.string.goods'), $r('app.string.Promotional'), 0) + this.listBuilder($r('app.string.Itinerary'), $r('app.string.Travel'), 1) } + .barWidth(new BreakpointType($r('app.float.bar_width_sm'), $r('app.float.bar_width_md'), + $r('app.float.bar_width_lg')).getValue(this.curBp)) + .onAnimationStart((_index: number, targetIndex: number, _event: TabsAnimationEvent) => { + this.currentIndex = targetIndex; + }) } - .scrollBar(BarState.Off) - .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.FULL_HEIGHT) } + .height(new BreakpointType('210%', '120%', '120%').getValue(this.curBp)) + .scrollBar(BarState.Off) .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.STACK_HEIGHT) } + .padding({ + left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.curBp), + right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.curBp), + top: px2vp(this.topRectHeight) + }) + .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.FULL_HEIGHT) - .backgroundColor($r('app.color.start_window_background')) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/InitData.ets b/entry/src/main/ets/viewmodel/InitData.ets index fc218ea..cf04449 100644 --- a/entry/src/main/ets/viewmodel/InitData.ets +++ b/entry/src/main/ets/viewmodel/InitData.ets @@ -16,4 +16,6 @@ /** * List data */ -export const listArr: string[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']; \ No newline at end of file +export const listArr: string[] = + ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', + '22', '23', '24']; \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index 3fec972..a953cfa 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -2,11 +2,23 @@ "float": [ { "name": "middle_font_size", - "value": "16fp" + "value": "14fp" + }, + { + "name": "button_border_radius", + "value": "21fp" + }, + { + "name": "button_height", + "value": "36fp" + }, + { + "name": "button_width", + "value": "84fp" }, { "name": "title_line_height", - "value": "22vp" + "value": "36vp" }, { "name": "title_margin_top", @@ -22,7 +34,7 @@ }, { "name": "list_item_radius", - "value": "24vp" + "value": "16vp" }, { "name": "list_item_padding", @@ -61,8 +73,16 @@ "value": "188vp" }, { - "name": "bar_width", + "name": "bar_width_sm", "value": "290vp" + }, + { + "name": "bar_width_md", + "value": "500vp" + }, + { + "name": "bar_width_lg", + "value": "700vp" } ] } \ No newline at end of file -- Gitee From 538c31fab6abe4eb158ccc20b3eb51ccac5a3e98 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Tue, 4 Mar 2025 17:04:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?HMOSWorld=E6=95=B4=E6=94=B9=20(1)UX?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E9=80=82=E9=85=8D;=20(2)=E6=B7=B1=E6=B5=85?= =?UTF-8?q?=E8=89=B2=E9=80=82=E9=85=8D;=20(3)=E6=B2=89=E6=B5=B8=E5=BC=8F?= =?UTF-8?q?=E9=80=82=E9=85=8D;=20(4)=E4=B8=80=E5=A4=9A=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=95=B4=E6=94=B9;=20(5)=E5=9B=BE=E6=A0=87/=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2;=20(6)=E5=9B=BD=E9=99=85=E5=8C=96=E6=95=B4?= =?UTF-8?q?=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 121 ++++++++++-------- .../main/resources/base/element/string.json | 2 +- .../main/resources/en_US/element/string.json | 2 +- .../main/resources/zh_CN/element/string.json | 2 +- 4 files changed, 73 insertions(+), 54 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index fd7a90a..9bb4f85 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -16,17 +16,43 @@ import { listArr } from '../viewmodel/InitData'; import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType } from '../common/utils/Utils'; +import { + ItemRestriction, + SegmentButton, + SegmentButtonOptions, + SegmentButtonTextItem +} from '@ohos.arkui.advanced.SegmentButton'; @Entry @Component struct NestedCeiling { + @State @Watch('onSegmentButtonChange') tabSelectedIndexes: number[] = [0]; @State currentIndex: number = 0; + @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.tab({ + buttons: [{ text: '促销活动' }, { text: '行程服务' }] as ItemRestriction, + fontSize: $r('sys.float.Body_M'), + selectedFontSize: $r('sys.float.Body_M'), + fontColor: $r('sys.color.font_secondary'), + selectedFontColor: $r('sys.color.font_primary'), + backgroundColor: $r('sys.color.comp_background_tertiary'), + selectedBackgroundColor: $r('sys.color.ohos_id_color_foreground_contrary_disable'), + textPadding: { + top: 8, + bottom: 8, + right: 16, + left: 16 + }, + }) @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; @StorageProp('topRectHeight') topRectHeight: number = 0; private scrollerForScroll: Scroller = new Scroller(); private scrollerForList: Scroller = new Scroller(); + onSegmentButtonChange() { + this.currentIndex = this.tabSelectedIndexes[0]; + } + @Builder tabBuilder(index: number, name: ResourceStr) { Column() { @@ -43,51 +69,48 @@ struct NestedCeiling { @Builder listBuilder(listName: ResourceStr, tabName: ResourceStr, index: number) { - TabContent() { - List({ scroller: this.scrollerForList }) { - ForEach(listArr, (item: string, index: number) => { - ListItem() { - Row() { - Text(listName) - .fontSize($r('app.float.middle_font_size')) - .fontColor($r('sys.color.font_primary')) - .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) - Text(item) - .fontSize($r('app.float.middle_font_size')) - .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) - .fontColor($r('sys.color.font_primary')) - } - .justifyContent(FlexAlign.Center) - .borderColor($r('sys.color.comp_divider')) - .borderWidth({ bottom: 0.5 }) - .backgroundColor($r('sys.color.comp_background_primary')) - .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.FULL_HEIGHT) + List({ scroller: this.scrollerForList }) { + ForEach(listArr, (item: string, index: number) => { + ListItem() { + Row() { + Text(listName) + .fontSize($r('app.float.middle_font_size')) + .fontColor($r('sys.color.font_primary')) + .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) + Text(item) + .fontSize($r('app.float.middle_font_size')) + .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) + .fontColor($r('sys.color.font_primary')) } - .borderRadius({ - bottomLeft: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : - ((index === listArr.length - 2) ? $r('app.float.list_item_radius') : 0), - bottomRight: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : - ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) - }) + .justifyContent(FlexAlign.Center) + .borderColor($r('sys.color.comp_divider')) + .borderWidth({ bottom: 0.5 }) .backgroundColor($r('sys.color.comp_background_primary')) - .padding({ left: $r('app.float.list_item_padding'), right: $r('app.float.list_item_padding') }) .width(CommonConstants.FULL_WIDTH) - .height($r('app.float.list_item_height')) - }, (item: string) => JSON.stringify(item)) - } - .borderRadius($r('app.float.list_item_radius')) - .lanes(new BreakpointType(1, 2, 2).getValue(this.curBp)) - .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.FULL_HEIGHT) - .edgeEffect(EdgeEffect.None) - .scrollBar(BarState.Off) - .nestedScroll({ - scrollForward: NestedScrollMode.PARENT_FIRST, - scrollBackward: NestedScrollMode.SELF_FIRST - }) + .height(CommonConstants.FULL_HEIGHT) + } + .borderRadius({ + bottomLeft: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : + ((index === listArr.length - 2) ? $r('app.float.list_item_radius') : 0), + bottomRight: this.curBp === 'sm' ? ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) : + ((index === listArr.length - 1) ? $r('app.float.list_item_radius') : 0) + }) + .backgroundColor($r('sys.color.comp_background_primary')) + .padding({ left: $r('app.float.list_item_padding'), right: $r('app.float.list_item_padding') }) + .width(CommonConstants.FULL_WIDTH) + .height($r('app.float.list_item_height')) + }, (item: string) => JSON.stringify(item)) } - .tabBar(this.tabBuilder(index, tabName)) + .borderRadius($r('app.float.list_item_radius')) + .lanes(new BreakpointType(1, 2, 2).getValue(this.curBp)) + .width(CommonConstants.FULL_WIDTH) + .height(CommonConstants.FULL_HEIGHT) + .edgeEffect(EdgeEffect.None) + .scrollBar(BarState.Off) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.SELF_FIRST + }) } build() { @@ -104,21 +127,17 @@ struct NestedCeiling { top: $r('sys.float.padding_level32') }) + Scroll(this.scrollerForScroll) { Column() { - Image($r("app.media.banner")) - .width(CommonConstants.FULL_WIDTH) - .height($r('app.float.image_height')) - .borderRadius($r('app.float.list_item_radius')) - Tabs() { + SegmentButton({ options: this.tabOptions, selectedIndexes: this.tabSelectedIndexes }) + .width(this.curBp === 'sm' ? '100%' : 448) + .margin({bottom:$r('sys.float.padding_level6')}) + if (this.currentIndex === 0) { this.listBuilder($r('app.string.goods'), $r('app.string.Promotional'), 0) + } else { this.listBuilder($r('app.string.Itinerary'), $r('app.string.Travel'), 1) } - .barWidth(new BreakpointType($r('app.float.bar_width_sm'), $r('app.float.bar_width_md'), - $r('app.float.bar_width_lg')).getValue(this.curBp)) - .onAnimationStart((_index: number, targetIndex: number, _event: TabsAnimationEvent) => { - this.currentIndex = targetIndex; - }) } } .height(new BreakpointType('210%', '120%', '120%').getValue(this.curBp)) diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index cc16f2f..e64f625 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -14,7 +14,7 @@ }, { "name": "title", - "value": "发现" + "value": "Scroll组件嵌套滑动" }, { "name": "Promotional", diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index a63e5ac..cf462b7 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -14,7 +14,7 @@ }, { "name": "title", - "value": "Discover" + "value": "Nested scrolling of the Scroll component" }, { "name": "Promotional", diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index cc16f2f..e64f625 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -14,7 +14,7 @@ }, { "name": "title", - "value": "发现" + "value": "Scroll组件嵌套滑动" }, { "name": "Promotional", -- Gitee From 2db3ce3055714aa5231388c622764ef2c151e8a4 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Sat, 8 Mar 2025 17:58:58 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B7=B7=E6=B7=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/obfuscation-rules.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt index 985b2ae..a1dfa0b 100644 --- a/entry/obfuscation-rules.txt +++ b/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # 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 \ No newline at end of file +# -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 -- Gitee From dfcee81f492ef24542a952693b77ef036a8c77b1 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Thu, 13 Mar 2025 22:03:34 +0800 Subject: [PATCH 4/4] DTS2025031327502 --- entry/src/main/ets/pages/Index.ets | 5 +++-- entry/src/main/resources/base/element/float.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 9bb4f85..bd5e7af 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -29,7 +29,8 @@ struct NestedCeiling { @State @Watch('onSegmentButtonChange') tabSelectedIndexes: number[] = [0]; @State currentIndex: number = 0; @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.tab({ - buttons: [{ text: '促销活动' }, { text: '行程服务' }] as ItemRestriction, + buttons: [{ text: $r('app.string.Promotional') }, + { text: $r('app.string.Travel') }] as ItemRestriction, fontSize: $r('sys.float.Body_M'), selectedFontSize: $r('sys.float.Body_M'), fontColor: $r('sys.color.font_secondary'), @@ -132,7 +133,7 @@ struct NestedCeiling { Column() { SegmentButton({ options: this.tabOptions, selectedIndexes: this.tabSelectedIndexes }) .width(this.curBp === 'sm' ? '100%' : 448) - .margin({bottom:$r('sys.float.padding_level6')}) + .margin({ bottom: $r('sys.float.padding_level6') }) if (this.currentIndex === 0) { this.listBuilder($r('app.string.goods'), $r('app.string.Promotional'), 0) } else { diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index a953cfa..eb404fe 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -62,7 +62,7 @@ }, { "name": "discover_bottom_padding", - "value": "8vp" + "value": "16vp" }, { "name": "image_width", -- Gitee