Japanese README: README-ja.md
A SwiftUI extension that provides sheet_
, behaving like the standard sheet
, but with two extra features:
@Environment(\.dismissSheet)
to programmatically dismiss the currently presented sheetonDismissAttempt_
, triggered only if you’ve setinteractiveDismissDisabled(true)
and the user attempts to dismiss
Presenting a sheet
@State private var isSheetPresented = false
Button("Open Sheet") {
isSheetPresented = true
}
.sheet_(
isPresented: $isSheetPresented,
onDismiss: { print("Sheet dismissed") }
) {
SheetContentView()
}
Dismissing from inside
@Environment(\.dismissSheet) private var dismissSheet
Button("Dismiss") {
dismissSheet()
}
Intercepting dismiss (requires interactiveDismissDisabled(true)
)
@Environment(\.dismissSheet) private var dismissSheet
.interactiveDismissDisabled(true)
.onInteractiveDismissAttempt_ {
showAlert = true
}
.alert("Dismiss?", isPresented: $showAlert) {
Button("Cancel", role: .cancel) {}
Button("Dismiss", role: .destructive) {
dismissSheet()
}
}