nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

replicate `presentationBackgroundInteraction(.enabled)` #42

Closed AndrewSB closed 3 months ago

AndrewSB commented 3 months ago

hey! swiftui has a modifier on their sheet content, .presentationBackgroundInteraction, that allows touches to be handled by the background, not the sheet content, is there a way to replicate that?

my sheet only takes up the bottom 3rd of the screen, so i'd like the top 2/3rds of the screen to still be interactive, not have touches taken by the black overlay area of my sheet

nathantannar4 commented 3 months ago

Have you tried setting the largestUndimmedDetentIdentifier?

extension PresentationLinkTransition.SheetTransitionOptions.Detent.Identifier {
    static let partial = PresentationLinkTransition.SheetTransitionOptions.Detent.Identifier("small")
}

extension PresentationLinkTransition.SheetTransitionOptions.Detent {
    static let partial = PresentationLinkTransition.SheetTransitionOptions.Detent.custom(.partial) { ctx in
        return ctx.maximumDetentValue * 2 / 3
    }
}

struct ContentView: View {
    var body: some View {
        PresentationLink(
            transition: .sheet(
                options: .init(
                    detents: [.partial],
                    largestUndimmedDetentIdentifier: .partial
                )
            )
        ) {
            Text("Content")
        } label: {
            Text("Label")
        }
    }
}
AndrewSB commented 3 months ago

ahh no! i missed that, thank you for your work, i'll give it a shot

AndrewSB commented 3 months ago

awesome, that works!