import Foundation
import SwiftUI

typealias SwiftButton = SwiftUI.Button

// MARK: - KeyboardButton

public struct KeyboardButton: View {
    // MARK: Lifecycle

    public init(_ key: String, action: @escaping (_ key: String)->Void, width: CGFloat = .infinity, height: CGFloat = 48, color: Color = Colors.card, textColor: Color = Colors.text) {
        self.key = key
        self.action = action
        self.width = width
        self.height = height
        self.color = color
        self.textColor = textColor
    }

    // MARK: Public

    public var body: some View {
        SwiftUI.Button(action: { self.action(key) }) {
            HStack {
                Text(key).font(.system(size: 24, weight: .bold))
            }.frame(maxWidth: CGFloat(width), minHeight: height)
                .background(color)
                .foregroundColor(textColor)
                .clipShape(RoundedRectangle(cornerRadius: 8))
        }
    }

    // MARK: Internal

    var key: String = ""
    var action: (_ key: String)->Void
    var width: CGFloat
    var height: CGFloat
    var color: Color
    var textColor: Color
}
