//
//  LiveReservationAllItemView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/14.
//

import SwiftUI
import Kingfisher

struct LiveReservationAllItemView: View {
    
    let item: GetRoomListResponse
    
    var body: some View {
        VStack(spacing: 13.3) {
            HStack(spacing: 20) {
                ZStack(alignment: .topLeading) {
                    KFImage(URL(string: item.coverImageUrl))
                        .cancelOnDisappear(true)
                        .downsampling(
                            size: CGSize(
                                width: 80,
                                height: 116
                            )
                        )
                        .resizable()
                        .scaledToFill()
                        .frame(width: 80, height: 116.7, alignment: .top)
                        .cornerRadius(4.7)
                        .clipped()
                }
                
                HStack(alignment: .top, spacing: 0) {
                    VStack(alignment: .leading, spacing: 0) {
                        Text(item.beginDateTime)
                            .font(.custom(Font.medium.rawValue, size: 9.3))
                            .foregroundColor(Color(hex: "ffd300"))
                        
                        Text(item.creatorNickname)
                            .font(.custom(Font.medium.rawValue, size: 11.3))
                            .foregroundColor(Color(hex: "bbbbbb"))
                            .padding(.top, 10)
                        
                        Text(item.title)
                            .font(.custom(Font.medium.rawValue, size: 15.3))
                            .foregroundColor(Color(hex: "e2e2e2"))
                            .lineLimit(2)
                            .padding(.top, 10)
                            .padding(.trailing, 20)
                        
                        Spacer()
                        
                        if item.isReservation {
                            Text("예약완료")
                                .font(.custom(Font.medium.rawValue, size: 11.3))
                                .foregroundColor(Color(hex: "d2d2d2"))
                                .padding(.horizontal, 7)
                                .padding(.vertical, 4)
                                .background(Color(hex: "533d89"))
                                .cornerRadius(10)
                        } else {
                            Text(item.price > 0 ? "\(item.price)캔" : "무료")
                                .font(.custom(Font.medium.rawValue, size: 12))
                                .foregroundColor(Color(hex: "e2e2e2").opacity(0.49))
                                .padding(.bottom, 6.7)
                        }
                    }
                    
                    Spacer()
                    
                    if item.isPrivateRoom {
                        Image("ic_lock")
                            .resizable()
                            .frame(width: 20, height: 20)
                    }
                }
                .padding(.vertical, 6.7)
            }
            
            Rectangle()
                .foregroundColor(Color(hex: "909090").opacity(0.5))
                .frame(width: screenSize().width - 26.7, height: 1)
        }
        .frame(width: screenSize().width - 26.7, height: 130, alignment: .center)
    }
}
