sodalive-ios/SodaLive/Sources/Live/Room/Chat/LiveRoomDonationChatItemVie...

71 lines
2.6 KiB
Swift

//
// LiveRoomDonationChatItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveRoomDonationChatItemView: View {
let chatMessage: LiveRoomDonationChat
var body: some View {
HStack(spacing: 13.3) {
ZStack(alignment: .bottomTrailing) {
KFImage(URL(string: chatMessage.profileUrl))
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipped()
.cornerRadius(23.3)
Image("ic_can")
}
VStack(alignment: .leading, spacing: 6.7) {
HStack(spacing: 0) {
Text(chatMessage.nickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(.white)
Text("님이")
.font(.custom(Font.light.rawValue, size: 12))
.foregroundColor(.white)
}
HStack(spacing: 0) {
Text("\(chatMessage.can)")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(Color(hex: "fdca2f"))
Text("을 후원하셨습니다.")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(.white)
}
if !chatMessage.donationMessage.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
Text("\"\(chatMessage.donationMessage)\"")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(.white)
}
}
}
.padding(13)
.frame(width: screenSize().width - 86, alignment: .leading)
.background(
chatMessage.can >= 100000 ? Color(hex: "c25264") :
chatMessage.can >= 50000 ? Color(hex: "d85e37").opacity(0.9) :
chatMessage.can >= 10000 ? Color(hex: "d38c38").opacity(0.9) :
chatMessage.can >= 5000 ? Color(hex: "59548f").opacity(0.9) :
chatMessage.can >= 1000 ? Color(hex: "4d6aa4").opacity(0.9) :
chatMessage.can >= 500 ? Color(hex: "2d7390").opacity(0.9) :
Color(hex: "548f7d").opacity(0.9)
)
.cornerRadius(10)
.padding(.leading, 20)
}
}