//
//  LiveRoomOverlayStrokeTextToggleButton.swift
//  SodaLive
//
//  Created by klaus on 2024/01/17.
//

import SwiftUI

struct LiveRoomOverlayStrokeTextToggleButton: View {
    
    let isOn: Bool
    
    let onText: String
    let onTextColor: Color
    let onStrokeColor: Color
    
    let offText: String?
    let offTextColor: Color
    let offStrokeColor: Color
    
    let strokeWidth: CGFloat
    let strokeCornerRadius: CGFloat
    
    let onClick: () -> Void
    
    var body: some View {
        Text(isOn ? onText : offText != nil && offText?.count ?? 0 > 0 ? offText! : onText)
            .font(.custom(Font.medium.rawValue, size: 12))
            .foregroundColor(isOn ? onTextColor : offTextColor)
            .padding(.horizontal, 8)
            .padding(.vertical, 6)
            .overlay(
                RoundedRectangle(cornerRadius: strokeCornerRadius)
                    .stroke(
                        isOn ? onStrokeColor : offStrokeColor,
                        lineWidth: strokeWidth
                    )
            )
            .onTapGesture { onClick() }
    }
}

struct LiveRoomOverlayStrokeTextToggleButton_Previews: PreviewProvider {
    static var previews: some View {
        LiveRoomOverlayStrokeTextToggleButton(
            isOn: true,
            onText: "배경 ON",
            onTextColor: Color.button,
            onStrokeColor: Color.button,
            offText: "배경 OFF",
            offTextColor: Color.grayee,
            offStrokeColor: Color.graybb,
            strokeWidth: 1,
            strokeCornerRadius: 5.3,
            onClick: {}
        )
    }
}
