2023-12-29 11:17:37 +01:00
|
|
|
//Made by Lumaa
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct LargeButton: ButtonStyle {
|
|
|
|
var filled: Bool = false
|
2024-01-02 14:23:36 +01:00
|
|
|
var height: CGFloat? = nil
|
2024-01-24 19:40:14 +01:00
|
|
|
var disabled: Bool = false
|
|
|
|
|
|
|
|
private var fillColor: Color {
|
|
|
|
if disabled {
|
|
|
|
Color.gray
|
|
|
|
} else {
|
|
|
|
Color(uiColor: UIColor.label)
|
|
|
|
}
|
|
|
|
}
|
2023-12-29 11:17:37 +01:00
|
|
|
|
|
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
|
|
configuration.label
|
2024-01-02 14:23:36 +01:00
|
|
|
.padding(.horizontal)
|
|
|
|
.padding(.vertical, height)
|
2023-12-29 11:17:37 +01:00
|
|
|
.background {
|
|
|
|
if filled {
|
2024-01-24 19:40:14 +01:00
|
|
|
fillColor
|
2023-12-29 11:17:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.foregroundStyle(filled ? Color(uiColor: UIColor.systemBackground) : Color(uiColor: UIColor.label))
|
|
|
|
.bold(filled)
|
|
|
|
.clipShape(.rect(cornerRadius: 15))
|
|
|
|
.opacity(configuration.isPressed ? 0.3 : 1)
|
|
|
|
.overlay {
|
|
|
|
if !filled {
|
|
|
|
RoundedRectangle(cornerRadius: 15)
|
|
|
|
.stroke(Color(uiColor: UIColor.tertiaryLabel))
|
|
|
|
.opacity(configuration.isPressed ? 0.3 : 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NoTapAnimationStyle: PrimitiveButtonStyle {
|
|
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
|
|
configuration.label
|
|
|
|
.contentShape(Rectangle())
|
|
|
|
.onTapGesture(perform: configuration.trigger)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Preview {
|
|
|
|
Button {} label: {
|
2024-01-06 02:50:09 +01:00
|
|
|
Text(String("Hello world"))
|
2023-12-29 11:17:37 +01:00
|
|
|
}
|
|
|
|
.buttonStyle(NoTapAnimationStyle())
|
|
|
|
}
|