//
//  PlaylistCreateContentView.swift
//  SodaLive
//
//  Created by klaus on 12/8/24.
//

import SwiftUI
import Kingfisher

struct PlaylistCreateContentView: View {
    
    let content: AudioContentPlaylistContent
    
    var body: some View {
        HStack(spacing: 13.3) {
            KFImage(URL(string: content.coverUrl))
                .cancelOnDisappear(true)
                .downsampling(size: CGSize(width: 40, height: 40))
                .resizable()
                .scaledToFill()
                .frame(width: 40, height: 40, alignment: .center)
                .cornerRadius(5.3)
            
            VStack(alignment: .leading, spacing: 6.7) {
                HStack(spacing: 8) {
                    Text(content.category)
                        .font(.custom(Font.medium.rawValue, size: 8))
                        .foregroundColor(Color(hex: "3bac6a"))
                        .padding(2.6)
                        .background(Color(hex: "28312b"))
                        .cornerRadius(2.6)
                    
                    Text(content.duration)
                        .font(.custom(Font.medium.rawValue, size: 8))
                        .foregroundColor(Color.gray77)
                        .padding(2.6)
                        .background(Color.gray22)
                        .cornerRadius(2.6)
                }
                
                Text(content.title)
                    .font(.custom(Font.medium.rawValue, size: 12))
                    .foregroundColor(Color.grayd2)
                    .multilineTextAlignment(.leading)
                    .lineLimit(3)
                    .truncationMode(.tail)
                    .fixedSize(horizontal: false, vertical: true)
            }
        }
    }
}

#Preview {
    PlaylistCreateContentView(
        content: AudioContentPlaylistContent(
            id: 1,
            title: "안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요안녕하세요 오늘은 커버곡을 들려드리려고 해요",
            category: "커버곡",
            coverUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
            duration: "00:30:20",
            creatorNickname: "유저1",
            creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png"
        )
    )
}