ChartItemComponent.ets 1.69 KB
import { LiveRoomItemBean } from 'wdBean/Index'
import { LiveMessageRole } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'
// import { LengthMetrics } from '@kit.ArkUI'

@Component
export struct ChatItemComponent {
  item: LiveRoomItemBean = {} as LiveRoomItemBean

  aboutToAppear(): void {
  }

  build() {
    Row() {
      Text() {
        if (this.item.role == LiveMessageRole.host) {
          Span(' 主持人 ')
            .fontSize(11)
            // .lineHeight(16)
            .textBackgroundStyle({ color: "#70FFC63F", radius: 2 })
            .fontColor('#FFFFFFFF')
            .fontFamily('PingFang SC-Regular')
            .fontWeight(400)
          Span(' ')
        }
        if (this.item.role == LiveMessageRole.guest) {
          Span(' 嘉宾 ')
            .fontSize(11)
            // .lineHeight(16)
            .textBackgroundStyle({ color: "#70FFC63F", radius: 2 })
            .fontColor('#FFFFFFFF')
            .fontFamily('PingFang SC-Regular')
            .fontWeight(400)
          Span(' ')
        }
        Span(this.item.senderUserName + ': ')
          .fontSize(14)
          .lineHeight(22)
          .fontColor('#FFFFC63F')
          .padding({ right: 118 })
          .fontFamily('PingFang SC-Semibold')
          .fontWeight(600)

        Span(this.item.text)
          .fontSize(14)
          .lineHeight(22)
          .fontColor('#FFFFFFFF')
          .fontFamily('PingFang SC-Semibold')
          .fontWeight(600)
      }
      .textShadow({ offsetX: 1, offsetY: 1, color: '#4D000000', radius: 1 })

    }
    .backgroundColor('#4D000000')
    .borderRadius(3)
    .padding({
      top: 6,
      bottom: 6,
      left: 8,
      right: 8
    })
    .margin({ left: 16, bottom: 4 })
  }
}