ios – Navigation view with drag indicator


Let’s say I am opening a modal from my main view and then modal is opening a subview within it. My modal does not have a drag indicator on top, so my guess that’s why the subview doesn’t have drag indicator on top as well.

How do I get drag indicator to show up in the subview(NavigationA view in my code below)? I am adding “.presentationDragIndicator(.visible)” but that’s not helping.

Code:

import SwiftUI
import Foundation

struct ContentView: View {
    @State var showSheet: Bool = false
    var body: some View {
        VStack {
            Text("Click Me").font(.title).foregroundStyle(Color.blue).onTapGesture {
                self.showSheet.toggle()
            }
        }
        .sheet(isPresented: $showSheet) { SheetA() }
    }
}

struct SheetA: View {
    @State var showSubView: Bool = false
    
    var body: some View {
        NavigationStack {
            VStack {
                Text("Show Navigation View").foregroundStyle(Color.blue).font(.title).onTapGesture {
                    self.showSubView.toggle()
                }
            }
            .navigationDestination(isPresented: self.$showSubView) { NavigationA() }
            .presentationDetents([.large])
            .presentationDragIndicator(.hidden)
            .interactiveDismissDisabled()
        }
    }
}

/// This view when presented should have drag indicator or handler on the top.
struct NavigationA: View {
    var body: some View {
        VStack {
            Text("This is the navigation view. \nThis view should have drag handler on top")
        }
        .presentationDetents([.medium, .large])
        .presentationDragIndicator(.visible)
        .interactiveDismissDisabled()
        .navigationBarBackButtonHidden()
    }
}

I need drag indicator on this view.

enter image description here

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img