A SwiftUI extension to enable dismiss gestures for full-screen covers.
To present a full-screen cover without animation, you can use the following example:
struct ContentView: View {
@State private var showDetail: Bool = false
var body: some View {
ZStack {
Button("Show Detail") {
presentWithoutAnimation()
}
}
.fullScreenCover(isPresented: $showDetail) {
DetailView().fullScreenCoverDismissGesture()
}
}
private func presentWithoutAnimation() {
var transaction = Transaction(animation: nil)
transaction.disablesAnimations = true
withTransaction(transaction) {
showDetail = true
}
}
}To enable dismissing a full-screen cover using a custom gesture, use the following example:
struct DetailView: View {
@Environment(\.fullScreenCoverDismiss) private var dismiss
var body: some View {
ZStack {
Color.black
Button("Dismiss") {
dismiss()
}
}
}
}This project is licensed under the MIT License - see the LICENSE file for details.
