58 lines
2.1 KiB
Swift
58 lines
2.1 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
public struct PrimaryActionStyle: ButtonStyle {
|
||
|
|
public init() {}
|
||
|
|
|
||
|
|
public func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.headline.weight(.semibold))
|
||
|
|
.foregroundStyle(.white)
|
||
|
|
.padding(.horizontal, 16)
|
||
|
|
.padding(.vertical, 11)
|
||
|
|
.frame(minHeight: 44)
|
||
|
|
.background(
|
||
|
|
RoundedRectangle(cornerRadius: SIO.controlRadius, style: .continuous)
|
||
|
|
.fill(SIO.tint.opacity(configuration.isPressed ? 0.82 : 1))
|
||
|
|
)
|
||
|
|
.opacity(configuration.isPressed ? 0.94 : 1)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public struct SecondaryActionStyle: ButtonStyle {
|
||
|
|
public init() {}
|
||
|
|
|
||
|
|
public func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.headline.weight(.semibold))
|
||
|
|
.foregroundStyle(.primary)
|
||
|
|
.padding(.horizontal, 16)
|
||
|
|
.padding(.vertical, 11)
|
||
|
|
.frame(minHeight: 44)
|
||
|
|
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: SIO.controlRadius, style: .continuous))
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: SIO.controlRadius, style: .continuous)
|
||
|
|
.strokeBorder(Color.primary.opacity(0.08), lineWidth: 1)
|
||
|
|
)
|
||
|
|
.opacity(configuration.isPressed ? 0.9 : 1)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public struct DestructiveStyle: ButtonStyle {
|
||
|
|
public init() {}
|
||
|
|
|
||
|
|
public func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.headline.weight(.semibold))
|
||
|
|
.foregroundStyle(.red)
|
||
|
|
.padding(.horizontal, 16)
|
||
|
|
.padding(.vertical, 11)
|
||
|
|
.frame(minHeight: 44)
|
||
|
|
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: SIO.controlRadius, style: .continuous))
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: SIO.controlRadius, style: .continuous)
|
||
|
|
.strokeBorder(Color.red.opacity(configuration.isPressed ? 0.35 : 0.18), lineWidth: 1)
|
||
|
|
)
|
||
|
|
.opacity(configuration.isPressed ? 0.9 : 1)
|
||
|
|
}
|
||
|
|
}
|