41 lines
1.7 KiB
Swift
41 lines
1.7 KiB
Swift
import Portico
|
|
|
|
struct PresentationDemoPage: View {
|
|
@State private var dialogLocked = false
|
|
@State private var showDialog = false
|
|
@State private var showAlert = false
|
|
@State private var lastResponse = "none"
|
|
private let toasts = ToastManager()
|
|
|
|
var body: some View {
|
|
ToastOverlay {
|
|
VStack(spacing: 12) {
|
|
Button().label("Show dialog").onClicked { showDialog = true }
|
|
Button().label("Show alert").onClicked { showAlert = true }
|
|
Button().label("Toast").onClicked {
|
|
toasts.addToast(Toast(title: "Saved", timeout: .seconds(3), buttonLabel: "Undo") {
|
|
lastResponse = "undo"
|
|
})
|
|
}
|
|
Button().label("Dismiss toasts").onClicked { toasts.dismissAll() }
|
|
Label("Last response: \(lastResponse)").dimmed()
|
|
}
|
|
.margin(24)
|
|
.dialog(isPresented: $showDialog, title: "Details", contentWidth: 360, canClose: $dialogLocked) {
|
|
VStack(spacing: 12) {
|
|
Label("Dialog")
|
|
Button().label("Toggle lock").onClicked { dialogLocked.toggle() }
|
|
Button().label("Close").onClicked { showDialog = false }
|
|
}
|
|
.margin(24)
|
|
}
|
|
.alert(isPresented: $showAlert, heading: "Delete file?", body: "This cannot be undone.", defaultResponse: "cancel", closeResponse: "cancel", responses: [
|
|
AlertResponse(id: "cancel", label: "Cancel"),
|
|
AlertResponse(id: "delete", label: "Delete", appearance: .destructive)
|
|
]) { response in
|
|
lastResponse = response
|
|
}
|
|
}
|
|
.toastManager(toasts)
|
|
}
|
|
}
|