132 lines
2.3 KiB
Swift
132 lines
2.3 KiB
Swift
import SwiftUI
|
|
|
|
public struct DeleteButton: View {
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button(role: .destructive, action: action) {
|
|
Label("Delete", systemImage: "trash")
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct DoneButton: View {
|
|
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button(action: action) {
|
|
Text("Done")
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct EditButton: View {
|
|
|
|
@Environment(\.editButtonStyle) private var style
|
|
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button(action: action) {
|
|
Label("Edit", systemImage: "square.and.pencil")
|
|
}
|
|
.buttonStyle(style)
|
|
}
|
|
}
|
|
|
|
public struct InfoButton: View {
|
|
|
|
@Environment(\.infoButtonStyle) private var infoButtonStyle
|
|
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button(action: action) {
|
|
Label("Info", systemImage: "info.circle")
|
|
}
|
|
.buttonStyle(infoButtonStyle)
|
|
}
|
|
}
|
|
|
|
public struct NextButton: View {
|
|
|
|
@Environment(\.nextButtonStyle) private var nextButtonStyle
|
|
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button {
|
|
action()
|
|
} label: {
|
|
Label("Next", systemImage: "chevron.right")
|
|
}
|
|
.buttonStyle(nextButtonStyle)
|
|
}
|
|
}
|
|
|
|
public struct ResetButton: View {
|
|
|
|
@Environment(\.resetButtonStyle) private var resetButtonStyle
|
|
|
|
let action: () -> Void
|
|
|
|
public init(action: @escaping () -> Void) {
|
|
self.action = action
|
|
}
|
|
|
|
public var body: some View {
|
|
Button("Reset", role: .destructive) {
|
|
action()
|
|
}
|
|
.buttonStyle(resetButtonStyle)
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct ButtonPreview: View {
|
|
|
|
@State private var lastButtonPressed: String = ""
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Text(lastButtonPressed)
|
|
|
|
InfoButton {
|
|
lastButtonPressed = "Info button pressed."
|
|
}
|
|
NextButton {
|
|
lastButtonPressed = "Next button pressed."
|
|
}
|
|
ResetButton {
|
|
lastButtonPressed = "Reset button pressed."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ButtonPreview()
|
|
}
|
|
#endif
|