Showing
2 changed files
with
51 additions
and
48 deletions
| @@ -59,7 +59,6 @@ export struct TopNavigationComponent { | @@ -59,7 +59,6 @@ export struct TopNavigationComponent { | ||
| 59 | @State autoRefresh2Page: number = 0 | 59 | @State autoRefresh2Page: number = 0 |
| 60 | // 当前底导index | 60 | // 当前底导index |
| 61 | @State navIndex: number = 0 | 61 | @State navIndex: number = 0 |
| 62 | - | ||
| 63 | @State animationDuration: number = 0 | 62 | @State animationDuration: number = 0 |
| 64 | @State indicatorLeftMargin: number = 0 | 63 | @State indicatorLeftMargin: number = 0 |
| 65 | @State indicatorWidth: number = 0 | 64 | @State indicatorWidth: number = 0 |
| @@ -93,7 +92,8 @@ export struct TopNavigationComponent { | @@ -93,7 +92,8 @@ export struct TopNavigationComponent { | ||
| 93 | 92 | ||
| 94 | //defaultMyChannelList | 93 | //defaultMyChannelList |
| 95 | defaultList.forEach(item => { | 94 | defaultList.forEach(item => { |
| 96 | - if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || item.headlinesOn === 1) { | 95 | + if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || |
| 96 | + item.headlinesOn === 1) { | ||
| 97 | defaultMyChannelList.push(item); | 97 | defaultMyChannelList.push(item); |
| 98 | } | 98 | } |
| 99 | if (item.defaultPermitted === 1) { | 99 | if (item.defaultPermitted === 1) { |
| @@ -169,7 +169,6 @@ export struct TopNavigationComponent { | @@ -169,7 +169,6 @@ export struct TopNavigationComponent { | ||
| 169 | return item.name === '版面' | 169 | return item.name === '版面' |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | - | ||
| 173 | build() { | 172 | build() { |
| 174 | Column() { | 173 | Column() { |
| 175 | // 顶部搜索、日报logo、早晚报 | 174 | // 顶部搜索、日报logo、早晚报 |
| @@ -216,51 +215,53 @@ export struct TopNavigationComponent { | @@ -216,51 +215,53 @@ export struct TopNavigationComponent { | ||
| 216 | // 频道分类list | 215 | // 频道分类list |
| 217 | Stack({ alignContent: Alignment.TopEnd }) { | 216 | Stack({ alignContent: Alignment.TopEnd }) { |
| 218 | Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) { | 217 | Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) { |
| 219 | - ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => { | ||
| 220 | - TabContent() { | ||
| 221 | - if (this.currentBottomNavName === '视频' && navItem.name === '视频') { | ||
| 222 | - VideoChannelDetail({ | ||
| 223 | - bottomNavIndex: $_currentNavIndex, | ||
| 224 | - topNavIndex: $currentTopNavSelectedIndex, | ||
| 225 | - groupId: this.groupId + '', | ||
| 226 | - pageId: navItem.pageId + '', | ||
| 227 | - channelId: navItem.channelId + '', | ||
| 228 | - }) | ||
| 229 | - } | ||
| 230 | - else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { | ||
| 231 | - PeopleShipMainComponent({ | ||
| 232 | - currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 233 | - navIndex: index, | ||
| 234 | - pageId: navItem.pageId + '', | ||
| 235 | - channelId: navItem.channelId + '', | ||
| 236 | - }) | ||
| 237 | - } | ||
| 238 | - else | ||
| 239 | - if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | ||
| 240 | - PageComponent({ | 218 | + ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, |
| 219 | + (navItem: TopNavDTO, index: number) => { | ||
| 220 | + TabContent() { | ||
| 221 | + if (this.currentBottomNavName === '视频' && navItem.name === '视频') { | ||
| 222 | + VideoChannelDetail({ | ||
| 223 | + bottomNavIndex: $_currentNavIndex, | ||
| 224 | + topNavIndex: $currentTopNavSelectedIndex, | ||
| 225 | + groupId: this.groupId + '', | ||
| 226 | + pageId: navItem.pageId + '', | ||
| 227 | + channelId: navItem.channelId + '', | ||
| 228 | + }) | ||
| 229 | + } else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { | ||
| 230 | + PeopleShipMainComponent({ | ||
| 241 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 231 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| 242 | navIndex: index, | 232 | navIndex: index, |
| 243 | pageId: navItem.pageId + '', | 233 | pageId: navItem.pageId + '', |
| 244 | channelId: navItem.channelId + '', | 234 | channelId: navItem.channelId + '', |
| 245 | - autoRefresh: this.autoRefresh2Page | ||
| 246 | }) | 235 | }) |
| 247 | - } | ||
| 248 | - } | ||
| 249 | - .tabBar(this.tabBarBuilder(navItem, index)) | 236 | + } else |
| 237 | + if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | ||
| 238 | + PageComponent({ | ||
| 239 | + currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | ||
| 240 | + navIndex: index, | ||
| 241 | + pageId: navItem.pageId + '', | ||
| 242 | + channelId: navItem.channelId + '', | ||
| 243 | + autoRefresh: this.autoRefresh2Page | ||
| 244 | + }) | ||
| 245 | + } | ||
| 246 | + } | ||
| 247 | + .tabBar(this.tabBarBuilder(navItem, index)) | ||
| 250 | 248 | ||
| 251 | - }, (navItem: TopNavDTO) => JSON.stringify(navItem)); | 249 | + }, (navItem: TopNavDTO) => JSON.stringify(navItem)); |
| 252 | } | 250 | } |
| 253 | .barHeight($r('app.float.top_tab_bar_height')) | 251 | .barHeight($r('app.float.top_tab_bar_height')) |
| 254 | .barMode(BarMode.Scrollable) | 252 | .barMode(BarMode.Scrollable) |
| 255 | .vertical(false) | 253 | .vertical(false) |
| 256 | .barBackgroundColor(this.barBackgroundColor) | 254 | .barBackgroundColor(this.barBackgroundColor) |
| 257 | - .onAreaChange((oldValue: Area,newValue: Area)=> { | 255 | + .backgroundColor(this.barBackgroundColor) |
| 256 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 257 | + .onAreaChange((oldValue: Area, newValue: Area) => { | ||
| 258 | let width = Number.parseFloat(newValue.width.toString()) | 258 | let width = Number.parseFloat(newValue.width.toString()) |
| 259 | this.tabsWidth = Number.isNaN(width) ? 0 : width | 259 | this.tabsWidth = Number.isNaN(width) ? 0 : width |
| 260 | }) | 260 | }) |
| 261 | .animationDuration(this.animationDuration) | 261 | .animationDuration(this.animationDuration) |
| 262 | .onChange((index: number) => { | 262 | .onChange((index: number) => { |
| 263 | - this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name | 263 | + this.currentTopNavName = |
| 264 | + this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name | ||
| 264 | Logger.info(TAG, `onChange index : ${index}`); | 265 | Logger.info(TAG, `onChange index : ${index}`); |
| 265 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 266 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| 266 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) | 267 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) |
| @@ -288,27 +289,27 @@ export struct TopNavigationComponent { | @@ -288,27 +289,27 @@ export struct TopNavigationComponent { | ||
| 288 | let targetIndexInfo = this.getTextInfo(targetIndex) | 289 | let targetIndexInfo = this.getTextInfo(targetIndex) |
| 289 | this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width) | 290 | this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width) |
| 290 | }) | 291 | }) |
| 291 | - .onAnimationEnd((index: number,event: TabsAnimationEvent) => { | 292 | + .onAnimationEnd((index: number, event: TabsAnimationEvent) => { |
| 292 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 293 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| 293 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) | 294 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) |
| 294 | ) { | 295 | ) { |
| 295 | return | 296 | return |
| 296 | } | 297 | } |
| 297 | - // 切换动画结束时触发该回调。下划线动画停止。 | ||
| 298 | - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event) | ||
| 299 | - this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width) | 298 | + // 切换动画结束时触发该回调。下划线动画停止。 |
| 299 | + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) | ||
| 300 | + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width) | ||
| 300 | }) | 301 | }) |
| 301 | - .onGestureSwipe((index: number,event: TabsAnimationEvent) => { | 302 | + .onGestureSwipe((index: number, event: TabsAnimationEvent) => { |
| 302 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && | 303 | if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && |
| 303 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) | 304 | !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) |
| 304 | ) { | 305 | ) { |
| 305 | return | 306 | return |
| 306 | } | 307 | } |
| 307 | - // 在页面跟手滑动过程中,逐帧触发该回调。 | ||
| 308 | - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event) | ||
| 309 | - this.currentTopNavSelectedIndex = currentIndicatorInfo.index | ||
| 310 | - this.indicatorLeftMargin = currentIndicatorInfo.left | ||
| 311 | - this.indicatorWidth = currentIndicatorInfo.width | 308 | + // 在页面跟手滑动过程中,逐帧触发该回调。 |
| 309 | + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event) | ||
| 310 | + this.currentTopNavSelectedIndex = currentIndicatorInfo.index | ||
| 311 | + this.indicatorLeftMargin = currentIndicatorInfo.left | ||
| 312 | + this.indicatorWidth = currentIndicatorInfo.width | ||
| 312 | }) | 313 | }) |
| 313 | 314 | ||
| 314 | // 分类列表最右侧频道设置 | 315 | // 分类列表最右侧频道设置 |
| @@ -351,8 +352,9 @@ export struct TopNavigationComponent { | @@ -351,8 +352,9 @@ export struct TopNavigationComponent { | ||
| 351 | .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) | 352 | .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) |
| 352 | .maxLines(this.MAX_LINE) | 353 | .maxLines(this.MAX_LINE) |
| 353 | .id(index.toString()) | 354 | .id(index.toString()) |
| 354 | - .onAreaChange((oldValue: Area,newValue: Area) => { | ||
| 355 | - if (this.currentTopNavSelectedIndex === index && (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)){ | 355 | + .onAreaChange((oldValue: Area, newValue: Area) => { |
| 356 | + if (this.currentTopNavSelectedIndex === index && | ||
| 357 | + (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)) { | ||
| 356 | if (newValue.position.x != undefined) { | 358 | if (newValue.position.x != undefined) { |
| 357 | let positionX = Number.parseFloat(newValue.position.x.toString()) | 359 | let positionX = Number.parseFloat(newValue.position.x.toString()) |
| 358 | this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX | 360 | this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX |
| @@ -396,7 +398,8 @@ export struct TopNavigationComponent { | @@ -396,7 +398,8 @@ export struct TopNavigationComponent { | ||
| 396 | } | 398 | } |
| 397 | 399 | ||
| 398 | onTopNavigationDataUpdated() { | 400 | onTopNavigationDataUpdated() { |
| 399 | - Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); | 401 | + Logger.info(TAG, |
| 402 | + `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); | ||
| 400 | } | 403 | } |
| 401 | 404 | ||
| 402 | onAutoRefresh() { | 405 | onAutoRefresh() { |
| @@ -505,7 +508,7 @@ export struct TopNavigationComponent { | @@ -505,7 +508,7 @@ export struct TopNavigationComponent { | ||
| 505 | let indexInfo = this.getTextInfo(index) | 508 | let indexInfo = this.getTextInfo(index) |
| 506 | let nextIndexInfo = this.getTextInfo(nextIndex) | 509 | let nextIndexInfo = this.getTextInfo(nextIndex) |
| 507 | let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) | 510 | let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth) |
| 508 | - let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 | 511 | + let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。 |
| 509 | let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio | 512 | let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio |
| 510 | let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio | 513 | let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio |
| 511 | return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } | 514 | return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth } |
| @@ -101,7 +101,7 @@ export struct VideoChannelDetail { | @@ -101,7 +101,7 @@ export struct VideoChannelDetail { | ||
| 101 | openFullScreen() { | 101 | openFullScreen() { |
| 102 | WindowModel.shared.setWindowSystemBarProperties({ | 102 | WindowModel.shared.setWindowSystemBarProperties({ |
| 103 | statusBarContentColor: '#ffffff', | 103 | statusBarContentColor: '#ffffff', |
| 104 | - statusBarColor: '#000000', | 104 | + // statusBarColor: '#000000', |
| 105 | // navigationBarColor: '#000000', | 105 | // navigationBarColor: '#000000', |
| 106 | // navigationBarContentColor: '#ffffff' | 106 | // navigationBarContentColor: '#ffffff' |
| 107 | }) | 107 | }) |
| @@ -116,7 +116,7 @@ export struct VideoChannelDetail { | @@ -116,7 +116,7 @@ export struct VideoChannelDetail { | ||
| 116 | closeFullScreen() { | 116 | closeFullScreen() { |
| 117 | WindowModel.shared.setWindowSystemBarProperties({ | 117 | WindowModel.shared.setWindowSystemBarProperties({ |
| 118 | statusBarContentColor: '#000000', | 118 | statusBarContentColor: '#000000', |
| 119 | - statusBarColor: '#ffffff', | 119 | + // statusBarColor: '#ffffff', |
| 120 | // navigationBarColor: '#0x66000000', | 120 | // navigationBarColor: '#0x66000000', |
| 121 | // navigationBarContentColor: '#0xE5FFFFFF' | 121 | // navigationBarContentColor: '#0xE5FFFFFF' |
| 122 | 122 |
-
Please register or login to post a comment