Showing
3 changed files
with
42 additions
and
11 deletions
| @@ -96,10 +96,10 @@ export struct RmhTitle { | @@ -96,10 +96,10 @@ export struct RmhTitle { | ||
| 96 | build() { | 96 | build() { |
| 97 | Flex() { | 97 | Flex() { |
| 98 | Stack() { | 98 | Stack() { |
| 99 | - Image(this.rmhInfo.rmhHeadUrl) | 99 | + Image(this.rmhInfo?.rmhHeadUrl) |
| 100 | .width(36) | 100 | .width(36) |
| 101 | .height(36).borderRadius(50) | 101 | .height(36).borderRadius(50) |
| 102 | - Image(this.rmhInfo.authIcon) | 102 | + Image(this.rmhInfo?.authIcon) |
| 103 | .width(14) | 103 | .width(14) |
| 104 | .height(14) | 104 | .height(14) |
| 105 | .borderRadius(50) | 105 | .borderRadius(50) |
| @@ -109,7 +109,7 @@ export struct RmhTitle { | @@ -109,7 +109,7 @@ export struct RmhTitle { | ||
| 109 | .flexShrink(0) | 109 | .flexShrink(0) |
| 110 | 110 | ||
| 111 | Column() { | 111 | Column() { |
| 112 | - Text(this.rmhInfo.rmhName) | 112 | + Text(this.rmhInfo?.rmhName) |
| 113 | .fontSize($r('app.float.font_size_13')) | 113 | .fontSize($r('app.float.font_size_13')) |
| 114 | .fontColor($r('app.color.color_222222')) | 114 | .fontColor($r('app.color.color_222222')) |
| 115 | .fontWeight(600) | 115 | .fontWeight(600) |
| @@ -122,13 +122,13 @@ export struct RmhTitle { | @@ -122,13 +122,13 @@ export struct RmhTitle { | ||
| 122 | .fontSize($r("app.float.font_size_12")) | 122 | .fontSize($r("app.float.font_size_12")) |
| 123 | .fontColor($r("app.color.color_B0B0B0")) | 123 | .fontColor($r("app.color.color_B0B0B0")) |
| 124 | } | 124 | } |
| 125 | - if (this.publishTime && this.rmhInfo.rmhDesc) { | 125 | + if (this.publishTime && this.rmhInfo?.rmhDesc) { |
| 126 | Image($r('app.media.point')) | 126 | Image($r('app.media.point')) |
| 127 | .width(16) | 127 | .width(16) |
| 128 | .height(16) | 128 | .height(16) |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | - Text(this.rmhInfo.rmhDesc) | 131 | + Text(this.rmhInfo?.rmhDesc) |
| 132 | .fontSize($r("app.float.font_size_12")) | 132 | .fontSize($r("app.float.font_size_12")) |
| 133 | .fontColor($r("app.color.color_B0B0B0")) | 133 | .fontColor($r("app.color.color_B0B0B0")) |
| 134 | .maxLines(1) | 134 | .maxLines(1) |
| @@ -141,7 +141,7 @@ export struct RmhTitle { | @@ -141,7 +141,7 @@ export struct RmhTitle { | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | Blank() | 143 | Blank() |
| 144 | - if (this.rmhInfo.cnIsAttention) { | 144 | + if (this.rmhInfo?.cnIsAttention) { |
| 145 | Row() { | 145 | Row() { |
| 146 | if (Number(this.followStatus) === 0) { | 146 | if (Number(this.followStatus) === 0) { |
| 147 | Image($r('app.media.rmh_follow')) | 147 | Image($r('app.media.rmh_follow')) |
| @@ -49,7 +49,7 @@ export class LiveModel { | @@ -49,7 +49,7 @@ export class LiveModel { | ||
| 49 | success(data.data) | 49 | success(data.data) |
| 50 | }, (error: Error) => { | 50 | }, (error: Error) => { |
| 51 | fail(error.message) | 51 | fail(error.message) |
| 52 | - Logger.debug(TAG + ":error ", error.toString()) | 52 | + Logger.debug(TAG + ":error ", error.message) |
| 53 | }) | 53 | }) |
| 54 | }) | 54 | }) |
| 55 | } | 55 | } |
| @@ -26,6 +26,7 @@ export struct TabComponent { | @@ -26,6 +26,7 @@ export struct TabComponent { | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | build() { | 28 | build() { |
| 29 | + Stack({alignContent: Alignment.TopStart}) { | ||
| 29 | Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { | 30 | Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) { |
| 30 | ForEach(this.tabs, (item: string, index: number) => { | 31 | ForEach(this.tabs, (item: string, index: number) => { |
| 31 | TabContent() { | 32 | TabContent() { |
| @@ -36,7 +37,7 @@ export struct TabComponent { | @@ -36,7 +37,7 @@ export struct TabComponent { | ||
| 36 | } else if ('大家聊' === item) { | 37 | } else if ('大家聊' === item) { |
| 37 | TabChatComponent() | 38 | TabChatComponent() |
| 38 | } | 39 | } |
| 39 | - }.tabBar(this.tabBuilder(index, item)) | 40 | + } |
| 40 | .backgroundColor('#F5F5F5') | 41 | .backgroundColor('#F5F5F5') |
| 41 | }, (item: string, index: number) => { | 42 | }, (item: string, index: number) => { |
| 42 | return item + index | 43 | return item + index |
| @@ -45,13 +46,37 @@ export struct TabComponent { | @@ -45,13 +46,37 @@ export struct TabComponent { | ||
| 45 | .layoutWeight(1) | 46 | .layoutWeight(1) |
| 46 | .vertical(false) | 47 | .vertical(false) |
| 47 | .barMode(BarMode.Fixed) | 48 | .barMode(BarMode.Fixed) |
| 48 | - .barWidth(70 * this.tabs.length) | ||
| 49 | .barHeight(48) | 49 | .barHeight(48) |
| 50 | .animationDuration(100) | 50 | .animationDuration(100) |
| 51 | .onChange((index: number) => { | 51 | .onChange((index: number) => { |
| 52 | this.currentIndex = index | 52 | this.currentIndex = index |
| 53 | }) | 53 | }) |
| 54 | .backgroundColor(Color.White) | 54 | .backgroundColor(Color.White) |
| 55 | + | ||
| 56 | + // 页签 | ||
| 57 | + Row() { | ||
| 58 | + Scroll() { | ||
| 59 | + Row({space: '24vp'}) { | ||
| 60 | + ForEach(this.tabs, (item: string, index: number) => { | ||
| 61 | + this.tabBuilder(index, item) | ||
| 62 | + }) | ||
| 63 | + } | ||
| 64 | + .width('100%') | ||
| 65 | + .justifyContent(FlexAlign.Center) | ||
| 66 | + } | ||
| 67 | + .backgroundColor(Color.White) | ||
| 68 | + .align(Alignment.Start) | ||
| 69 | + .scrollable(ScrollDirection.Horizontal) | ||
| 70 | + .scrollBar(BarState.Off) | ||
| 71 | + .width('100%') | ||
| 72 | + } | ||
| 73 | + .backgroundColor(Color.White) | ||
| 74 | + .height('48vp') | ||
| 75 | + .alignItems(VerticalAlign.Bottom) | ||
| 76 | + .width('100%') | ||
| 77 | + }.layoutWeight(1) | ||
| 78 | + | ||
| 79 | + | ||
| 55 | } | 80 | } |
| 56 | 81 | ||
| 57 | @Builder | 82 | @Builder |
| @@ -60,7 +85,7 @@ export struct TabComponent { | @@ -60,7 +85,7 @@ export struct TabComponent { | ||
| 60 | Text(name) | 85 | Text(name) |
| 61 | .margin({ top: 6 }) | 86 | .margin({ top: 6 }) |
| 62 | .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) | 87 | .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) |
| 63 | - .fontSize('18fp') | 88 | + .fontSize('18vp') |
| 64 | .fontWeight(this.currentIndex === index ? 600 : 400) | 89 | .fontWeight(this.currentIndex === index ? 600 : 400) |
| 65 | Divider() | 90 | Divider() |
| 66 | .strokeWidth(2) | 91 | .strokeWidth(2) |
| @@ -68,7 +93,13 @@ export struct TabComponent { | @@ -68,7 +93,13 @@ export struct TabComponent { | ||
| 68 | .width(15) | 93 | .width(15) |
| 69 | .color('#CB0000') | 94 | .color('#CB0000') |
| 70 | .visibility(this.currentIndex === index ? Visibility.Visible : Visibility.Hidden) | 95 | .visibility(this.currentIndex === index ? Visibility.Visible : Visibility.Hidden) |
| 71 | - }.width('100%') | 96 | + }.justifyContent(FlexAlign.Center) |
| 97 | + .constraintSize({ minWidth: 35 }) | ||
| 98 | + .height('48vp') | ||
| 99 | + .onClick(() => { | ||
| 100 | + this.controller.changeIndex(index) | ||
| 101 | + this.currentIndex = index | ||
| 102 | + }) | ||
| 72 | } | 103 | } |
| 73 | 104 | ||
| 74 | aboutToDisappear(): void { | 105 | aboutToDisappear(): void { |
-
Please register or login to post a comment