Showing
7 changed files
with
115 additions
and
100 deletions
| @@ -4,37 +4,39 @@ import { TopNavDTO } from './TopNavDTO'; | @@ -4,37 +4,39 @@ import { TopNavDTO } from './TopNavDTO'; | ||
| 4 | * 底导(包含顶导列表)数据 | 4 | * 底导(包含顶导列表)数据 |
| 5 | */ | 5 | */ |
| 6 | export interface BottomNavDTO { | 6 | export interface BottomNavDTO { |
| 7 | - backgroundUrl: string; | ||
| 8 | - channelChooseActionUrl: string; | ||
| 9 | - channelChooseCColor: string; | ||
| 10 | - channelChooseColor: string; | ||
| 11 | - channelMoreColor: string; | 7 | + backgroundUrl: string; // 迭代四:页面背景图 |
| 8 | + channelChooseActionUrl: string; // 迭代四:频道选中下划线动画 | ||
| 9 | + channelChooseCColor: string; // 迭代四:频道未选中颜色 | ||
| 10 | + channelChooseColor: string; // 迭代四:频道选中颜色 | ||
| 11 | + channelMoreColor: string; // 迭代四:更多频道颜色 | ||
| 12 | extraData: string; | 12 | extraData: string; |
| 13 | - homePageColor: string; | ||
| 14 | - icon: string; | ||
| 15 | - iconC: string; | 13 | + homePageColor: string; // 迭代四:主页图标/文字颜色 |
| 14 | + icon: string; // 未选中图标 | ||
| 15 | + iconC: string; // 选中图标 | ||
| 16 | id: number; | 16 | id: number; |
| 17 | - immersiveIconCUrl: string; | ||
| 18 | - immersiveIconUrl: string; | ||
| 19 | - immersiveNameCColor: string; | ||
| 20 | - immersiveNameColor: string; | ||
| 21 | - logoUrl: string; | 17 | + immersiveIconCUrl: string; // 迭代二新增-图标颜色-选中(沉浸式频道) |
| 18 | + immersiveIconUrl: string; // 迭代二新增-图标颜色-未选中(沉浸式频道) | ||
| 19 | + immersiveNameCColor: string; // 迭代二新增-文字颜色-选中(沉浸式频道) | ||
| 20 | + immersiveNameColor: string; // 迭代二新增-文字颜色-未选中(沉浸式频道) | ||
| 21 | + logoUrl: string; // 迭代四:logo图片 | ||
| 22 | morningAndEveningUrl: string; | 22 | morningAndEveningUrl: string; |
| 23 | name: string; | 23 | name: string; |
| 24 | - nameCColor: string; | ||
| 25 | - nameColor: string; | ||
| 26 | - nightIconCUrl: string; | ||
| 27 | - nightIconUrl: string; | ||
| 28 | - nightNameCColor: string; | ||
| 29 | - nightNameColor: string; | ||
| 30 | - noticeColor: string; | 24 | + nameCColor: string; // 名字选中颜色 |
| 25 | + nameColor: string; // 名字颜色 | ||
| 26 | + nightIconCUrl: string; // 迭代三新增-图标颜色-选中(夜间模式) | ||
| 27 | + nightIconUrl: string; // 迭代三新增-图标颜色-未选中(夜间模式) | ||
| 28 | + nightNameCColor: string; // 迭代三新增-文字颜色-选中(夜间模式) | ||
| 29 | + nightNameColor: string; // 迭代三新增-文字颜色-未选中(夜间模式) | ||
| 30 | + noticeColor: string; // 迭代四:消息通知提醒颜色 | ||
| 31 | pageId?: string; | 31 | pageId?: string; |
| 32 | pageType?: string; | 32 | pageType?: string; |
| 33 | - searchBothColor: string; | ||
| 34 | - searchUrl: string; | 33 | + searchBothColor: string; // 迭代四:两侧文字图标颜色,搜索图标颜色 |
| 34 | + searchUrl: string; // 迭代四:搜索背景框 | ||
| 35 | sortValue: number; | 35 | sortValue: number; |
| 36 | - statusBarColor: number; | 36 | + statusBarColor: number; // 迭代四:状态栏图标颜色,0:白色,1:黑色 |
| 37 | topNavChannelList: TopNavDTO[]; | 37 | topNavChannelList: TopNavDTO[]; |
| 38 | - topStyle: string; | ||
| 39 | - type: string; | 38 | + topStyle: string; // 顶部样式:中文的(11-新闻;12-人民号;13-视频;14-服务) |
| 39 | + type: string; // 底部导航类型,1普通 2我的;【rmrb需要扩展】 | ||
| 40 | + fmorningAndEveningUrl: string; // 迭代四:早晚报背景框 | ||
| 41 | + dropDownAnimationColor: string; // 下拉加载动画颜色,1白色,2灰色。未配置值是null | ||
| 40 | } | 42 | } |
| @@ -4,9 +4,10 @@ import { BottomNavDTO } from './BottomNavDTO'; | @@ -4,9 +4,10 @@ import { BottomNavDTO } from './BottomNavDTO'; | ||
| 4 | * 导航Body数据 | 4 | * 导航Body数据 |
| 5 | */ | 5 | */ |
| 6 | export interface NavigationBodyDTO { | 6 | export interface NavigationBodyDTO { |
| 7 | - backgroundColor: string; | 7 | + backgroundColor: string; // 迭代二新增-底部导航背景色(信息流频道) |
| 8 | bottomNavList: BottomNavDTO[]; | 8 | bottomNavList: BottomNavDTO[]; |
| 9 | - // greyBottomNav: GreyBottomNav; | ||
| 10 | - immersiveBackgroundColor: string; | ||
| 11 | - nightBackgroundColor: string; | 9 | + |
| 10 | + // greyBottomNav: GreyBottomNav; // 灰度皮肤 | ||
| 11 | + immersiveBackgroundColor: string; // 迭代二新增-底部导航背景色(沉浸式频道) | ||
| 12 | + nightBackgroundColor: string; // 迭代三新增-底部导航背景色(夜间模式) | ||
| 12 | } | 13 | } |
| @@ -7,14 +7,14 @@ export interface TopNavDTO { | @@ -7,14 +7,14 @@ export interface TopNavDTO { | ||
| 7 | channelType: number; | 7 | channelType: number; |
| 8 | defaultPermitted: number; | 8 | defaultPermitted: number; |
| 9 | delPermitted: number; | 9 | delPermitted: number; |
| 10 | - fontCColor: string; | ||
| 11 | - fontColor: string; | 10 | + fontCColor: string; // 频道展示样式颜色(选中状态) |
| 11 | + fontColor: string; // 频道展示样式颜色(未选中状态) | ||
| 12 | headlinesOn: number; | 12 | headlinesOn: number; |
| 13 | homeChannel: string; | 13 | homeChannel: string; |
| 14 | - iconCUrl: string; | ||
| 15 | - iconCUrlSize: string; | ||
| 16 | - iconUrl: string; | ||
| 17 | iconUrlSize: string; | 14 | iconUrlSize: string; |
| 15 | + iconCUrlSize: string; | ||
| 16 | + iconUrl: string; // 频道图片展示样式图片相对地址(未选中状态) | ||
| 17 | + iconCUrl: string; //频道图片展示样式图片相对地址(选中状态 | ||
| 18 | localChannel: string; | 18 | localChannel: string; |
| 19 | moreChannel: string; | 19 | moreChannel: string; |
| 20 | movePermitted: number; | 20 | movePermitted: number; |
| @@ -23,5 +23,5 @@ export interface TopNavDTO { | @@ -23,5 +23,5 @@ export interface TopNavDTO { | ||
| 23 | num: number; | 23 | num: number; |
| 24 | pageId: number; | 24 | pageId: number; |
| 25 | pageType: string; | 25 | pageType: string; |
| 26 | - underlineCColor: string; | 26 | + underlineCColor: string; // 选中下划线颜色 |
| 27 | } | 27 | } |
| 1 | import { BottomNavi, CommonConstants } from 'wdConstant'; | 1 | import { BottomNavi, CommonConstants } from 'wdConstant'; |
| 2 | -import { BottomNavDTO } from 'wdBean'; | 2 | +import { BottomNavDTO, TopNavDTO } from 'wdBean'; |
| 3 | import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; | 3 | import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; |
| 4 | import { TopNavigationComponent } from './TopNavigationComponent'; | 4 | import { TopNavigationComponent } from './TopNavigationComponent'; |
| 5 | import { MinePageComponent } from './MinePageComponent'; | 5 | import { MinePageComponent } from './MinePageComponent'; |
| 6 | import { CompUtils } from '../../utils/CompUtils'; | 6 | import { CompUtils } from '../../utils/CompUtils'; |
| 7 | import PageViewModel from '../../viewmodel/PageViewModel'; | 7 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 8 | import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; | 8 | import HomeChannelUtils, { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils'; |
| 9 | +import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | ||
| 9 | 10 | ||
| 10 | const TAG = 'BottomNavigationComponent'; | 11 | const TAG = 'BottomNavigationComponent'; |
| 11 | let storage = LocalStorage.getShared(); | 12 | let storage = LocalStorage.getShared(); |
| @@ -21,14 +22,13 @@ export struct BottomNavigationComponent { | @@ -21,14 +22,13 @@ export struct BottomNavigationComponent { | ||
| 21 | @Provide isLayoutFullScreen: boolean = false | 22 | @Provide isLayoutFullScreen: boolean = false |
| 22 | @Provide isImmersive: boolean = false // 是否开启沉浸式模式 http://192.168.1.3:3300/project/3802/interface/api/189229 | 23 | @Provide isImmersive: boolean = false // 是否开启沉浸式模式 http://192.168.1.3:3300/project/3802/interface/api/189229 |
| 23 | @Provide isNight: boolean = false // 是否开启夜间模式 | 24 | @Provide isNight: boolean = false // 是否开启夜间模式 |
| 25 | + @Provide currentBottomNavInfo: BottomNavDTO = {} as BottomNavDTO; // 当前底导信息 | ||
| 26 | + @Provide currentTopNavInfo: TopNavDTO = {} as TopNavDTO; // 当前顶导信息 | ||
| 27 | + @Provide barBackgroundColor: Color = Color.Transparent | ||
| 24 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 28 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 25 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 29 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 26 | - // 底导/顶导全部数据 | ||
| 27 | - @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] | ||
| 28 | - // 底导当前选中/焦点下标 | ||
| 29 | - @State currentNavIndex: number = BottomNavi.NEWS; | ||
| 30 | - // @State currentTopNavSelectedIndex: number = 0; // | ||
| 31 | - @State barBackgroundColor: Color = Color.Transparent | 30 | + @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] // 底导/顶导全部数据 |
| 31 | + @State currentNavIndex: number = BottomNavi.NEWS; // 底导当前选中/焦点下标 | ||
| 32 | // 底导TabsController | 32 | // 底导TabsController |
| 33 | private navController: TabsController = new TabsController(); | 33 | private navController: TabsController = new TabsController(); |
| 34 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 | 34 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 |
| @@ -44,6 +44,7 @@ export struct BottomNavigationComponent { | @@ -44,6 +44,7 @@ export struct BottomNavigationComponent { | ||
| 44 | @State assignChannel: AssignChannelParam = new AssignChannelParam() | 44 | @State assignChannel: AssignChannelParam = new AssignChannelParam() |
| 45 | // 自动刷新触发(双击tab自动刷新) | 45 | // 自动刷新触发(双击tab自动刷新) |
| 46 | @State autoRefresh: number = 0 | 46 | @State autoRefresh: number = 0 |
| 47 | + | ||
| 47 | async aboutToAppear() { | 48 | async aboutToAppear() { |
| 48 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); | 49 | Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`); |
| 49 | let bottomNav = await PageViewModel.getBottomNavData(getContext(this)) | 50 | let bottomNav = await PageViewModel.getBottomNavData(getContext(this)) |
| @@ -84,7 +85,6 @@ export struct BottomNavigationComponent { | @@ -84,7 +85,6 @@ export struct BottomNavigationComponent { | ||
| 84 | _currentNavIndex: $currentNavIndex, | 85 | _currentNavIndex: $currentNavIndex, |
| 85 | navIndex: index, | 86 | navIndex: index, |
| 86 | currentBottomNavName: navItem.name, | 87 | currentBottomNavName: navItem.name, |
| 87 | - barBackgroundColor: $barBackgroundColor, | ||
| 88 | assignChannel: this.assignChannel, | 88 | assignChannel: this.assignChannel, |
| 89 | autoRefresh: this.autoRefresh | 89 | autoRefresh: this.autoRefresh |
| 90 | }) | 90 | }) |
| @@ -99,8 +99,8 @@ export struct BottomNavigationComponent { | @@ -99,8 +99,8 @@ export struct BottomNavigationComponent { | ||
| 99 | .animationDuration(0) | 99 | .animationDuration(0) |
| 100 | .barHeight($r('app.float.bottom_navigation_barHeight')) | 100 | .barHeight($r('app.float.bottom_navigation_barHeight')) |
| 101 | .barMode(BarMode.Fixed) | 101 | .barMode(BarMode.Fixed) |
| 102 | - // TODO:更详细的判断是视频频道 | ||
| 103 | .barBackgroundColor(this.barBackgroundColor) | 102 | .barBackgroundColor(this.barBackgroundColor) |
| 103 | + // 备注:鸿蒙目前只有修改三线导航背景方法,对于全面屏导航条手机需要设置背景色并使其扩散到导航区域 | ||
| 104 | .backgroundColor(this.barBackgroundColor) | 104 | .backgroundColor(this.barBackgroundColor) |
| 105 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | 105 | .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) |
| 106 | 106 | ||
| @@ -108,17 +108,6 @@ export struct BottomNavigationComponent { | @@ -108,17 +108,6 @@ export struct BottomNavigationComponent { | ||
| 108 | 108 | ||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | - /** | ||
| 112 | - * TODO:更详细的判断视频频道 | ||
| 113 | - */ | ||
| 114 | - getFontColor(index: number): Color { | ||
| 115 | - if (this.currentNavIndex === 2 && this.barBackgroundColor === Color.Black) { | ||
| 116 | - return Color.White | ||
| 117 | - } else { | ||
| 118 | - return this.currentNavIndex === index ? Color.Red : Color.Gray | ||
| 119 | - } | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | @Builder | 111 | @Builder |
| 123 | tabBarBuilder(navItem: BottomNavDTO, index: number) { | 112 | tabBarBuilder(navItem: BottomNavDTO, index: number) { |
| 124 | Stack({ alignContent: Alignment.Bottom }) { | 113 | Stack({ alignContent: Alignment.Bottom }) { |
| @@ -132,31 +121,34 @@ export struct BottomNavigationComponent { | @@ -132,31 +121,34 @@ export struct BottomNavigationComponent { | ||
| 132 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) | 121 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 133 | .textAlign(TextAlign.Center) | 122 | .textAlign(TextAlign.Center) |
| 134 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) | 123 | .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) |
| 135 | - .fontColor(this.getFontColor(index)) | 124 | + .fontColor(this.currentNavIndex === index ? navItem.nameCColor : navItem.nameColor) |
| 136 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) | 125 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) |
| 137 | } | 126 | } |
| 138 | .height($r('app.float.bottom_navigation_barHeight')) | 127 | .height($r('app.float.bottom_navigation_barHeight')) |
| 139 | .hoverEffect(HoverEffect.Highlight) | 128 | .hoverEffect(HoverEffect.Highlight) |
| 140 | - .onClick(() => { | ||
| 141 | - if (this.currentNavIndex === index) { | ||
| 142 | - // 当前tab,双击事件 | ||
| 143 | - this.doubleClick(() => { | ||
| 144 | - Logger.info(TAG, 'tab double click ') | ||
| 145 | - this.autoRefresh++ | 129 | + .gesture( |
| 130 | + TapGesture({ count: 2 }) | ||
| 131 | + .onAction((event: GestureEvent) => { | ||
| 132 | + AlertDialog.show({ message: 'aa' }) | ||
| 133 | + if (this.currentNavIndex === index) { | ||
| 134 | + // 当前tab,双击事件 | ||
| 135 | + this.autoRefresh++ | ||
| 136 | + } | ||
| 146 | }) | 137 | }) |
| 138 | + ) | ||
| 139 | + .onClick(() => { | ||
| 140 | + if (navItem.name === '我的') { | ||
| 141 | + this.barBackgroundColor = Color.White | ||
| 142 | + this.currentBottomNavInfo = {} as BottomNavDTO | ||
| 147 | } else { | 143 | } else { |
| 148 | - // 切换tab | ||
| 149 | - this.currentNavIndex = index; | ||
| 150 | - Logger.info(TAG, `onChange, index: ${index}`); | 144 | + this.currentBottomNavInfo = navItem |
| 151 | } | 145 | } |
| 146 | + | ||
| 147 | + this.currentNavIndex = index; | ||
| 148 | + Logger.info(TAG, `onChange, index: ${index}`); | ||
| 149 | + | ||
| 152 | }) | 150 | }) |
| 153 | 151 | ||
| 154 | - // .justifyContent(FlexAlign.Center) | ||
| 155 | - // .onClick(() => { | ||
| 156 | - // Logger.info(TAG, `onClick, index: ${index}`); | ||
| 157 | - // this.currentNavIndex = index ?? 0; | ||
| 158 | - // this.navController.changeIndex(this.currentNavIndex); | ||
| 159 | - // }) | ||
| 160 | } | 152 | } |
| 161 | 153 | ||
| 162 | // 底导切换函数 | 154 | // 底导切换函数 |
| @@ -199,17 +191,17 @@ export struct BottomNavigationComponent { | @@ -199,17 +191,17 @@ export struct BottomNavigationComponent { | ||
| 199 | /** | 191 | /** |
| 200 | * 双击实现 | 192 | * 双击实现 |
| 201 | */ | 193 | */ |
| 202 | - doubleClickTime: number = 0 | 194 | + // doubleClickTime: number = 0 |
| 203 | 195 | ||
| 204 | /** | 196 | /** |
| 205 | * 双击实现 | 197 | * 双击实现 |
| 206 | */ | 198 | */ |
| 207 | - private doubleClick(fun: () => void) { | ||
| 208 | - let now = DateTimeUtils.getTimeStamp() | ||
| 209 | - if (now - this.doubleClickTime < 200) { | ||
| 210 | - fun() | ||
| 211 | - } else { | ||
| 212 | - this.doubleClickTime = now | ||
| 213 | - } | ||
| 214 | - } | 199 | + // private doubleClick(fun: () => void) { |
| 200 | + // let now = DateTimeUtils.getTimeStamp() | ||
| 201 | + // if (now - this.doubleClickTime < 200) { | ||
| 202 | + // fun() | ||
| 203 | + // } else { | ||
| 204 | + // this.doubleClickTime = now | ||
| 205 | + // } | ||
| 206 | + // } | ||
| 215 | } | 207 | } |
| 1 | -import { CompDTO, TopNavDTO } from 'wdBean'; | 1 | +import { BottomNavDTO, CompDTO, TopNavDTO } from 'wdBean'; |
| 2 | import { LazyDataSource, Logger } from 'wdKit'; | 2 | import { LazyDataSource, Logger } from 'wdKit'; |
| 3 | import { ProcessUtils } from 'wdRouter'; | 3 | import { ProcessUtils } from 'wdRouter'; |
| 4 | import { PageComponent } from './PageComponent'; | 4 | import { PageComponent } from './PageComponent'; |
| @@ -26,12 +26,14 @@ export struct TopNavigationComponent { | @@ -26,12 +26,14 @@ export struct TopNavigationComponent { | ||
| 26 | @Consume isLayoutFullScreen: boolean | 26 | @Consume isLayoutFullScreen: boolean |
| 27 | @Consume bottomRectHeight: number | 27 | @Consume bottomRectHeight: number |
| 28 | @Consume topRectHeight: number | 28 | @Consume topRectHeight: number |
| 29 | + @Consume @Watch('topOrBottomNavChange') currentBottomNavInfo: BottomNavDTO // 当前底导信息 | ||
| 30 | + @Consume barBackgroundColor: Color | ||
| 29 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 31 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 30 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 32 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 31 | - @Link barBackgroundColor: Color | ||
| 32 | @Link _currentNavIndex?: number; | 33 | @Link _currentNavIndex?: number; |
| 33 | // 顶导当前选中/焦点下标 | 34 | // 顶导当前选中/焦点下标 |
| 34 | - @State currentTopNavSelectedIndex: number = 0; | 35 | + @State @Watch('topOrBottomNavChange') currentTopNavSelectedIndex: number = 0; |
| 36 | + @State currentTopNavName: string = ''; | ||
| 35 | // 顶导数据 | 37 | // 顶导数据 |
| 36 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 38 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 37 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 39 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| @@ -56,6 +58,21 @@ export struct TopNavigationComponent { | @@ -56,6 +58,21 @@ export struct TopNavigationComponent { | ||
| 56 | // 当前底导index | 58 | // 当前底导index |
| 57 | @State navIndex: number = 0 | 59 | @State navIndex: number = 0 |
| 58 | 60 | ||
| 61 | + topOrBottomNavChange() { | ||
| 62 | + if (this.currentBottomNavName === this.currentBottomNavInfo?.name) { | ||
| 63 | + this.setBarBackgroundColor() | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + setBarBackgroundColor() { | ||
| 68 | + console.error('setBarBackgroundColor', this.currentTopNavName, this.currentBottomNavInfo?.name) | ||
| 69 | + if (this.currentTopNavName === '视频' && this.currentBottomNavInfo?.name === '视频') { | ||
| 70 | + this.barBackgroundColor = Color.Black | ||
| 71 | + } else { | ||
| 72 | + this.barBackgroundColor = Color.White | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 59 | //处理新闻tab顶导频道数据 | 76 | //处理新闻tab顶导频道数据 |
| 60 | topNavListHandle() { | 77 | topNavListHandle() { |
| 61 | let _channelIds: number [] = [] | 78 | let _channelIds: number [] = [] |
| @@ -126,10 +143,14 @@ export struct TopNavigationComponent { | @@ -126,10 +143,14 @@ export struct TopNavigationComponent { | ||
| 126 | this.channelIds = _channelIds | 143 | this.channelIds = _channelIds |
| 127 | this.myChannelList = _myChannelList | 144 | this.myChannelList = _myChannelList |
| 128 | 145 | ||
| 146 | + this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[0].name : this.topNavList[0].name | ||
| 147 | + | ||
| 148 | + | ||
| 129 | //缓存首页频道 | 149 | //缓存首页频道 |
| 130 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) | 150 | let index = this.myChannelList.findIndex(_item => _item.channelId === this.indexSettingChannelId) |
| 131 | if (index > -1) { | 151 | if (index > -1) { |
| 132 | this.currentTopNavSelectedIndex = index | 152 | this.currentTopNavSelectedIndex = index |
| 153 | + this.currentTopNavName = this.myChannelList[index].name | ||
| 133 | } | 154 | } |
| 134 | } | 155 | } |
| 135 | 156 | ||
| @@ -196,7 +217,6 @@ export struct TopNavigationComponent { | @@ -196,7 +217,6 @@ export struct TopNavigationComponent { | ||
| 196 | groupId: this.groupId + '', | 217 | groupId: this.groupId + '', |
| 197 | pageId: navItem.pageId + '', | 218 | pageId: navItem.pageId + '', |
| 198 | channelId: navItem.channelId + '', | 219 | channelId: navItem.channelId + '', |
| 199 | - barBackgroundColor: $barBackgroundColor | ||
| 200 | }) | 220 | }) |
| 201 | } else | 221 | } else |
| 202 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | 222 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { |
| @@ -216,9 +236,10 @@ export struct TopNavigationComponent { | @@ -216,9 +236,10 @@ export struct TopNavigationComponent { | ||
| 216 | .barHeight($r('app.float.top_tab_bar_height')) | 236 | .barHeight($r('app.float.top_tab_bar_height')) |
| 217 | .barMode(BarMode.Scrollable) | 237 | .barMode(BarMode.Scrollable) |
| 218 | .vertical(false) | 238 | .vertical(false) |
| 219 | - // item.name === '视频' && this.currentTopNavSelectedIndex === 0 ? | ||
| 220 | .barBackgroundColor(this.barBackgroundColor) | 239 | .barBackgroundColor(this.barBackgroundColor) |
| 221 | .onChange((index: number) => { | 240 | .onChange((index: number) => { |
| 241 | + this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name | ||
| 242 | + | ||
| 222 | Logger.info(TAG, `onChange index : ${index}`); | 243 | Logger.info(TAG, `onChange index : ${index}`); |
| 223 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 244 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| 224 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) | 245 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) |
| @@ -256,15 +277,11 @@ export struct TopNavigationComponent { | @@ -256,15 +277,11 @@ export struct TopNavigationComponent { | ||
| 256 | } | 277 | } |
| 257 | 278 | ||
| 258 | /** | 279 | /** |
| 259 | - * TODO:更详细的判断视频频道 | 280 | + * TODO:根据顶导配置获取颜色展示效果不对,待确认 |
| 260 | */ | 281 | */ |
| 261 | - getFontColor(item: TopNavDTO, index: number): Color | string { | ||
| 262 | - if (this._currentNavIndex === 2) { | ||
| 263 | - if (this.currentTopNavSelectedIndex == 0) { | ||
| 264 | - return item.name === '视频' ? Color.White : '#e5e0e0' | ||
| 265 | - } else { | ||
| 266 | - return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" | ||
| 267 | - } | 282 | + getTopNavFontColor(item: TopNavDTO, index: number): Color | string { |
| 283 | + if (item.name === '视频' && this.currentBottomNavInfo.name === '视频') { | ||
| 284 | + return this.currentTopNavSelectedIndex === index ? Color.White : '#e5e0e0' | ||
| 268 | } else { | 285 | } else { |
| 269 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" | 286 | return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999" |
| 270 | } | 287 | } |
| @@ -276,9 +293,10 @@ export struct TopNavigationComponent { | @@ -276,9 +293,10 @@ export struct TopNavigationComponent { | ||
| 276 | Text(item.name) | 293 | Text(item.name) |
| 277 | .fontSize($r('app.float.selected_text_size')) | 294 | .fontSize($r('app.float.selected_text_size')) |
| 278 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | 295 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 279 | - .fontColor(this.getFontColor(item, index)) | ||
| 280 | - .padding({ top: $r('app.float.top_tab_item_padding_top') , bottom: $r('app.float.top_tab_item_padding_bottom')}) | 296 | + .fontColor(this.getTopNavFontColor(item, index)) |
| 297 | + .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) | ||
| 281 | .maxLines(this.MAX_LINE) | 298 | .maxLines(this.MAX_LINE) |
| 299 | + // .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl) | ||
| 282 | if (this.currentTopNavSelectedIndex === index) { | 300 | if (this.currentTopNavSelectedIndex === index) { |
| 283 | Row() | 301 | Row() |
| 284 | .width(20) | 302 | .width(20) |
| @@ -292,18 +310,20 @@ export struct TopNavigationComponent { | @@ -292,18 +310,20 @@ export struct TopNavigationComponent { | ||
| 292 | minWidth: $r('app.float.top_tab_item_min_width'), | 310 | minWidth: $r('app.float.top_tab_item_min_width'), |
| 293 | maxWidth: $r('app.float.top_tab_item_max_width') | 311 | maxWidth: $r('app.float.top_tab_item_max_width') |
| 294 | }) | 312 | }) |
| 295 | - .backgroundColor(Color.Transparent) | 313 | + // .backgroundColor(Color.Transparent) |
| 296 | .padding({ | 314 | .padding({ |
| 297 | left: $r('app.float.top_tab_item_padding_horizontal'), | 315 | left: $r('app.float.top_tab_item_padding_horizontal'), |
| 298 | right: $r('app.float.top_tab_item_padding_horizontal'), | 316 | right: $r('app.float.top_tab_item_padding_horizontal'), |
| 299 | }) | 317 | }) |
| 300 | .id(`col_tabBar${index}`) | 318 | .id(`col_tabBar${index}`) |
| 301 | .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) | 319 | .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) |
| 320 | + | ||
| 302 | } | 321 | } |
| 303 | 322 | ||
| 304 | aboutToAppear() { | 323 | aboutToAppear() { |
| 305 | //处理新闻tab顶导频道数据 | 324 | //处理新闻tab顶导频道数据 |
| 306 | this.topNavListHandle() | 325 | this.topNavListHandle() |
| 326 | + this.setBarBackgroundColor() | ||
| 307 | } | 327 | } |
| 308 | 328 | ||
| 309 | aboutToDisappear() { | 329 | aboutToDisappear() { |
| @@ -133,7 +133,7 @@ export struct DetailPlayShortVideoPage { | @@ -133,7 +133,7 @@ export struct DetailPlayShortVideoPage { | ||
| 133 | aboutToAppear() { | 133 | aboutToAppear() { |
| 134 | this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape | 134 | this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape |
| 135 | this.playerController.onCanplay = () => { | 135 | this.playerController.onCanplay = () => { |
| 136 | - if (this.index == 0 || this.currentIndex === this.index) { | 136 | + if ((this.index == 0 || this.currentIndex === this.index) && this.switchVideoStatus) { |
| 137 | this.playerController.play() | 137 | this.playerController.play() |
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| @@ -38,7 +38,7 @@ export struct VideoChannelDetail { | @@ -38,7 +38,7 @@ export struct VideoChannelDetail { | ||
| 38 | // private recommend?: string = '' // 0.非推荐,1.推荐; | 38 | // private recommend?: string = '' // 0.非推荐,1.推荐; |
| 39 | @Link @Watch('navIndexChange') bottomNavIndex: number | 39 | @Link @Watch('navIndexChange') bottomNavIndex: number |
| 40 | @Link @Watch('navIndexChange') topNavIndex: number | 40 | @Link @Watch('navIndexChange') topNavIndex: number |
| 41 | - @Link barBackgroundColor: Color | 41 | + @Consume barBackgroundColor: Color |
| 42 | private swiperController: SwiperController = new SwiperController() | 42 | private swiperController: SwiperController = new SwiperController() |
| 43 | @Provide showComment: boolean = false | 43 | @Provide showComment: boolean = false |
| 44 | @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | 44 | @Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0 |
| @@ -72,11 +72,11 @@ export struct VideoChannelDetail { | @@ -72,11 +72,11 @@ export struct VideoChannelDetail { | ||
| 72 | navIndexChange() { | 72 | navIndexChange() { |
| 73 | console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex) | 73 | console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex) |
| 74 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { | 74 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { |
| 75 | - this.barBackgroundColor = Color.Black | 75 | + // this.barBackgroundColor = Color.Black |
| 76 | this.switchVideoStatus = true | 76 | this.switchVideoStatus = true |
| 77 | this.openFullScreen() | 77 | this.openFullScreen() |
| 78 | } else { | 78 | } else { |
| 79 | - this.barBackgroundColor = Color.Transparent | 79 | + // this.barBackgroundColor = Color.Transparent |
| 80 | this.switchVideoStatus = false | 80 | this.switchVideoStatus = false |
| 81 | this.closeFullScreen() | 81 | this.closeFullScreen() |
| 82 | } | 82 | } |
-
Please register or login to post a comment