Showing
13 changed files
with
215 additions
and
56 deletions
| @@ -15,15 +15,17 @@ export class Size { | @@ -15,15 +15,17 @@ export class Size { | ||
| 15 | 15 | ||
| 16 | export class WindowModel { | 16 | export class WindowModel { |
| 17 | private windowStage?: window.WindowStage; | 17 | private windowStage?: window.WindowStage; |
| 18 | - | ||
| 19 | static shared: WindowModel = new WindowModel() | 18 | static shared: WindowModel = new WindowModel() |
| 20 | - | ||
| 21 | static TAG = "WindowModel"; | 19 | static TAG = "WindowModel"; |
| 22 | 20 | ||
| 23 | setWindowStage(windowStage: window.WindowStage) { | 21 | setWindowStage(windowStage: window.WindowStage) { |
| 24 | this.windowStage = windowStage; | 22 | this.windowStage = windowStage; |
| 25 | } | 23 | } |
| 26 | 24 | ||
| 25 | + getWindowStage(): window.WindowStage { | ||
| 26 | + return this.windowStage as window.WindowStage | ||
| 27 | + } | ||
| 28 | + | ||
| 27 | setMainWindowFullScreen(fullScreen: boolean) { | 29 | setMainWindowFullScreen(fullScreen: boolean) { |
| 28 | if (deviceInfo.deviceType != "phone") { | 30 | if (deviceInfo.deviceType != "phone") { |
| 29 | return | 31 | return |
| @@ -65,10 +67,10 @@ export class WindowModel { | @@ -65,10 +67,10 @@ export class WindowModel { | ||
| 65 | windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err: BusinessError) => { | 67 | windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err: BusinessError) => { |
| 66 | const errCode: number = err.code; | 68 | const errCode: number = err.code; |
| 67 | if (errCode) { | 69 | if (errCode) { |
| 68 | - console.error(WindowModel.TAG +'设置屏幕常亮:' + isKeepScreenOn + ',失败: ' + JSON.stringify(err)); | 70 | + console.error(WindowModel.TAG + '设置屏幕常亮:' + isKeepScreenOn + ',失败: ' + JSON.stringify(err)); |
| 69 | return; | 71 | return; |
| 70 | } | 72 | } |
| 71 | - console.info(WindowModel.TAG +'设置屏幕常亮:' + isKeepScreenOn + ",成功"); | 73 | + console.info(WindowModel.TAG + '设置屏幕常亮:' + isKeepScreenOn + ",成功"); |
| 72 | }) | 74 | }) |
| 73 | }) | 75 | }) |
| 74 | } | 76 | } |
| @@ -14,6 +14,7 @@ | @@ -14,6 +14,7 @@ | ||
| 14 | "wdKit": "file:../../commons/wdKit", | 14 | "wdKit": "file:../../commons/wdKit", |
| 15 | "wdWebComponent": "file:../../commons/wdWebComponent", | 15 | "wdWebComponent": "file:../../commons/wdWebComponent", |
| 16 | "wdBean": "file:../../features/wdBean", | 16 | "wdBean": "file:../../features/wdBean", |
| 17 | + "wdDetailPlayShortVideo": "file:../../features/wdDetailPlayShortVideo", | ||
| 17 | "wdRouter": "file:../../commons/wdRouter", | 18 | "wdRouter": "file:../../commons/wdRouter", |
| 18 | "wdNetwork": "file:../../commons/wdNetwork" | 19 | "wdNetwork": "file:../../commons/wdNetwork" |
| 19 | } | 20 | } |
| @@ -7,16 +7,24 @@ import { CompUtils } from '../../utils/CompUtils'; | @@ -7,16 +7,24 @@ import { CompUtils } from '../../utils/CompUtils'; | ||
| 7 | import PageViewModel from '../../viewmodel/PageViewModel'; | 7 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 8 | 8 | ||
| 9 | const TAG = 'BottomNavigationComponent'; | 9 | const TAG = 'BottomNavigationComponent'; |
| 10 | +let storage = LocalStorage.getShared(); | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 底部页签导航栏/底导 | 13 | * 底部页签导航栏/底导 |
| 13 | */ | 14 | */ |
| 15 | +@Entry(storage) | ||
| 14 | @Component | 16 | @Component |
| 15 | export struct BottomNavigationComponent { | 17 | export struct BottomNavigationComponent { |
| 18 | + @Provide bottomRectHeight: number = 0 | ||
| 19 | + @Provide topRectHeight: number = 0 | ||
| 20 | + @Provide isLayoutFullScreen: boolean = false | ||
| 21 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 22 | + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | ||
| 16 | // 底导/顶导全部数据 | 23 | // 底导/顶导全部数据 |
| 17 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] | 24 | @State @Watch('onBottomNavigationDataUpdated') bottomNavList: BottomNavDTO[] = [] |
| 18 | // 底导当前选中/焦点下标 | 25 | // 底导当前选中/焦点下标 |
| 19 | @State currentNavIndex: number = BottomNavi.NEWS; | 26 | @State currentNavIndex: number = BottomNavi.NEWS; |
| 27 | + @State barBackgroundColor: Color = Color.Transparent | ||
| 20 | // 底导TabsController | 28 | // 底导TabsController |
| 21 | private navController: TabsController = new TabsController(); | 29 | private navController: TabsController = new TabsController(); |
| 22 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 | 30 | readonly ASPECT_RATIO_1_1: number = 1 / 1; // 底导图片宽高比 |
| @@ -51,20 +59,44 @@ export struct BottomNavigationComponent { | @@ -51,20 +59,44 @@ export struct BottomNavigationComponent { | ||
| 51 | // 我的页面组件数据列表 | 59 | // 我的页面组件数据列表 |
| 52 | MinePageComponent() | 60 | MinePageComponent() |
| 53 | } else { | 61 | } else { |
| 54 | - TopNavigationComponent({ topNavList: navItem.topNavChannelList, _currentNavIndex: this.currentNavIndex }) | 62 | + TopNavigationComponent({ |
| 63 | + topNavList: navItem.topNavChannelList, | ||
| 64 | + _currentNavIndex: this.currentNavIndex, | ||
| 65 | + changeBarBackgroundColor: (color: Color) => { | ||
| 66 | + this.barBackgroundColor = color | ||
| 55 | } | 67 | } |
| 68 | + }) | ||
| 69 | + } | ||
| 70 | + | ||
| 56 | } | 71 | } |
| 57 | } | 72 | } |
| 58 | .tabBar(this.tabBarBuilder(navItem, index)) | 73 | .tabBar(this.tabBarBuilder(navItem, index)) |
| 59 | }); | 74 | }); |
| 75 | + | ||
| 60 | } | 76 | } |
| 61 | .barHeight($r('app.float.bottom_navigation_barHeight')) | 77 | .barHeight($r('app.float.bottom_navigation_barHeight')) |
| 62 | .barMode(BarMode.Fixed) | 78 | .barMode(BarMode.Fixed) |
| 79 | + // TODO:更详细的判断是视频频道 | ||
| 80 | + .barBackgroundColor(this.barBackgroundColor) | ||
| 63 | .onChange((index: number) => { | 81 | .onChange((index: number) => { |
| 64 | Logger.info(TAG, `onChange, index: ${index}`); | 82 | Logger.info(TAG, `onChange, index: ${index}`); |
| 65 | this.currentNavIndex = index; | 83 | this.currentNavIndex = index; |
| 66 | // this.onBottomNavigationIndexChange() | 84 | // this.onBottomNavigationIndexChange() |
| 67 | }) | 85 | }) |
| 86 | + .backgroundColor(this.barBackgroundColor) | ||
| 87 | + .padding({ bottom: this.bottomRectHeight + 'px', top: this.topRectHeight + 'px' }) // 此处margin具体数值在实际中应与导航条区域高度保持一致 | ||
| 88 | + | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * TODO:更详细的判断视频频道 | ||
| 93 | + */ | ||
| 94 | + getFontColor(index: number): Color { | ||
| 95 | + if (this.currentNavIndex === 2 && this.barBackgroundColor === Color.Black) { | ||
| 96 | + return Color.White | ||
| 97 | + } else { | ||
| 98 | + return this.currentNavIndex === index ? Color.Red : Color.Gray | ||
| 99 | + } | ||
| 68 | } | 100 | } |
| 69 | 101 | ||
| 70 | @Builder | 102 | @Builder |
| @@ -79,8 +111,8 @@ export struct BottomNavigationComponent { | @@ -79,8 +111,8 @@ export struct BottomNavigationComponent { | ||
| 79 | .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) | 111 | .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) |
| 80 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) | 112 | .fontWeight(this.currentNavIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 81 | .textAlign(TextAlign.Center) | 113 | .textAlign(TextAlign.Center) |
| 82 | - .fontSize($r('app.float.font_size_10')) | ||
| 83 | - .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) | 114 | + .fontSize($r('app.float.font_size_10'))// .fontColor(this.currentNavIndex === index ? Color.Red : Color.Gray) |
| 115 | + .fontColor(this.getFontColor(index)) | ||
| 84 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) | 116 | .opacity(this.currentNavIndex === index ? this.FULL_OPACITY : this.SIXTY_OPACITY) |
| 85 | } | 117 | } |
| 86 | .height($r('app.float.bottom_navigation_barHeight')) | 118 | .height($r('app.float.bottom_navigation_barHeight')) |
| @@ -12,6 +12,7 @@ import LoadMoreLayout from './LoadMoreLayout'; | @@ -12,6 +12,7 @@ import LoadMoreLayout from './LoadMoreLayout'; | ||
| 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 13 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 14 | import { CompDTO } from 'wdBean'; | 14 | import { CompDTO } from 'wdBean'; |
| 15 | +import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; | ||
| 15 | 16 | ||
| 16 | const TAG = 'PageComponent'; | 17 | const TAG = 'PageComponent'; |
| 17 | 18 | ||
| @@ -21,6 +22,7 @@ export struct PageComponent { | @@ -21,6 +22,7 @@ export struct PageComponent { | ||
| 21 | navIndex: number = 0; | 22 | navIndex: number = 0; |
| 22 | pageId: string = ""; | 23 | pageId: string = ""; |
| 23 | channelId: string = ""; | 24 | channelId: string = ""; |
| 25 | + name: string = ""; | ||
| 24 | @Link @Watch('onChange') currentTopNavSelectedIndex: number | 26 | @Link @Watch('onChange') currentTopNavSelectedIndex: number |
| 25 | 27 | ||
| 26 | build() { | 28 | build() { |
| @@ -62,8 +64,13 @@ export struct PageComponent { | @@ -62,8 +64,13 @@ export struct PageComponent { | ||
| 62 | LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { | 64 | LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { |
| 63 | ListItem() { | 65 | ListItem() { |
| 64 | Column() { | 66 | Column() { |
| 67 | + if (this.name == '视频') { | ||
| 68 | + VideoChannelDetail() | ||
| 69 | + } else { | ||
| 65 | CompParser({ compDTO: compDTO, compIndex: compIndex }); | 70 | CompParser({ compDTO: compDTO, compIndex: compIndex }); |
| 66 | } | 71 | } |
| 72 | + | ||
| 73 | + } | ||
| 67 | } | 74 | } |
| 68 | }, | 75 | }, |
| 69 | (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp | 76 | (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp |
| @@ -94,8 +101,10 @@ export struct PageComponent { | @@ -94,8 +101,10 @@ export struct PageComponent { | ||
| 94 | 101 | ||
| 95 | @Builder | 102 | @Builder |
| 96 | LoadingLayout() { | 103 | LoadingLayout() { |
| 97 | - CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true, | ||
| 98 | - $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.pageModel.pullDownRefreshHeight) }) | 104 | + CustomRefreshLoadLayout({ |
| 105 | + refreshBean: new RefreshLayoutBean(true, | ||
| 106 | + $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.pageModel.pullDownRefreshHeight) | ||
| 107 | + }) | ||
| 99 | } | 108 | } |
| 100 | 109 | ||
| 101 | async aboutToAppear() { | 110 | async aboutToAppear() { |
| @@ -4,21 +4,34 @@ import { WDRouterRule } from 'wdRouter'; | @@ -4,21 +4,34 @@ import { WDRouterRule } from 'wdRouter'; | ||
| 4 | import { PageComponent } from './PageComponent'; | 4 | import { PageComponent } from './PageComponent'; |
| 5 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout'; | 5 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout'; |
| 6 | import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent'; | 6 | import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent'; |
| 7 | +import window from '@ohos.window'; | ||
| 8 | +import { WindowModel } from 'wdKit'; | ||
| 7 | 9 | ||
| 8 | const TAG = 'TopNavigationComponent'; | 10 | const TAG = 'TopNavigationComponent'; |
| 9 | 11 | ||
| 10 | PersistentStorage.persistProp('channelIds', ''); | 12 | PersistentStorage.persistProp('channelIds', ''); |
| 11 | PersistentStorage.persistProp('indexSettingChannelId', 0); | 13 | PersistentStorage.persistProp('indexSettingChannelId', 0); |
| 12 | 14 | ||
| 15 | +const storage = LocalStorage.getShared(); | ||
| 16 | + | ||
| 13 | /** | 17 | /** |
| 14 | * 顶部页签导航栏/顶导 | 18 | * 顶部页签导航栏/顶导 |
| 15 | */ | 19 | */ |
| 20 | +@Entry(storage) | ||
| 16 | @Component | 21 | @Component |
| 17 | export struct TopNavigationComponent { | 22 | export struct TopNavigationComponent { |
| 18 | private tabsController: TabsController = new TabsController() | 23 | private tabsController: TabsController = new TabsController() |
| 19 | - @Prop _currentNavIndex?: number; | 24 | + private changeBarBackgroundColor: (color: Color) => void = () => { |
| 25 | + } | ||
| 26 | + @Consume isLayoutFullScreen: boolean | ||
| 27 | + @Consume bottomRectHeight: number | ||
| 28 | + @Consume topRectHeight: number | ||
| 29 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 30 | + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | ||
| 31 | + @State barBackgroundColor: Color = Color.Transparent | ||
| 32 | + @Prop @Watch('indexChange') _currentNavIndex?: number; | ||
| 20 | // 顶导当前选中/焦点下标 | 33 | // 顶导当前选中/焦点下标 |
| 21 | - @State currentTopNavSelectedIndex: number = 0; | 34 | + @State @Watch('indexChange') currentTopNavSelectedIndex: number = 0; |
| 22 | // 顶导数据 | 35 | // 顶导数据 |
| 23 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 36 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 24 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 37 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| @@ -135,6 +148,40 @@ export struct TopNavigationComponent { | @@ -135,6 +148,40 @@ export struct TopNavigationComponent { | ||
| 135 | WDRouterRule.jumpWithAction(taskAction) | 148 | WDRouterRule.jumpWithAction(taskAction) |
| 136 | } | 149 | } |
| 137 | 150 | ||
| 151 | + indexChange() { | ||
| 152 | + if (this._currentNavIndex === 2 && this.currentTopNavSelectedIndex === 0 && this.changeBarBackgroundColor) { | ||
| 153 | + this.barBackgroundColor = Color.Black | ||
| 154 | + this.changeBarBackgroundColor(this.barBackgroundColor) | ||
| 155 | + } else { | ||
| 156 | + this.barBackgroundColor = Color.Transparent | ||
| 157 | + this.changeBarBackgroundColor(this.barBackgroundColor) | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + if (this._currentNavIndex === 2 && this.currentTopNavSelectedIndex == 0) { | ||
| 161 | + if (!this.isLayoutFullScreen) { | ||
| 162 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 163 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 164 | + windowClass.setWindowLayoutFullScreen(true).then(() => { | ||
| 165 | + this.isLayoutFullScreen = true | ||
| 166 | + this.bottomRectHeight = this.bottomSafeHeight | ||
| 167 | + this.topRectHeight = this.topSafeHeight | ||
| 168 | + }) | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + } else { | ||
| 172 | + if (this.isLayoutFullScreen) { | ||
| 173 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 174 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 175 | + windowClass.setWindowLayoutFullScreen(false).then(() => { | ||
| 176 | + this.isLayoutFullScreen = false | ||
| 177 | + this.bottomRectHeight = 0 | ||
| 178 | + this.topRectHeight = 0 | ||
| 179 | + console.error(' this.isLayoutFullScreen ', this.isLayoutFullScreen) | ||
| 180 | + }) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 138 | build() { | 185 | build() { |
| 139 | Column() { | 186 | Column() { |
| 140 | // 顶部搜索、日报logo、早晚报 | 187 | // 顶部搜索、日报logo、早晚报 |
| @@ -145,7 +192,7 @@ export struct TopNavigationComponent { | @@ -145,7 +192,7 @@ export struct TopNavigationComponent { | ||
| 145 | Image($r('app.media.icon_ren_min_ri_bao')) | 192 | Image($r('app.media.icon_ren_min_ri_bao')) |
| 146 | .width(72) | 193 | .width(72) |
| 147 | .height(29) | 194 | .height(29) |
| 148 | - .onClick(()=>{ | 195 | + .onClick(() => { |
| 149 | this.jumpToENewPaper() | 196 | this.jumpToENewPaper() |
| 150 | }) | 197 | }) |
| 151 | Stack({ alignContent: Alignment.Center }) { | 198 | Stack({ alignContent: Alignment.Center }) { |
| @@ -194,16 +241,20 @@ export struct TopNavigationComponent { | @@ -194,16 +241,20 @@ export struct TopNavigationComponent { | ||
| 194 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 241 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 195 | navIndex: index, | 242 | navIndex: index, |
| 196 | pageId: navItem.pageId + '', | 243 | pageId: navItem.pageId + '', |
| 197 | - channelId: navItem.channelId + '' | 244 | + channelId: navItem.channelId + '', |
| 245 | + name: navItem.name | ||
| 198 | }) | 246 | }) |
| 199 | } | 247 | } |
| 200 | } | 248 | } |
| 201 | .tabBar(this.tabBarBuilder(navItem, index)) | 249 | .tabBar(this.tabBarBuilder(navItem, index)) |
| 250 | + | ||
| 202 | }, (navItem: TopNavDTO) => JSON.stringify(navItem)); | 251 | }, (navItem: TopNavDTO) => JSON.stringify(navItem)); |
| 203 | } | 252 | } |
| 204 | .barHeight($r('app.float.top_tab_bar_height')) | 253 | .barHeight($r('app.float.top_tab_bar_height')) |
| 205 | .barMode(BarMode.Scrollable) | 254 | .barMode(BarMode.Scrollable) |
| 206 | .vertical(false) | 255 | .vertical(false) |
| 256 | + // item.name === '视频' && this.currentTopNavSelectedIndex === 0 ? | ||
| 257 | + .barBackgroundColor(this.barBackgroundColor) | ||
| 207 | .onChange((index: number) => { | 258 | .onChange((index: number) => { |
| 208 | Logger.info(TAG, `onChange index : ${index}`); | 259 | Logger.info(TAG, `onChange index : ${index}`); |
| 209 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 260 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| @@ -245,7 +296,21 @@ export struct TopNavigationComponent { | @@ -245,7 +296,21 @@ export struct TopNavigationComponent { | ||
| 245 | }) | 296 | }) |
| 246 | } | 297 | } |
| 247 | } | 298 | } |
| 299 | + } | ||
| 300 | + } | ||
| 248 | 301 | ||
| 302 | + /** | ||
| 303 | + * TODO:更详细的判断视频频道 | ||
| 304 | + */ | ||
| 305 | + getFontColor(item: TopNavDTO, index: number): Color | string { | ||
| 306 | + if (this._currentNavIndex === 2) { | ||
| 307 | + if (this.currentTopNavSelectedIndex == 0) { | ||
| 308 | + return item.name === '视频' ? Color.White : '#e5e0e0' | ||
| 309 | + } else { | ||
| 310 | + return this.currentTopNavSelectedIndex === index ? Color.Black : Color.Gray | ||
| 311 | + } | ||
| 312 | + } else { | ||
| 313 | + return this.currentTopNavSelectedIndex === index ? Color.Black : Color.Gray | ||
| 249 | } | 314 | } |
| 250 | } | 315 | } |
| 251 | 316 | ||
| @@ -255,7 +320,7 @@ export struct TopNavigationComponent { | @@ -255,7 +320,7 @@ export struct TopNavigationComponent { | ||
| 255 | Text(item.name) | 320 | Text(item.name) |
| 256 | .fontSize(this.currentTopNavSelectedIndex === index ? $r('app.float.selected_text_size') : $r('app.float.normal_text_size')) | 321 | .fontSize(this.currentTopNavSelectedIndex === index ? $r('app.float.selected_text_size') : $r('app.float.normal_text_size')) |
| 257 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) | 322 | .fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal) |
| 258 | - .fontColor(Color.Black) | 323 | + .fontColor(this.getFontColor(item, index)) |
| 259 | .padding({ top: $r('app.float.top_tab_item_padding_top') }) | 324 | .padding({ top: $r('app.float.top_tab_item_padding_top') }) |
| 260 | .maxLines(this.MAX_LINE) | 325 | .maxLines(this.MAX_LINE) |
| 261 | Divider() | 326 | Divider() |
| @@ -271,7 +336,7 @@ export struct TopNavigationComponent { | @@ -271,7 +336,7 @@ export struct TopNavigationComponent { | ||
| 271 | maxWidth: $r('app.float.top_tab_item_max_width') | 336 | maxWidth: $r('app.float.top_tab_item_max_width') |
| 272 | }) | 337 | }) |
| 273 | // .margin({ right: 36 }) | 338 | // .margin({ right: 36 }) |
| 274 | - // .backgroundColor(Color.Black) | 339 | + .backgroundColor(Color.Transparent) |
| 275 | .padding({ | 340 | .padding({ |
| 276 | left: $r('app.float.top_tab_item_padding_horizontal'), | 341 | left: $r('app.float.top_tab_item_padding_horizontal'), |
| 277 | right: $r('app.float.top_tab_item_padding_horizontal'), | 342 | right: $r('app.float.top_tab_item_padding_horizontal'), |
| 1 | export { DetailPlayShortVideoPage } from './src/main/ets/pages/DetailPlayShortVideoPage' | 1 | export { DetailPlayShortVideoPage } from './src/main/ets/pages/DetailPlayShortVideoPage' |
| 2 | + | ||
| 3 | +export { DetailVideoListPage } from './src/main/ets/pages/DetailVideoListPage' | ||
| 4 | + | ||
| 5 | +export { VideoChannelDetail } from './src/main/ets/pages/VideoChannelDetail' | ||
| 6 | + | ||
| 7 | +export { LottieViewDemo } from './src/main/ets/pages/LottieViewDemo' |
| @@ -14,6 +14,6 @@ | @@ -14,6 +14,6 @@ | ||
| 14 | "wdRouter": "file:../../commons/wdRouter", | 14 | "wdRouter": "file:../../commons/wdRouter", |
| 15 | "wdNetwork": "file:../../commons/wdNetwork", | 15 | "wdNetwork": "file:../../commons/wdNetwork", |
| 16 | "wdDetailPlayApi": "file:../../features/wdDetailPlayApi", | 16 | "wdDetailPlayApi": "file:../../features/wdDetailPlayApi", |
| 17 | - "wdComponent": "file:../../features/wdComponent" | 17 | + // "wdComponent": "file:../../features/wdComponent" |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| @@ -140,6 +140,7 @@ export struct DetailPlayShortVideoPage { | @@ -140,6 +140,7 @@ export struct DetailPlayShortVideoPage { | ||
| 140 | 140 | ||
| 141 | aboutToDisappear(): void { | 141 | aboutToDisappear(): void { |
| 142 | console.log('aboutToDisappear', this.index) | 142 | console.log('aboutToDisappear', this.index) |
| 143 | + this.playerController?.pause() | ||
| 143 | this.playerController?.release(); | 144 | this.playerController?.release(); |
| 144 | // this.playerController.onCanplay = ()={} | 145 | // this.playerController.onCanplay = ()={} |
| 145 | } | 146 | } |
| @@ -160,7 +161,7 @@ export struct DetailPlayShortVideoPage { | @@ -160,7 +161,7 @@ export struct DetailPlayShortVideoPage { | ||
| 160 | // console.log('onload==', this.index) | 161 | // console.log('onload==', this.index) |
| 161 | // if (this.index === 0) { | 162 | // if (this.index === 0) { |
| 162 | 163 | ||
| 163 | - if(this.contentDetailData!=null && this.contentDetailData?.videoInfo[0]!=null){ | 164 | + if (this.contentDetailData != null && this.contentDetailData?.videoInfo[0] != null) { |
| 164 | this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl); | 165 | this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl); |
| 165 | } | 166 | } |
| 166 | // } | 167 | // } |
| @@ -211,5 +212,7 @@ export struct DetailPlayShortVideoPage { | @@ -211,5 +212,7 @@ export struct DetailPlayShortVideoPage { | ||
| 211 | .height('100%') | 212 | .height('100%') |
| 212 | .width('100%') | 213 | .width('100%') |
| 213 | .backgroundColor(Color.Black) | 214 | .backgroundColor(Color.Black) |
| 215 | + // 扩展至所有非安全区域 | ||
| 216 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 214 | } | 217 | } |
| 215 | } | 218 | } |
| @@ -2,15 +2,18 @@ import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index'; | @@ -2,15 +2,18 @@ import { Action, ContentDetailDTO, InteractDataDTO } from 'wdBean/Index'; | ||
| 2 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | 2 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' |
| 3 | import { ResponseDTO } from 'wdNetwork/Index'; | 3 | import { ResponseDTO } from 'wdNetwork/Index'; |
| 4 | import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' | 4 | import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage' |
| 5 | -import { Test } from './Test' | ||
| 6 | import router from '@ohos.router'; | 5 | import router from '@ohos.router'; |
| 7 | -import window from '@ohos.window'; | ||
| 8 | import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | 6 | import { contentListParams } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; |
| 7 | +import window from '@ohos.window'; | ||
| 8 | +import { WindowModel } from 'wdKit'; | ||
| 9 | 9 | ||
| 10 | +const storage = LocalStorage.getShared(); | ||
| 10 | 11 | ||
| 11 | -@Entry | 12 | +@Entry(storage) |
| 12 | @Component | 13 | @Component |
| 13 | export struct DetailVideoListPage { | 14 | export struct DetailVideoListPage { |
| 15 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 16 | + @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | ||
| 14 | private contentId: string = '' | 17 | private contentId: string = '' |
| 15 | private relId: string = '' | 18 | private relId: string = '' |
| 16 | private relType: string = '' | 19 | private relType: string = '' |
| @@ -21,6 +24,14 @@ export struct DetailVideoListPage { | @@ -21,6 +24,14 @@ export struct DetailVideoListPage { | ||
| 21 | @State interactDataList: InteractDataDTO[] = [] | 24 | @State interactDataList: InteractDataDTO[] = [] |
| 22 | 25 | ||
| 23 | async aboutToAppear(): Promise<void> { | 26 | async aboutToAppear(): Promise<void> { |
| 27 | + | ||
| 28 | + | ||
| 29 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 30 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 31 | + windowClass.setWindowLayoutFullScreen(true) | ||
| 32 | + windowClass.setWindowSystemBarProperties({ statusBarColor: '#fff' }) | ||
| 33 | + | ||
| 34 | + | ||
| 24 | let data: ContentDetailDTO[] = [] | 35 | let data: ContentDetailDTO[] = [] |
| 25 | let action: Action = router.getParams() as Action | 36 | let action: Action = router.getParams() as Action |
| 26 | if (action) { | 37 | if (action) { |
| @@ -83,6 +94,15 @@ export struct DetailVideoListPage { | @@ -83,6 +94,15 @@ export struct DetailVideoListPage { | ||
| 83 | 94 | ||
| 84 | } | 95 | } |
| 85 | 96 | ||
| 97 | + aboutToDisappear(): void { | ||
| 98 | + | ||
| 99 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 100 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 101 | + windowClass.setWindowLayoutFullScreen(false) | ||
| 102 | + windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' }) | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + | ||
| 86 | /** | 106 | /** |
| 87 | * 查询视频列表用于翻页 | 107 | * 查询视频列表用于翻页 |
| 88 | */ | 108 | */ |
| @@ -112,16 +132,17 @@ export struct DetailVideoListPage { | @@ -112,16 +132,17 @@ export struct DetailVideoListPage { | ||
| 112 | }) | 132 | }) |
| 113 | }.width('100%') | 133 | }.width('100%') |
| 114 | .height('100%') | 134 | .height('100%') |
| 135 | + // 扩展至所有非安全区域 | ||
| 136 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 115 | }, (item: ContentDetailDTO) => item.newsId + '') | 137 | }, (item: ContentDetailDTO) => item.newsId + '') |
| 116 | } | 138 | } |
| 139 | + .clip(false) | ||
| 117 | .cachedCount(-1) | 140 | .cachedCount(-1) |
| 118 | .indicator(false) | 141 | .indicator(false) |
| 119 | .vertical(true) | 142 | .vertical(true) |
| 120 | .loop(false) | 143 | .loop(false) |
| 121 | .width('100%') | 144 | .width('100%') |
| 122 | .height('100%') | 145 | .height('100%') |
| 123 | - // 扩展至所有非安全区域 | ||
| 124 | - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 125 | .onChange((index: number) => { | 146 | .onChange((index: number) => { |
| 126 | this.currentIndex = index | 147 | this.currentIndex = index |
| 127 | console.info('onChange==', index.toString()) | 148 | console.info('onChange==', index.toString()) |
| @@ -130,7 +151,6 @@ export struct DetailVideoListPage { | @@ -130,7 +151,6 @@ export struct DetailVideoListPage { | ||
| 130 | this.queryVideoList() | 151 | this.queryVideoList() |
| 131 | } | 152 | } |
| 132 | }) | 153 | }) |
| 133 | - | ||
| 134 | - }.width('100%').height('100%') | 154 | + }.width('100%').height('100%').backgroundColor(Color.Black).padding({ bottom: this.bottomSafeHeight + 'px' }) |
| 135 | } | 155 | } |
| 136 | } | 156 | } |
| 1 | import { AnimationItem } from '@ohos/lottie' | 1 | import { AnimationItem } from '@ohos/lottie' |
| 2 | -import { LottieView } from 'wdComponent/Index' | 2 | + |
| 3 | +// import { LottieView } from 'wdComponent/Index' | ||
| 3 | 4 | ||
| 4 | 5 | ||
| 5 | @Component | 6 | @Component |
| @@ -16,16 +17,16 @@ export struct LottieViewDemo { | @@ -16,16 +17,16 @@ export struct LottieViewDemo { | ||
| 16 | .fontColor(Color.White) | 17 | .fontColor(Color.White) |
| 17 | .borderRadius(10) | 18 | .borderRadius(10) |
| 18 | .fontWeight(500) | 19 | .fontWeight(500) |
| 19 | - LottieView({ | ||
| 20 | - name: 'lottieDemo', | ||
| 21 | - path: 'common/lottie/politeChicky.json', | ||
| 22 | - onReady: (animateItem: AnimationItem | null) => { | ||
| 23 | - this.animateItem = animateItem | ||
| 24 | - }, | ||
| 25 | - onComplete: () => { | ||
| 26 | - console.log('onComplete===') | ||
| 27 | - } | ||
| 28 | - }) | 20 | + // LottieView({ |
| 21 | + // name: 'lottieDemo', | ||
| 22 | + // path: 'common/lottie/politeChicky.json', | ||
| 23 | + // onReady: (animateItem: AnimationItem | null) => { | ||
| 24 | + // this.animateItem = animateItem | ||
| 25 | + // }, | ||
| 26 | + // onComplete: () => { | ||
| 27 | + // console.log('onComplete===') | ||
| 28 | + // } | ||
| 29 | + // }) | ||
| 29 | } | 30 | } |
| 30 | .width(200) | 31 | .width(200) |
| 31 | .height(200) | 32 | .height(200) |
| @@ -20,26 +20,26 @@ export struct VideoChannelDetail { | @@ -20,26 +20,26 @@ export struct VideoChannelDetail { | ||
| 20 | @State interactDataList: InteractDataDTO[] = [] | 20 | @State interactDataList: InteractDataDTO[] = [] |
| 21 | 21 | ||
| 22 | async aboutToAppear(): Promise<void> { | 22 | async aboutToAppear(): Promise<void> { |
| 23 | - let data: ContentDetailDTO[] = [] | ||
| 24 | - let action: Action = router.getParams() as Action | ||
| 25 | - if (action) { | ||
| 26 | - this.contentId = action.params?.contentID || '' | ||
| 27 | - if (action.params && action.params.extra) { | ||
| 28 | - this.relId = action.params.extra.relId || '' | ||
| 29 | - this.relType = action.params.extra.relType || '' | ||
| 30 | - } | ||
| 31 | - await ContentDetailRequest.getContentDetail({ | ||
| 32 | - contentId: this.contentId, | ||
| 33 | - relId: this.relId, | ||
| 34 | - relType: this.relType | ||
| 35 | - }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => { | ||
| 36 | - console.error('resDTO==', JSON.stringify(resDTO.data)) | ||
| 37 | - if (resDTO.data) { | ||
| 38 | - this.data.push(resDTO.data[0]) | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - }) | ||
| 42 | - } | 23 | + // let data: ContentDetailDTO[] = [] |
| 24 | + // let action: Action = router.getParams() as Action | ||
| 25 | + // if (action) { | ||
| 26 | + // this.contentId = action.params?.contentID || '' | ||
| 27 | + // if (action.params && action.params.extra) { | ||
| 28 | + // this.relId = action.params.extra.relId || '' | ||
| 29 | + // this.relType = action.params.extra.relType || '' | ||
| 30 | + // } | ||
| 31 | + // await ContentDetailRequest.getContentDetail({ | ||
| 32 | + // contentId: this.contentId, | ||
| 33 | + // relId: this.relId, | ||
| 34 | + // relType: this.relType | ||
| 35 | + // }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => { | ||
| 36 | + // console.error('resDTO==', JSON.stringify(resDTO.data)) | ||
| 37 | + // if (resDTO.data) { | ||
| 38 | + // this.data.push(resDTO.data[0]) | ||
| 39 | + // } | ||
| 40 | + // | ||
| 41 | + // }) | ||
| 42 | + // } | ||
| 43 | 43 | ||
| 44 | await this.queryVideoList() | 44 | await this.queryVideoList() |
| 45 | 45 | ||
| @@ -97,10 +97,17 @@ export struct VideoChannelDetail { | @@ -97,10 +97,17 @@ export struct VideoChannelDetail { | ||
| 97 | }) | 97 | }) |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | + aboutToDisappear(): void { | ||
| 101 | + | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + onPageHide(): void { | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 100 | build() { | 108 | build() { |
| 101 | Column() { | 109 | Column() { |
| 102 | Swiper(this.swiperController) { | 110 | Swiper(this.swiperController) { |
| 103 | - | ||
| 104 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { | 111 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { |
| 105 | Column() { | 112 | Column() { |
| 106 | DetailPlayShortVideoPage({ | 113 | DetailPlayShortVideoPage({ |
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | "wdKit": "file:../../commons/wdKit", | 12 | "wdKit": "file:../../commons/wdKit", |
| 13 | "wdWebComponent": "file:../../commons/wdWebComponent", | 13 | "wdWebComponent": "file:../../commons/wdWebComponent", |
| 14 | "wdBean": "file:../../features/wdBean", | 14 | "wdBean": "file:../../features/wdBean", |
| 15 | + "wdDetailPlayShortVideo": "file:../../features/wdDetailPlayShortVideo", | ||
| 15 | "wdRouter": "file:../../commons/wdRouter", | 16 | "wdRouter": "file:../../commons/wdRouter", |
| 16 | "wdNetwork": "file:../../commons/wdNetwork" | 17 | "wdNetwork": "file:../../commons/wdNetwork" |
| 17 | } | 18 | } |
| @@ -23,6 +23,18 @@ export default class EntryAbility extends UIAbility { | @@ -23,6 +23,18 @@ export default class EntryAbility extends UIAbility { | ||
| 23 | // Main window is created, set main page for this ability | 23 | // Main window is created, set main page for this ability |
| 24 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); | 24 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); |
| 25 | WindowModel.shared.setWindowStage(windowStage); | 25 | WindowModel.shared.setWindowStage(windowStage); |
| 26 | + // 2. 获取布局避让遮挡的区域 | ||
| 27 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 28 | + const TYPE_NAVIGATION_INDICATOR = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; // 以导航条避让为例 | ||
| 29 | + const TYPE_SYSTEM = window.AvoidAreaType.TYPE_SYSTEM; // 以导航条避让为例 | ||
| 30 | + const NAV_AREA = windowClass.getWindowAvoidArea(TYPE_NAVIGATION_INDICATOR); | ||
| 31 | + const SYSTEM_AREA = windowClass.getWindowAvoidArea(TYPE_SYSTEM); | ||
| 32 | + const bottomSafeHeight = NAV_AREA.bottomRect.height; // 获取到导航条区域的高度 | ||
| 33 | + const topSafeHeight = SYSTEM_AREA.topRect.height; // 获取到状态栏区域的高度 | ||
| 34 | + AppStorage.setOrCreate('bottomSafeHeight', bottomSafeHeight); | ||
| 35 | + AppStorage.setOrCreate('topSafeHeight', topSafeHeight); | ||
| 36 | + | ||
| 37 | + | ||
| 26 | // let a = new WindowModel(); | 38 | // let a = new WindowModel(); |
| 27 | // 设置窗口的显示方向属性 | 39 | // 设置窗口的显示方向属性 |
| 28 | WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT) | 40 | WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT) |
-
Please register or login to post a comment