Showing
3 changed files
with
42 additions
and
45 deletions
| @@ -34,8 +34,7 @@ export struct TopNavigationComponentNew { | @@ -34,8 +34,7 @@ export struct TopNavigationComponentNew { | ||
| 34 | */ | 34 | */ |
| 35 | navItem: BottomNavDTO = {} as BottomNavDTO | 35 | navItem: BottomNavDTO = {} as BottomNavDTO |
| 36 | // 首页当前正在哪个tab的索引值 | 36 | // 首页当前正在哪个tab的索引值 |
| 37 | - @Link @Watch('setBarBackgroundColor') _currentNavIndex?: number; | ||
| 38 | - | 37 | + @Link @Watch('setBarBackgroundColor') _currentNavIndex?: number; |
| 39 | @Consume @Watch('pageShowChange') pageShow: number | 38 | @Consume @Watch('pageShowChange') pageShow: number |
| 40 | // 记录首页底部tab 的索引值 | 39 | // 记录首页底部tab 的索引值 |
| 41 | @State bottomNavIndex: number = 0 | 40 | @State bottomNavIndex: number = 0 |
| @@ -43,7 +42,6 @@ export struct TopNavigationComponentNew { | @@ -43,7 +42,6 @@ export struct TopNavigationComponentNew { | ||
| 43 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; | 42 | @State @Watch('updateCurrentTopNavSelectedIndex') currentTopNavSelectedIndex: number = 0; |
| 44 | // 顶导数据 | 43 | // 顶导数据 |
| 45 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 44 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 46 | - | ||
| 47 | @Consume barBackgroundColor: Color | 45 | @Consume barBackgroundColor: Color |
| 48 | @Consume isImmersive: boolean | 46 | @Consume isImmersive: boolean |
| 49 | // | 47 | // |
| @@ -329,36 +327,32 @@ export struct TopNavigationComponentNew { | @@ -329,36 +327,32 @@ export struct TopNavigationComponentNew { | ||
| 329 | @Builder | 327 | @Builder |
| 330 | tabBarBuilder(item: TopNavDTO, index: number) { | 328 | tabBarBuilder(item: TopNavDTO, index: number) { |
| 331 | Column() { | 329 | Column() { |
| 332 | - Text(item?.name) | ||
| 333 | - .fontSize($r('app.float.selected_text_size')) | ||
| 334 | - .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | ||
| 335 | - .fontColor(this.tabSelectedColor(this.currentTopNavSelectedIndex === index)) | ||
| 336 | - .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) | ||
| 337 | - .maxLines(this.MAX_LINE) | ||
| 338 | - .id(index.toString()) | ||
| 339 | - // .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 340 | - // if (this.currentTopNavSelectedIndex === index && | ||
| 341 | - // (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)) { | ||
| 342 | - // if (newValue.position.x != undefined) { | ||
| 343 | - // let positionX = Number.parseFloat(newValue.position.x.toString()) | ||
| 344 | - // this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX | ||
| 345 | - // } | ||
| 346 | - // let width = Number.parseFloat(newValue.width.toString()) | ||
| 347 | - // this.indicatorWidth = Number.isNaN(width) ? 0 : width | ||
| 348 | - // } | ||
| 349 | - // }) | ||
| 350 | - if (this.currentTopNavSelectedIndex === index) { | ||
| 351 | 330 | ||
| 352 | - Image($r('app.media.icon_channel_active')) | ||
| 353 | - .colorFilter(ColorUtils.getDrawingColorFilter(this.getBothColor(""))) | ||
| 354 | - .width(20) | ||
| 355 | - .height(3) | ||
| 356 | - // Row() | ||
| 357 | - // .width(20) | ||
| 358 | - // .height(3) | ||
| 359 | - // .backgroundImage($r('app.media.icon_channel_active'), ImageRepeat.NoRepeat) | ||
| 360 | - // .backgroundImageSize(ImageSize.Contain) | 331 | + if (item.iconUrl && item.iconCUrl) { |
| 332 | + // 有图 | ||
| 333 | + Image(this.currentTopNavSelectedIndex === index ? item.iconUrl : item.iconCUrl) | ||
| 334 | + .height(36) | ||
| 335 | + } else { | ||
| 336 | + // 无图 | ||
| 337 | + Text(item?.name) | ||
| 338 | + .fontSize($r('app.float.selected_text_size')) | ||
| 339 | + .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | ||
| 340 | + .fontColor(this.tabSelectedColor(this.currentTopNavSelectedIndex === index)) | ||
| 341 | + .padding({ | ||
| 342 | + top: $r('app.float.top_tab_item_padding_top'), | ||
| 343 | + bottom: $r('app.float.top_tab_item_padding_bottom') | ||
| 344 | + }) | ||
| 345 | + .maxLines(this.MAX_LINE) | ||
| 346 | + .id(index.toString()) | ||
| 347 | + if (this.currentTopNavSelectedIndex === index) { | ||
| 348 | + Image($r('app.media.icon_channel_active'))//.colorFilter(ColorUtils.getDrawingColorFilter(this.getBothColor(""))) | ||
| 349 | + .width(20) | ||
| 350 | + .height(3) | ||
| 351 | + | ||
| 352 | + } | ||
| 361 | } | 353 | } |
| 354 | + | ||
| 355 | + | ||
| 362 | } | 356 | } |
| 363 | .hoverEffect(HoverEffect.Highlight) | 357 | .hoverEffect(HoverEffect.Highlight) |
| 364 | .constraintSize({ | 358 | .constraintSize({ |
| @@ -482,24 +476,22 @@ export struct TopNavigationComponentNew { | @@ -482,24 +476,22 @@ export struct TopNavigationComponentNew { | ||
| 482 | this.backgroundImageH = px2vp(this.topRectHeight) + 44 | 476 | this.backgroundImageH = px2vp(this.topRectHeight) + 44 |
| 483 | } | 477 | } |
| 484 | 478 | ||
| 485 | - ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor) | 479 | + ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor, 1) |
| 486 | 480 | ||
| 487 | } | 481 | } |
| 488 | 482 | ||
| 489 | pageShowChange() { | 483 | pageShowChange() { |
| 490 | - ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor) | 484 | + ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor, 1) |
| 491 | } | 485 | } |
| 492 | 486 | ||
| 493 | - | ||
| 494 | - | ||
| 495 | /** | 487 | /** |
| 496 | * 修改手机顶部状态栏颜色 | 488 | * 修改手机顶部状态栏颜色 |
| 497 | */ | 489 | */ |
| 498 | setBarBackgroundColor() { | 490 | setBarBackgroundColor() { |
| 499 | 491 | ||
| 500 | 492 | ||
| 501 | - if(this._currentNavIndex == this.bottomNavIndex){ | ||
| 502 | - ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor) | 493 | + if (this._currentNavIndex == this.bottomNavIndex) { |
| 494 | + ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor, 1) | ||
| 503 | 495 | ||
| 504 | this.isImmersive = false | 496 | this.isImmersive = false |
| 505 | this.barBackgroundColor = Color.White | 497 | this.barBackgroundColor = Color.White |
| @@ -646,7 +638,6 @@ export struct TopNavigationComponentNew { | @@ -646,7 +638,6 @@ export struct TopNavigationComponentNew { | ||
| 646 | return null | 638 | return null |
| 647 | } | 639 | } |
| 648 | 640 | ||
| 649 | - | ||
| 650 | /** | 641 | /** |
| 651 | * 进入早晚报专题 | 642 | * 进入早晚报专题 |
| 652 | */ | 643 | */ |
| @@ -242,7 +242,7 @@ export class ColorUtils { | @@ -242,7 +242,7 @@ export class ColorUtils { | ||
| 242 | /** | 242 | /** |
| 243 | * 获取图片填充的ColorFilter | 243 | * 获取图片填充的ColorFilter |
| 244 | * @param hex 十六进制颜色值 | 244 | * @param hex 十六进制颜色值 |
| 245 | - * @returns undefined:无填充颜色 | 245 | + * @returns undefined:无填充颜色 |
| 246 | */ | 246 | */ |
| 247 | public static getDrawingColorFilter(hex: string): ColorFilter | undefined { | 247 | public static getDrawingColorFilter(hex: string): ColorFilter | undefined { |
| 248 | 248 | ||
| @@ -270,10 +270,16 @@ export class ColorUtils { | @@ -270,10 +270,16 @@ export class ColorUtils { | ||
| 270 | 270 | ||
| 271 | /** | 271 | /** |
| 272 | * 修改手机顶部状态栏颜色 | 272 | * 修改手机顶部状态栏颜色 |
| 273 | - * @param statusValue | 273 | + * @param statusValue 动态修改值 |
| 274 | + * @param defaultValue 页面默认值:statusValue== null 就按此值走 | ||
| 274 | */ | 275 | */ |
| 275 | - public static changeTopStatusBarColor(statusValue: number) { | ||
| 276 | - if (statusValue === 1) { // 黑色状态栏 | 276 | + public static changeTopStatusBarColor(statusValue: number, defaultValue: number) { |
| 277 | + if (statusValue == null) { | ||
| 278 | + statusValue = defaultValue | ||
| 279 | + } else { //白色状态栏 | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + if (statusValue === 1 || statusValue == null) { // 黑色状态栏 | ||
| 277 | WindowModel.shared.setWindowSystemBarProperties({ | 283 | WindowModel.shared.setWindowSystemBarProperties({ |
| 278 | statusBarContentColor: '#000000', | 284 | statusBarContentColor: '#000000', |
| 279 | 285 |
| @@ -57,11 +57,11 @@ export struct VideoChannelPage { | @@ -57,11 +57,11 @@ export struct VideoChannelPage { | ||
| 57 | if (this.isImmerseChannel() && CompUtils.isVideo(this.currentBottomNavInfo)) { | 57 | if (this.isImmerseChannel() && CompUtils.isVideo(this.currentBottomNavInfo)) { |
| 58 | this.barBackgroundColor = Color.Black | 58 | this.barBackgroundColor = Color.Black |
| 59 | this.isImmersive = true | 59 | this.isImmersive = true |
| 60 | - ColorUtils.changeTopStatusBarColor(0)// 沉浸页面顶部导航栏颜色固定黑色 | 60 | + ColorUtils.changeTopStatusBarColor(0,0)// 沉浸页面顶部导航栏颜色固定黑色 |
| 61 | } else { | 61 | } else { |
| 62 | this.isImmersive = false | 62 | this.isImmersive = false |
| 63 | this.barBackgroundColor = Color.White | 63 | this.barBackgroundColor = Color.White |
| 64 | - ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor) | 64 | + ColorUtils.changeTopStatusBarColor(this.navItem.statusBarColor,1) |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | } | 67 | } |
| @@ -127,7 +127,7 @@ export struct VideoChannelPage { | @@ -127,7 +127,7 @@ export struct VideoChannelPage { | ||
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | Image($r('app.media.icon_channel_active')) | 129 | Image($r('app.media.icon_channel_active')) |
| 130 | - .colorFilter(ColorUtils.getDrawingColorFilter(this.getBothColor(""))) | 130 | + // .colorFilter(ColorUtils.getDrawingColorFilter(this.getBothColor(""))) |
| 131 | .width(20) | 131 | .width(20) |
| 132 | .height(3).visibility(this.currentTopNavSelectedIndex === index ? Visibility.Visible : Visibility.Hidden) | 132 | .height(3).visibility(this.currentTopNavSelectedIndex === index ? Visibility.Visible : Visibility.Hidden) |
| 133 | 133 |
-
Please register or login to post a comment