From 80dc92b3aac1847063677aabd1363da53d666a8a Mon Sep 17 00:00:00 2001 From: caoliwen1 <14658249+caoliwen1@user.noreply.gitee.com> Date: Thu, 5 Sep 2024 17:19:02 +0800 Subject: [PATCH] =?UTF-8?q?ScrollComponentNestedSliding=E6=B8=AF=E6=BE=B3?= =?UTF-8?q?=E5=8F=B0=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 32 +++++++++++-------- entry/src/main/ets/viewmodel/InitData.ets | 2 +- .../main/resources/base/element/string.json | 16 ++++++++++ .../main/resources/en_US/element/string.json | 18 ++++++++++- .../main/resources/zh_CN/element/string.json | 16 ++++++++++ 5 files changed, 69 insertions(+), 15 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6ae9648..52e66a5 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -24,7 +24,7 @@ struct NestedCeiling { private scrollerForList: Scroller = new Scroller(); @Builder - tabBuilder(index: number, name: string) { + tabBuilder(index: number, name: ResourceStr) { Column() { Text(name) .fontColor(this.currentIndex === index ? $r('app.color.active_font_color') : $r('app.color.font_color')) @@ -44,19 +44,25 @@ struct NestedCeiling { } @Builder - listBuilder(listName: string, tabName: string, index: number) { + listBuilder(listName: ResourceStr, tabName: ResourceStr, index: number) { TabContent() { List({ space: CommonConstants.LIST_SPACE, scroller: this.scrollerForList }) { - ForEach(listArr, (item: number) => { + ForEach(listArr, (item: string) => { ListItem() { - Text(listName + item) - .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.FULL_HEIGHT) - .borderRadius($r('app.float.list_item_radius')) - .fontSize($r('app.float.middle_font_size')) - .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) - .padding({ left: $r('app.float.list_item_padding') }) - .backgroundColor(Color.White) + Row() { + Text(listName) + .fontSize($r('app.float.middle_font_size')) + .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) + Text(item) + .fontSize($r('app.float.middle_font_size')) + .fontWeight(CommonConstants.FONT_WEIGHT_FIVE) + } + .padding({ left: $r('app.float.list_item_padding') }) + .backgroundColor(Color.White) + .width(CommonConstants.FULL_WIDTH) + .height(CommonConstants.FULL_HEIGHT) + .borderRadius($r('app.float.list_item_radius')) + } .width(CommonConstants.FULL_WIDTH) .height($r('app.float.list_item_height')) @@ -104,8 +110,8 @@ struct NestedCeiling { right: $r('app.float.list_item_padding') }) Tabs() { - this.listBuilder(CommonConstants.LIST_NAME_1, CommonConstants.TAB_NAME_1, 0) - this.listBuilder(CommonConstants.LIST_NAME_2, CommonConstants.TAB_NAME_2, 1) + 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')) .onChange((index: number) => { diff --git a/entry/src/main/ets/viewmodel/InitData.ets b/entry/src/main/ets/viewmodel/InitData.ets index add6701..fc218ea 100644 --- a/entry/src/main/ets/viewmodel/InitData.ets +++ b/entry/src/main/ets/viewmodel/InitData.ets @@ -16,4 +16,4 @@ /** * List data */ -export const listArr: number[] = [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']; \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index cd0ced3..cc16f2f 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -15,6 +15,22 @@ { "name": "title", "value": "发现" + }, + { + "name": "Promotional", + "value": "促销活动" + }, + { + "name": "Travel", + "value": "行程服务" + }, + { + "name": "goods", + "value": "促销商品" + }, + { + "name": "Itinerary", + "value": "行程安排" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 5371756..a63e5ac 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -14,7 +14,23 @@ }, { "name": "title", - "value": "discover" + "value": "Discover" + }, + { + "name": "Promotional", + "value": "Promotion activity" + }, + { + "name": "Travel", + "value": "Travel service" + }, + { + "name": "goods", + "value": "Promotion goods" + }, + { + "name": "Itinerary", + "value": "Itinerary arrangement" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index cd0ced3..cc16f2f 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -15,6 +15,22 @@ { "name": "title", "value": "发现" + }, + { + "name": "Promotional", + "value": "促销活动" + }, + { + "name": "Travel", + "value": "行程服务" + }, + { + "name": "goods", + "value": "促销商品" + }, + { + "name": "Itinerary", + "value": "行程安排" } ] } \ No newline at end of file -- Gitee