62 lines
1.1 KiB
Swift
62 lines
1.1 KiB
Swift
import SwiftUI
|
|
|
|
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 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."
|
|
}
|
|
ResetButton {
|
|
lastButtonPressed = "Reset button pressed."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ButtonPreview()
|
|
}
|
|
#endif
|