//
//  ContentDetailCreatorProfileView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/11.
//

import SwiftUI
import Kingfisher

struct ContentDetailCreatorProfileView: View {
    
    let creator: AudioContentCreator
    let onClickFollow: (Int) -> Void
    let onClickUnFollow: (Int) -> Void
    
    var body: some View {
        HStack(spacing: 0) {
            KFImage(URL(string: creator.profileImageUrl))
                .resizable()
                .frame(width: 26.7, height: 26.7)
                .clipShape(Circle())
            
            Text(creator.nickname)
                .font(.custom(Font.medium.rawValue, size: 12))
                .foregroundColor(Color(hex: "777777"))
                .padding(.horizontal, 5.3)
            
            Spacer()
            
            if creator.creatorId != UserDefaults.int(forKey: .userId) {
                Image(creator.isFollowing ? "btn_notification_selected" : "btn_notification")
                    .onTapGesture {
                        if creator.isFollowing {
                            onClickUnFollow(creator.creatorId)
                        } else {
                            onClickFollow(creator.creatorId)
                        }
                    }
            }
        }
    }
}