//
//  LiveRoomRouletteDonationChatItemView.swift
//  SodaLive
//
//  Created by klaus on 2023/12/07.
//

import SwiftUI
import Kingfisher

struct LiveRoomRouletteDonationChatItemView: View {
    
    let chatMessage: LiveRoomRouletteDonationChat
    
    var body: some View {
        HStack(spacing: 13.3) {
            ZStack(alignment: .bottomTrailing) {
                KFImage(URL(string: chatMessage.profileUrl))
                    .cancelOnDisappear(true)
                    .downsampling(
                        size: CGSize(
                            width: 33.3,
                            height: 33.3
                        )
                    )
                    .resizable()
                    .scaledToFill()
                    .frame(width: 33.3, height: 33.3, alignment: .top)
                    .clipped()
                    .cornerRadius(23.3)
                
                Image("ic_roulette")
                    .resizable()
                    .frame(width: 20, height: 20)
            }
            
            VStack(alignment: .leading, spacing: 6.7) {
                HStack(spacing: 0) {
                    Text(chatMessage.nickname)
                        .font(.system(size: 12))
                        .foregroundColor(.white)
                    
                    Text("님의 룰렛 결과?")
                        .font(.system(size: 12, weight: .light))
                        .foregroundColor(.white)
                }
                
                Text("[\(chatMessage.rouletteResult)]")
                    .font(.system(size: 15))
                    .foregroundColor(Color(hex: "ffe500"))
                
                +
                
                Text(" 당첨!")
                    .font(.system(size: 15))
                    .foregroundColor(.white)
            }
        }
        .padding(13)
        .frame(width: screenSize().width - 86, alignment: .leading)
        .background(Color(hex: "c25264"))
        .cornerRadius(10)
        .padding(.leading, 20)
    }
}

struct LiveRoomRouletteDonationChatItemView_Previews: PreviewProvider {
    static var previews: some View {
        LiveRoomRouletteDonationChatItemView(chatMessage: LiveRoomRouletteDonationChat(profileUrl: "", nickname: "유저일", rouletteResult: "옵션1"))
    }
}
