zhangbo1_wd

解决【18014 UI还原问题-【uat】底部导航-选中视频频道后,图标变成白色。看图】

@@ -131,7 +131,7 @@ export struct BottomNavigationComponent { @@ -131,7 +131,7 @@ export struct BottomNavigationComponent {
131 @Builder 131 @Builder
132 tabBarBuilder(navItem: BottomNavDTO, index: number) { 132 tabBarBuilder(navItem: BottomNavDTO, index: number) {
133 Stack({ alignContent: Alignment.Bottom }) { 133 Stack({ alignContent: Alignment.Bottom }) {
134 - Image(this.currentNavIndex === index ? navItem.iconC : navItem.icon) 134 + Image(this.getBottomIcon(navItem, this.currentNavIndex === index))
135 .height(CommonConstants.FULL_PARENT) 135 .height(CommonConstants.FULL_PARENT)
136 .padding({ 136 .padding({
137 bottom: 15, 137 bottom: 15,
@@ -140,6 +140,7 @@ export struct BottomNavigationComponent { @@ -140,6 +140,7 @@ export struct BottomNavigationComponent {
140 top: 2 140 top: 2
141 }) 141 })
142 .aspectRatio(this.ASPECT_RATIO_1_1) 142 .aspectRatio(this.ASPECT_RATIO_1_1)
  143 + .alt(this.getBottomLocalIcon(navItem, this.currentNavIndex === index))
143 144
144 Text(navItem.name) 145 Text(navItem.name)
145 .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) 146 .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') })
@@ -160,6 +161,48 @@ export struct BottomNavigationComponent { @@ -160,6 +161,48 @@ export struct BottomNavigationComponent {
160 161
161 } 162 }
162 163
  164 + private getBottomIcon(navItem: BottomNavDTO, isSelect: boolean): string | Resource {
  165 + if (!navItem) {
  166 + return ''
  167 + }
  168 + let icon: string = ''
  169 + if (this.isImmersive) {
  170 + // 获取沉浸式icon
  171 + icon = isSelect ? navItem.immersiveIconCUrl : navItem.immersiveIconUrl
  172 + } else {
  173 + // 获取常规icon
  174 + icon = isSelect ? navItem.iconC : navItem.icon
  175 + }
  176 + if (StringUtils.isEmpty(icon) || icon.includes('.pag')) {
  177 + // 兜底,获取预置的本地icon
  178 + return this.getBottomLocalIcon(navItem, isSelect)
  179 + }
  180 + return icon
  181 + }
  182 +
  183 + private getBottomLocalIcon(navItem: BottomNavDTO, isSelect: boolean): Resource {
  184 + if (!navItem) {
  185 + return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
  186 + }
  187 + // type:1普通 2我的
  188 + if (navItem.type == '2') {
  189 + // 我的
  190 + return isSelect ? $r('app.media.icon_tab_res5') : $r('app.media.icon_tab_res5_no')
  191 + } else {
  192 + // 顶部样式:中文的(11-新闻;12-人民号;13-视频;14-服务)
  193 + if (navItem.topStyle == '11') {
  194 + return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
  195 + } else if (navItem.topStyle == '12') {
  196 + return isSelect ? $r('app.media.icon_tab_res2') : $r('app.media.icon_tab_res2_no')
  197 + } else if (navItem.topStyle == '13') {
  198 + return isSelect ? $r('app.media.icon_tab_res3') : $r('app.media.icon_tab_res3_no')
  199 + } else if (navItem.topStyle == '14') {
  200 + return isSelect ? $r('app.media.icon_tab_res4') : $r('app.media.icon_tab_res4_no')
  201 + }
  202 + }
  203 + return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
  204 + }
  205 +
163 // 底导切换函数 206 // 底导切换函数
164 async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) { 207 async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) {
165 Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`); 208 Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`);
@@ -21,6 +21,7 @@ export struct VideoChannelPage { @@ -21,6 +21,7 @@ export struct VideoChannelPage {
21 @Prop topNavList: TopNavDTO[] 21 @Prop topNavList: TopNavDTO[]
22 @Link _currentNavIndex?: number; 22 @Link _currentNavIndex?: number;
23 @Consume barBackgroundColor: Color 23 @Consume barBackgroundColor: Color
  24 + @Consume isImmersive: boolean
24 @Consume displayDirection: DisplayDirection 25 @Consume displayDirection: DisplayDirection
25 @Consume @Watch('setBarBackgroundColor') currentBottomNavInfo: BottomNavDTO // 当前底导信息 26 @Consume @Watch('setBarBackgroundColor') currentBottomNavInfo: BottomNavDTO // 当前底导信息
26 @State @Watch('setBarBackgroundColor') currentTopNavSelectedIndex: number = 0; 27 @State @Watch('setBarBackgroundColor') currentTopNavSelectedIndex: number = 0;
@@ -42,8 +43,10 @@ export struct VideoChannelPage { @@ -42,8 +43,10 @@ export struct VideoChannelPage {
42 if (this.currentTopNavSelectedIndex === 0 && this.currentBottomNavInfo?.name === '视频') { 43 if (this.currentTopNavSelectedIndex === 0 && this.currentBottomNavInfo?.name === '视频') {
43 console.error('setBarBackgroundColor', '黑色') 44 console.error('setBarBackgroundColor', '黑色')
44 this.barBackgroundColor = Color.Black 45 this.barBackgroundColor = Color.Black
  46 + this.isImmersive = true
45 } else { 47 } else {
46 this.barBackgroundColor = Color.White 48 this.barBackgroundColor = Color.White
  49 + this.isImmersive = false
47 console.error('setBarBackgroundColor', '白色') 50 console.error('setBarBackgroundColor', '白色')
48 } 51 }
49 } 52 }