liyubing

fix:

1)修改顶导UI布局
@@ -113,7 +113,7 @@ export struct TopNavigationComponentNew { @@ -113,7 +113,7 @@ export struct TopNavigationComponentNew {
113 'middle': { 'anchor': '__container__', 'align': HorizontalAlign.Center }, 113 'middle': { 'anchor': '__container__', 'align': HorizontalAlign.Center },
114 'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom } 114 'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom }
115 }) 115 })
116 - .onAnimationStart((curIndex: number, index: number)=>{ 116 + .onAnimationStart((curIndex: number, index: number) => {
117 Logger.info(TAG, `onAnimationStart ${curIndex} ${index}`); 117 Logger.info(TAG, `onAnimationStart ${curIndex} ${index}`);
118 if (curIndex === index) { 118 if (curIndex === index) {
119 return 119 return
@@ -233,7 +233,7 @@ export struct TopNavigationComponentNew { @@ -233,7 +233,7 @@ export struct TopNavigationComponentNew {
233 .listDirection(Axis.Horizontal) 233 .listDirection(Axis.Horizontal)
234 .scrollBar(BarState.Off) 234 .scrollBar(BarState.Off)
235 .edgeEffect(EdgeEffect.None) 235 .edgeEffect(EdgeEffect.None)
236 - .padding({ left: 8, top: 6, right: 0 }) 236 + .padding({ left: 8, top:0, right: 0 })
237 .height($r('app.float.top_tab_bar_height')) 237 .height($r('app.float.top_tab_bar_height'))
238 .backgroundColor(this.barBackgroundColor) 238 .backgroundColor(this.barBackgroundColor)
239 .onAreaChange((oldValue: Area, newValue: Area) => { 239 .onAreaChange((oldValue: Area, newValue: Area) => {
@@ -278,13 +278,12 @@ export struct TopNavigationComponentNew { @@ -278,13 +278,12 @@ export struct TopNavigationComponentNew {
278 .listDirection(Axis.Horizontal) 278 .listDirection(Axis.Horizontal)
279 .scrollBar(BarState.Off) 279 .scrollBar(BarState.Off)
280 .edgeEffect(EdgeEffect.None) 280 .edgeEffect(EdgeEffect.None)
281 - .height($r('app.float.top_tab_bar_height_common'))  
282 - .backgroundColor(this.barBackgroundColor)  
283 - .margin({ top: 10 })  
284 .onAreaChange((oldValue: Area, newValue: Area) => { 281 .onAreaChange((oldValue: Area, newValue: Area) => {
285 let width = Number.parseFloat(newValue.width.toString()) 282 let width = Number.parseFloat(newValue.width.toString())
286 this.tabsWidth = Number.isNaN(width) ? 0 : width 283 this.tabsWidth = Number.isNaN(width) ? 0 : width
287 }) 284 })
  285 + .height($r('app.float.top_tab_bar_height_common'))
  286 + .backgroundColor(this.barBackgroundColor)
288 .id('tabList') 287 .id('tabList')
289 .alignRules({ 288 .alignRules({
290 'top': { 'anchor': '__container__', 'align': VerticalAlign.Top }, 289 'top': { 'anchor': '__container__', 'align': VerticalAlign.Top },
@@ -327,12 +326,13 @@ export struct TopNavigationComponentNew { @@ -327,12 +326,13 @@ export struct TopNavigationComponentNew {
327 minWidth: $r('app.float.top_tab_item_min_width'), 326 minWidth: $r('app.float.top_tab_item_min_width'),
328 maxWidth: $r('app.float.top_tab_item_max_width') 327 maxWidth: $r('app.float.top_tab_item_max_width')
329 }) 328 })
  329 + .height('100%')
330 // .backgroundColor(Color.Transparent) 330 // .backgroundColor(Color.Transparent)
331 .padding({ 331 .padding({
332 left: $r('app.float.top_tab_item_padding_horizontal'), 332 left: $r('app.float.top_tab_item_padding_horizontal'),
333 right: $r('app.float.top_tab_item_padding_horizontal'), 333 right: $r('app.float.top_tab_item_padding_horizontal'),
334 - bottom: 2,  
335 }) 334 })
  335 + .justifyContent(FlexAlign.Center)
336 .id(`col_tabBar${index}`) 336 .id(`col_tabBar${index}`)
337 // .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 }) 337 // .margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 })
338 .onClick(() => { 338 .onClick(() => {
@@ -497,7 +497,7 @@ export struct TopNavigationComponentNew { @@ -497,7 +497,7 @@ export struct TopNavigationComponentNew {
497 Logger.info(TAG, `currentTopNavSelectedIndex : ${this.currentTopNavSelectedIndex}、${this.currentBottomNavName}`); 497 Logger.info(TAG, `currentTopNavSelectedIndex : ${this.currentTopNavSelectedIndex}、${this.currentBottomNavName}`);
498 498
499 // 顶部tab埋点 499 // 顶部tab埋点
500 - if(this.currentBottomNavName === '新闻') { 500 + if (this.currentBottomNavName === '新闻') {
501 const tab = this.myChannelList[this.currentTopNavSelectedIndex] 501 const tab = this.myChannelList[this.currentTopNavSelectedIndex]
502 Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`); 502 Logger.info(TAG, `新闻tab埋点: ${JSON.stringify(tab)}`);
503 503
@@ -507,7 +507,7 @@ export struct TopNavigationComponentNew { @@ -507,7 +507,7 @@ export struct TopNavigationComponentNew {
507 "pageId": tab.pageId, 507 "pageId": tab.pageId,
508 } 508 }
509 Tracking.event("home_page_tab_click ", params) 509 Tracking.event("home_page_tab_click ", params)
510 - } else if(this.currentBottomNavName === '人民号') { 510 + } else if (this.currentBottomNavName === '人民号') {
511 const tab = this.topNavList[this.currentTopNavSelectedIndex] 511 const tab = this.topNavList[this.currentTopNavSelectedIndex]
512 Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`); 512 Logger.info(TAG, `人民号tab埋点: ${JSON.stringify(tab)}`);
513 513
@@ -519,6 +519,7 @@ export struct TopNavigationComponentNew { @@ -519,6 +519,7 @@ export struct TopNavigationComponentNew {
519 Tracking.event("People_account_page_tab_click", params) 519 Tracking.event("People_account_page_tab_click", params)
520 } 520 }
521 } 521 }
  522 +
522 onAutoRefresh() { 523 onAutoRefresh() {
523 if (this.bottomNavIndex != this._currentNavIndex) { 524 if (this.bottomNavIndex != this._currentNavIndex) {
524 return 525 return
@@ -619,32 +620,32 @@ export struct TopNavigationComponentNew { @@ -619,32 +620,32 @@ export struct TopNavigationComponentNew {
619 return null 620 return null
620 } 621 }
621 622
622 - private getTextInfo(index: number): Record<string, number> {  
623 - let strJson = getInspectorByKey(index.toString())  
624 - try {  
625 - let obj: Record<string, string> = JSON.parse(strJson)  
626 - let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']')  
627 - return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) }  
628 - } catch (error) {  
629 - return { 'left': 0, 'width': 0 }  
630 - }  
631 - }  
632 -  
633 - private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> {  
634 - let nextIndex = index  
635 - if (index > 0 && event.currentOffset > 0) {  
636 - nextIndex--  
637 - } else if (index < 3 && event.currentOffset < 0) {  
638 - nextIndex++  
639 - }  
640 - let indexInfo = this.getTextInfo(index)  
641 - let nextIndexInfo = this.getTextInfo(nextIndex)  
642 - let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)  
643 - let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。  
644 - let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio  
645 - let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio  
646 - return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }  
647 - } 623 + // private getTextInfo(index: number): Record<string, number> {
  624 + // let strJson = getInspectorByKey(index.toString())
  625 + // try {
  626 + // let obj: Record<string, string> = JSON.parse(strJson)
  627 + // let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']')
  628 + // return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) }
  629 + // } catch (error) {
  630 + // return { 'left': 0, 'width': 0 }
  631 + // }
  632 + // }
  633 +
  634 + // private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> {
  635 + // let nextIndex = index
  636 + // if (index > 0 && event.currentOffset > 0) {
  637 + // nextIndex--
  638 + // } else if (index < 3 && event.currentOffset < 0) {
  639 + // nextIndex++
  640 + // }
  641 + // let indexInfo = this.getTextInfo(index)
  642 + // let nextIndexInfo = this.getTextInfo(nextIndex)
  643 + // let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)
  644 + // let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。
  645 + // let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio
  646 + // let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio
  647 + // return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }
  648 + // }
648 649
649 private startAnimateTo(duration: number, leftMargin: number, width: number) { 650 private startAnimateTo(duration: number, leftMargin: number, width: number) {
650 animateTo({ 651 animateTo({