import SwiftUI

/// A `struct` that contains sizing and spacing information about a button.
///
/// # Usage
/// Use the static properties provided for initialization. E.g.
///
/// ```
/// PillButtonSize.standard
/// ```
///
/// This is meant to be used in conjunction with the `pillButtonSize` view modifier, like so:
///
/// ```
/// // Apply to a single button
/// PrimaryButton(...)
///  .pillButtonSize(.standard)
///
/// // Apply to a group of buttons
/// VStack {
///     PrimaryButton(...)
/// }
/// .pillButtonSize(.standard)
/// ```
public struct PillButtonSizeV1 {
    var typography: TypographyV1
    var width: CGFloat?
    var maxWidth: CGFloat?
    var minHeight: CGFloat
    public var iconWidth: CGFloat
    var borderRadius: CGFloat
    var padding: EdgeInsets
    var alignment: Alignment = .center
    var loadingAlignment: Alignment = .center

    public init(
        typography: TypographyV1,
        width: CGFloat? = nil,
        maxWidth: CGFloat? = nil,
        minHeight: CGFloat,
        iconWidth: CGFloat,
        borderRadius: CGFloat,
        padding: EdgeInsets,
        alignment: Alignment = .center,
        loadingAlignment: Alignment = .center
    ) {
        self.typography = typography
        self.width = width
        self.maxWidth = maxWidth
        self.minHeight = minHeight
        self.iconWidth = iconWidth
        self.borderRadius = borderRadius
        self.padding = padding
        self.alignment = alignment
        self.loadingAlignment = loadingAlignment
    }
}

public extension PillButtonSizeV1 {
    static let small = PillButtonSizeV1(
        typography: .body3,
        width: nil,
        maxWidth: .infinity,
        minHeight: 32,
        iconWidth: 16,
        borderRadius: 8,
        padding: EdgeInsets()
    )

    static let smallAdaptive = PillButtonSizeV1(
        typography: .body3,
        width: nil,
        maxWidth: nil,
        minHeight: 32,
        iconWidth: 16,
        borderRadius: 8,
        padding: EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
    )

    static let medium = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: .infinity,
        minHeight: 48,
        iconWidth: 20,
        borderRadius: 8,
        padding: EdgeInsets()
    )

    static let mediumAdaptive = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: nil,
        minHeight: 48,
        iconWidth: 20,
        borderRadius: 8,
        padding: EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
    )
    
    static let mediumRounded = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: .infinity,
        minHeight: 48,
        iconWidth: 20,
        borderRadius: 24,
        padding: EdgeInsets()
    )

    static let mediumRoundedAdaptive = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: nil,
        minHeight: 48,
        iconWidth: 20,
        borderRadius: 24,
        padding: EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32)
    )

    static let large = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: .infinity,
        minHeight: 64,
        iconWidth: 32,
        borderRadius: 8,
        padding: EdgeInsets()
    )

    static let largeAdaptive = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: nil,
        minHeight: 64,
        iconWidth: 32,
        borderRadius: 8,
        padding: EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32)
    )

    static let largeRounded = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: .infinity,
        minHeight: 64,
        iconWidth: 32,
        borderRadius: 32,
        padding: EdgeInsets()
    )

    static let largeRoundedAdaptive = PillButtonSizeV1(
        typography: .button1,
        width: nil,
        maxWidth: nil,
        minHeight: 64,
        iconWidth: 32,
        borderRadius: 32,
        padding: EdgeInsets(top: 0, leading: 32, bottom: 0, trailing: 32)
    )
}
