64 lines
2.3 KiB
Swift
64 lines
2.3 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
// MARK: — Primary (black fill)
|
||
|
|
struct PrimaryButtonStyle: ButtonStyle {
|
||
|
|
var color: Color = AppTheme.ink
|
||
|
|
var height: CGFloat = 50
|
||
|
|
|
||
|
|
func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.system(size: 15, weight: .medium))
|
||
|
|
.foregroundColor(.white)
|
||
|
|
.frame(maxWidth: .infinity)
|
||
|
|
.frame(height: height)
|
||
|
|
.background(color)
|
||
|
|
.clipShape(RoundedRectangle(cornerRadius: AppTheme.radius, style: .continuous))
|
||
|
|
.scaleEffect(configuration.isPressed ? 0.97 : 1)
|
||
|
|
.animation(.spring(response: 0.25, dampingFraction: 0.7), value: configuration.isPressed)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// MARK: — Ghost (outline)
|
||
|
|
struct GhostButtonStyle: ButtonStyle {
|
||
|
|
var height: CGFloat = 50
|
||
|
|
|
||
|
|
func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.system(size: 15, weight: .medium))
|
||
|
|
.foregroundColor(AppTheme.ink)
|
||
|
|
.frame(maxWidth: .infinity)
|
||
|
|
.frame(height: height)
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: AppTheme.radius, style: .continuous)
|
||
|
|
.stroke(AppTheme.cardBorderColor, lineWidth: 1)
|
||
|
|
)
|
||
|
|
.scaleEffect(configuration.isPressed ? 0.97 : 1)
|
||
|
|
.animation(.spring(response: 0.25, dampingFraction: 0.7), value: configuration.isPressed)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// MARK: — Scale (tap anywhere, just scales)
|
||
|
|
struct ScaleButtonStyle: ButtonStyle {
|
||
|
|
func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.scaleEffect(configuration.isPressed ? 0.97 : 1)
|
||
|
|
.animation(.spring(response: 0.25, dampingFraction: 0.7), value: configuration.isPressed)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// MARK: — Pill (compact, rounded)
|
||
|
|
struct PillButtonStyle: ButtonStyle {
|
||
|
|
var color: Color = AppTheme.ink
|
||
|
|
func makeBody(configuration: Configuration) -> some View {
|
||
|
|
configuration.label
|
||
|
|
.font(.system(size: 13, weight: .medium))
|
||
|
|
.foregroundColor(.white)
|
||
|
|
.padding(.horizontal, 14)
|
||
|
|
.padding(.vertical, 7)
|
||
|
|
.background(color)
|
||
|
|
.clipShape(Capsule())
|
||
|
|
.scaleEffect(configuration.isPressed ? 0.96 : 1)
|
||
|
|
.animation(.spring(response: 0.2, dampingFraction: 0.7), value: configuration.isPressed)
|
||
|
|
}
|
||
|
|
}
|