How to use double/triple columns navigation style in SwiftUI document-based app?

How to use double/triple columns navigation style in SwiftUI document-based app?

The problem is that the DocumentGroup() itself, seems already a NavigationView.

In a non-document-based app, we can simply achieve this using three views within a navigation view.

However, this is not the case for DocumentGroup.
The views will be "VStack-ed".
I've also tried setting the navigation view style as double column, which also failed.

Any workaround?

Code Block
@main
struct SomeApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
struct ContentView: View {
    var body: some View {
        NavigationView {
LeftPanelView()
MidPanelView()
RightPanelView()
        }
    }
}

I've just found a temporary workaround.

Wrap your views in an additional NavigationView so that you get standard behaviors.
Then hide the DocumentGroup's navigation bar.

Code Block swift
        DocumentGroup(newDocument: SomeDocument()) { file in
            NavigationView {
                ContentView(document: file.$document)
                ContentView(document: file.$document)
            }
            .navigationViewStyle(DoubleColumnNavigationViewStyle())
            .navigationBarHidden(true)


You will then need to manually add a back button ofc, i.e. from your view back to the document selection view.
I am struggling with the same issue. I have hidden the top-level navigation view to get to 90% of the design I want. But I don't know how to add a 'back' button to get back to the document selection view. I added a button in the LH pane ('close') and a @Binding to the top-level DocumentGroup. [Tap on 'close' and set the isDisplayed to false] but I cannot find a way to express to 'DocumentGroup' to return to the file picker.

Any leads on a path forward?


I'm also struggling with the issue.

I used to use the environment variable presentationMode. However, it is not working, at least for the moment.
As a result, I've refactored all my old code to use a isPresented binding to control the view dismiss behavior for workaround.

Maybe it is intended or maybe its a bug?
How to use double/triple columns navigation style in SwiftUI document-based app?
 
 
Q