diff --git a/scenario/arkui/MyNews/README.md b/scenario/arkui/MyNews/README.md index ddbb0c6cc2e281b0a37a3eac64eaaf302677273e..ebe78aebdcbe120576c305434a03207aa6f14721 100644 --- a/scenario/arkui/MyNews/README.md +++ b/scenario/arkui/MyNews/README.md @@ -38,3 +38,6 @@ RecommendedUserList.ets RecommendedVideoList.ets ``` + +## TODO + diff --git a/scenario/arkui/MyNews/entry/src/main/ets/pages/Index.ets b/scenario/arkui/MyNews/entry/src/main/ets/pages/Index.ets index 17aff0a74ec36a58b6457a4cfde9dde4b1d125a9..a75987dd7ebc9c3d0cb4a3fcbd2f53e4cffc40ea 100644 --- a/scenario/arkui/MyNews/entry/src/main/ets/pages/Index.ets +++ b/scenario/arkui/MyNews/entry/src/main/ets/pages/Index.ets @@ -51,12 +51,14 @@ const bottomNavItemList: IndexBottomNavItem[] = [{ title: '任务', normalIcon: $r('app.media.ic_public_calendar'), selectedIcon: $r('app.media.ic_public_calendar_filled'), - btnId: 'indexTaskPageBtn' + btnId: 'indexTaskPageBtn', + label: '开宝箱' }, { title: '商城', normalIcon: $r('app.media.ic_public_appstore'), selectedIcon: $r('app.media.ic_public_appstore_filled'), - btnId: 'indexMallPageBtn' + btnId: 'indexMallPageBtn', + label: '' }, { title: '个人', normalIcon: $r('app.media.ic_public_contacts'), @@ -103,7 +105,7 @@ struct Index { .width('100%') .height('100%') .align(Alignment.Top) - .tabBar(this.TabBuilder(item.title, itemIndex, item.normalIcon, item.selectedIcon, item.btnId)) + .tabBar(this.TabBuilder(item.title, itemIndex, item.normalIcon, item.selectedIcon, item.btnId, item.label)) }) } .width('100%') @@ -118,20 +120,32 @@ struct Index { * 底部导航栏中自定义按钮样式(图标+文字) */ @Builder - TabBuilder(title: string, targetIndex: number, normalIcon: Resource, selectedIcon: Resource, btnId: string) { + TabBuilder(title: string, targetIndex: number, normalIcon: Resource, selectedIcon: Resource, btnId: string, label: string) { Button() { - Column() { - // 当被选中时变色,图标变为填充型 - Image(this.curNavIdx === targetIndex ? selectedIcon : normalIcon) - .size({ width: 20, height: 20 }) - .fillColor(this.curNavIdx === targetIndex ? $r('app.color.primary') : $r('app.color.light_fg')) - Text(title) - .fontSize(8) - .fontColor(this.curNavIdx === targetIndex ? $r('app.color.primary') : $r('app.color.light_fg')) + Stack({alignContent: Alignment.TopEnd}) { + Column() { + // 当被选中时变色,图标变为填充型 + Image(this.curNavIdx === targetIndex ? selectedIcon : normalIcon) + .size({ width: 20, height: 20 }) + .fillColor(this.curNavIdx === targetIndex ? $r('app.color.primary') : $r('app.color.light_fg')) + Text(title) + .fontSize(8) + .fontColor(this.curNavIdx === targetIndex ? $r('app.color.primary') : $r('app.color.light_fg')) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + if(label) { + Text(label) + .borderRadius(999) + .backgroundColor('red') + .fontColor('white') + .fontSize(8) + .padding(2) + .margin({top: 2}) + } + } - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Center) } .id(btnId) .commonBtnStyle(() => { diff --git a/scenario/arkui/MyNews/entry/src/main/ets/viewmodel/IndexBottomNavItem.ets b/scenario/arkui/MyNews/entry/src/main/ets/viewmodel/IndexBottomNavItem.ets index 4f1388ff545ccff8a7b69384f937454ffb6a5621..908504ec8fa3cdb8437c6666e955e83cb0e565a3 100644 --- a/scenario/arkui/MyNews/entry/src/main/ets/viewmodel/IndexBottomNavItem.ets +++ b/scenario/arkui/MyNews/entry/src/main/ets/viewmodel/IndexBottomNavItem.ets @@ -25,5 +25,7 @@ export interface IndexBottomNavItem { /* 被选中时替换为填充型图标 */ selectedIcon: Resource /* 对应的按钮id(测试用例中使用) */ - btnId: string + btnId: string, + /* 右上角标签 */ + label?: string }