//
//  ContentCreatorView.swift
//  SodaLive
//
//  Created by klaus on 2/20/25.
//

import SwiftUI
import Kingfisher

struct ContentCreatorView: View {
    
    let isSelected: Bool
    let item: ContentCreatorResponse
    
    var body: some View {
        VStack(spacing: 13.3) {
            KFImage(URL(string: item.creatorProfileImageUrl))
                .cancelOnDisappear(true)
                .downsampling(size: CGSize(width: 60, height: 60))
                .resizable()
                .frame(width: 60, height: 60)
                .clipShape(Circle())
                .overlay(
                    Circle()
                        .strokeBorder(lineWidth: 3)
                        .foregroundColor(
                            .button
                                .opacity(isSelected ? 1 : 0)
                        )
                )
            
            Text(item.creatorNickname)
                .font(.custom(Font.medium.rawValue, size: 11.3))
                .foregroundColor(
                    isSelected ?
                    Color.button :
                    Color.graybb
                        
                )
        }
    }
}

#Preview {
    ContentCreatorView(
        isSelected: true,
        item: ContentCreatorResponse(
            creatorId: 1,
            creatorNickname: "유저1",
            creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png"
        )
    )
}