Showing
1 changed file
with
46 additions
and
9 deletions
| @@ -6,7 +6,7 @@ import { SpConstants } from 'wdConstant/Index' | @@ -6,7 +6,7 @@ import { SpConstants } from 'wdConstant/Index' | ||
| 6 | import { ContentDetailRequest, postInteractAccentionOperateParams } from 'wdDetailPlayApi/Index' | 6 | import { ContentDetailRequest, postInteractAccentionOperateParams } from 'wdDetailPlayApi/Index' |
| 7 | import { NumberFormatterUtils, DateTimeUtils, SPHelper } from 'wdKit/Index' | 7 | import { NumberFormatterUtils, DateTimeUtils, SPHelper } from 'wdKit/Index' |
| 8 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' | 8 | import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' |
| 9 | -import { router } from '@kit.ArkUI' | 9 | +import { LengthMetrics, router } from '@kit.ArkUI' |
| 10 | 10 | ||
| 11 | const TAG = 'PlayerEndView' | 11 | const TAG = 'PlayerEndView' |
| 12 | 12 | ||
| @@ -18,8 +18,9 @@ export struct PlayerEndView { | @@ -18,8 +18,9 @@ export struct PlayerEndView { | ||
| 18 | @Consume liveRoomDataBean: LiveRoomDataBean | 18 | @Consume liveRoomDataBean: LiveRoomDataBean |
| 19 | @State duration: string = '' | 19 | @State duration: string = '' |
| 20 | @State followStatus: String = '0'; | 20 | @State followStatus: String = '0'; |
| 21 | - private onBack: () => void = () => { | ||
| 22 | - } | 21 | + private onBack: () => void = () => {} |
| 22 | + controller: TextController = new TextController() | ||
| 23 | + muStyleString: MutableStyledString = new MutableStyledString("") | ||
| 23 | 24 | ||
| 24 | aboutToAppear(): void { | 25 | aboutToAppear(): void { |
| 25 | this.calculateLiveDuration() | 26 | this.calculateLiveDuration() |
| @@ -122,14 +123,17 @@ export struct PlayerEndView { | @@ -122,14 +123,17 @@ export struct PlayerEndView { | ||
| 122 | .padding({ top: 8 }) | 123 | .padding({ top: 8 }) |
| 123 | } | 124 | } |
| 124 | Blank().height(this.contentDetailData.rmhInfo == null ? 26:16) | 125 | Blank().height(this.contentDetailData.rmhInfo == null ? 26:16) |
| 125 | - Stack() { | 126 | + Row() { |
| 126 | Row() { | 127 | Row() { |
| 127 | Column() { | 128 | Column() { |
| 128 | - Text(this.duration).fontWeight(600).fontSize(20).fontColor(Color.White) | 129 | + Text(undefined, {controller: this.controller}).fontWeight(600).fontSize(20).fontColor(Color.White) |
| 129 | Text('直播时长').fontWeight(400).fontSize(12).fontColor(Color.White) | 130 | Text('直播时长').fontWeight(400).fontSize(12).fontColor(Color.White) |
| 130 | } | 131 | } |
| 131 | - | ||
| 132 | - Blank().width(1).height(32).margin({ left: 36, right: 36 }) | 132 | + } |
| 133 | + .width(306/2.0) | ||
| 134 | + .justifyContent(FlexAlign.Center) | ||
| 135 | + Text('').width(1).height(32).backgroundColor('#33FFFFFF') | ||
| 136 | + Row() { | ||
| 133 | Column() { | 137 | Column() { |
| 134 | Text(NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean?.pv || '')) | 138 | Text(NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean?.pv || '')) |
| 135 | .fontWeight(600) | 139 | .fontWeight(600) |
| @@ -138,8 +142,9 @@ export struct PlayerEndView { | @@ -138,8 +142,9 @@ export struct PlayerEndView { | ||
| 138 | Text('观看人数').fontWeight(400).fontSize(12).fontColor(Color.White) | 142 | Text('观看人数').fontWeight(400).fontSize(12).fontColor(Color.White) |
| 139 | } | 143 | } |
| 140 | } | 144 | } |
| 141 | - Text('').width(1).height(32).backgroundColor('#33FFFFFF') | ||
| 142 | - } | 145 | + .width(306/2.0) |
| 146 | + .justifyContent(FlexAlign.Center) | ||
| 147 | + }.width(307) | ||
| 143 | if (this.contentDetailData.rmhInfo != null) { | 148 | if (this.contentDetailData.rmhInfo != null) { |
| 144 | Row() { | 149 | Row() { |
| 145 | Text(this.followStatus == '0' ? '关注' : '已关注') | 150 | Text(this.followStatus == '0' ? '关注' : '已关注') |
| @@ -209,6 +214,14 @@ export struct PlayerEndView { | @@ -209,6 +214,14 @@ export struct PlayerEndView { | ||
| 209 | } | 214 | } |
| 210 | router.back(); | 215 | router.back(); |
| 211 | }) | 216 | }) |
| 217 | + .onAreaChange(()=>{ | ||
| 218 | + /* | ||
| 219 | + 此处是为了更新直播时长这个属性字符串,在aboutToAppear里面写,无效,可能因为组件当时还没渲染出来, | ||
| 220 | + 返回按钮是PlayerEndView这个自定义组件的最后一个元素,它已经渲染了,前面的组件也就肯定渲染了 | ||
| 221 | + */ | ||
| 222 | + this.dealStyleString() | ||
| 223 | + }) | ||
| 224 | + | ||
| 212 | 225 | ||
| 213 | }.width('100%') | 226 | }.width('100%') |
| 214 | 227 | ||
| @@ -223,4 +236,28 @@ export struct PlayerEndView { | @@ -223,4 +236,28 @@ export struct PlayerEndView { | ||
| 223 | 236 | ||
| 224 | 237 | ||
| 225 | } | 238 | } |
| 239 | + dealStyleString() { | ||
| 240 | + let dayString = "天" | ||
| 241 | + let hourString = "时" | ||
| 242 | + const minuteString = "分" | ||
| 243 | + | ||
| 244 | + const styledKey = StyledStringKey.FONT | ||
| 245 | + const textStyle = new TextStyle({fontSize: LengthMetrics.vp(12), fontWeight: 500}) | ||
| 246 | + this.muStyleString = new MutableStyledString(this.duration) | ||
| 247 | + | ||
| 248 | + this.customSetStringStyle(dayString, styledKey, textStyle) | ||
| 249 | + this.customSetStringStyle(hourString, styledKey, textStyle) | ||
| 250 | + this.customSetStringStyle(minuteString, styledKey, textStyle) | ||
| 251 | + this.controller.setStyledString(this.muStyleString) | ||
| 252 | + } | ||
| 253 | + customSetStringStyle(startString: string, styledKey:StyledStringKey, textStyle: TextStyle) { | ||
| 254 | + if (this.duration.includes(startString)) { | ||
| 255 | + this.muStyleString.setStyle({ | ||
| 256 | + start: this.duration.indexOf(startString), | ||
| 257 | + length: 1, | ||
| 258 | + styledKey: styledKey, | ||
| 259 | + styledValue: textStyle | ||
| 260 | + }) | ||
| 261 | + } | ||
| 262 | + } | ||
| 226 | } | 263 | } |
-
Please register or login to post a comment