Skip to content

quentinfasquel/FullScreenCoverDismissGesture

Repository files navigation

FullScreenCoverDismissGesture

Swift Package Manager compatible License: MIT

A SwiftUI extension to enable dismiss gestures for full-screen covers.

Example of usage

Usage

Presenting a Full-Screen Cover

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
        }
    }
}

Dismissing a Full-Screen Cover

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()
            }
        }
    }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages