//
//  AuditionItemView.swift
//  SodaLive
//
//  Created by klaus on 1/6/25.
//

import SwiftUI
import Kingfisher

struct AuditionItemView: View {
    
    let item: GetAuditionListItem
    
    var body: some View {
        VStack(alignment: .leading, spacing: 10) {
            ZStack {
                KFImage(URL(string: item.imageUrl))
                    .cancelOnDisappear(true)
                    .downsampling(size: CGSize(width: 1000, height: 530))
                    .resizable()
                    .aspectRatio(1000/530, contentMode: .fit)
                    .frame(maxWidth: .infinity)
                    .cornerRadius(6.7)
                    .overlay(
                        Color.black
                            .cornerRadius(6.7)
                            .opacity(item.isOff ? 0.7 : 0.0)
                    )
            }
            .frame(maxWidth: .infinity)
            
            Text(item.title)
                .font(.custom(Font.medium.rawValue, size: 13.3))
                .foregroundColor(Color.grayee)
                .lineLimit(1)
                .truncationMode(.tail)
        }
    }
}

#Preview {
    AuditionItemView(
        item: GetAuditionListItem(
            id: 1,
            title: "[원작] 성인식",
            imageUrl: "https://test-cf.sodalive.net/audition/production/3/audition-aa934579-c01a-4da2-89fd-cce70d51c612-4267-1735908116928",
            isOff: false
        )
    )
}
