SwiftUI .sheet() disables background interaction

Viewed 53

Background: SwiftUI 4.0 (iOS 16) brings a ton of cool new things to use, one is the new .sheet() with .presentationDetents(), this basically allows you to create a resizeable sheet like the one in apple maps. Bottom sheet tutorial

Problem: You cannot interact with the background of the .sheet(). See image below: screenshot While the sheet is open (in any position) you cannot move the map around in the background. How can I enable interaction with the background while using presentation detents?

Code:

struct CreateStoryView: View {
    @EnvironmentObject var csvm: CreateStoryViewModel
    @Binding var currentUserData: UserModel
    @Binding var showCreateStoryView: Bool
    private let topBarHeight: CGFloat = 50
    private let viewPadding: CGFloat = 15
    
    var body: some View {
        GeometryReader { geo in
            let mapFrame = CGSize(width: geo.size.width, height: geo.size.height + geo.safeAreaInsets.magnitude)
            
            ZStack(alignment: .top) {
                CreateFenceMapView(geoSize: mapFrame, viewPadding: self.viewPadding)
                CreateStoryNavBar(showCreateStoryView: $showCreateStoryView, topBarHeight: self.topBarHeight, viewPadding: self.viewPadding, geoSize: geo.size)
            }
            .sheet(isPresented: $showCreateStoryView, content: {
                if #available(iOS 16.0, *) {
                    CreateStoryDetailsView(currentUserData: $currentUserData, geoSize: geo.size)
                        .presentationDetents([.fraction(0.25), .large])
                        .presentationDragIndicator(.visible)
                        .interactiveDismissDisabled()
                } else {
                    ZStack {
                        Color.theme.accentLight
                    }
                }
            })
        }
    }
}
0 Answers
Related