//
//  SelectedButtonView.swift
//  SodaLive
//
//  Created by klaus on 2/23/24.
//

import SwiftUI

struct SelectedButtonView: View {
    
    let title: String
    let isActive: Bool
    let isSelected: Bool
    
    var checkImage = "ic_select_check"
    var bgDisabledColor = Color.gray55
    var bgSelectedColor = Color.button
    var bgDefaultColor = Color.bg
    var textDisabledColor = Color.gray77
    var textSelectedColor = Color.white
    var textDefaultColor = Color.button
    
    var body: some View {
        HStack(spacing: 6.7) {
            if isSelected {
                Image(checkImage)
            }
            
            Text(title)
                .font(.custom(Font.bold.rawValue, size: 14.7))
                .foregroundColor(!isActive ? textDisabledColor : isSelected ? textSelectedColor : textDefaultColor)
        }
        .padding(.vertical, isSelected ? 14.3 : 17)
        .frame(maxWidth: .infinity)
        .background(!isActive ? bgDisabledColor : isSelected ? bgSelectedColor : bgDefaultColor)
        .cornerRadius(6.7)
    }
}

#Preview("기본") {
    SelectedButtonView(title: "테스트", isActive: true, isSelected: true)
}

#Preview("이미지와 컬러 수정 - selected") {
    SelectedButtonView(
        title: "테스트",
        isActive: true,
        isSelected: true,
        bgSelectedColor: Color(hex: "ff14d9"),
        textDefaultColor: Color(hex: "ff14d9")
    )
}

#Preview("이미지와 컬러 수정 - unselected") {
    SelectedButtonView(
        title: "테스트",
        isActive: true,
        isSelected: false,
        textDefaultColor: Color(hex: "ff14d9")
    )
}

