0

I'm working on an iPad app where I will have three views inside a single NavigationView to provide the 3-way split screen found in native apps (Notes) on horizontal mode. See the screenshot below as an example.

enter image description here

A particular behaviour that I found to be interesting is when I click on an item in the Folders View. The entire Folders View collapses to the side when I do. See the following gif for an example of the behaviour that I found to be eyecatching (Here, I press on the React native Item).

enter image description here

I want to replicate this behaviour using SwiftUIs NavigationView but haven't managed to so far. I've tried many solutions in this thread about closing/popping a View in the navigation stack, but none of them works.

You can find the code I have prepared below with a gif representing how it looks as of now

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                Button("Close First") {
                    // Close the View
                }
            }
            .navigationTitle("First")

            Text("Second")
                .navigationTitle("Second")

            Text("Third")
                .navigationTitle("Third")
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .previewDevice("iPad mini (6th generation)")
.previewInterfaceOrientation(.landscapeLeft)
    }
}

GUI:

enter image description here

Any help would be appreciated, TIA.

Visal Rajapakse
  • 1,718
  • 1
  • 9
  • 15
  • 1
    This looks like a bug - dismiss should work in this case. – Asperi Mar 26 '22 at 18:40
  • 1
    I also noticed if you select a NavigationLink in the middle column it doesn't close the sidebar unless you had chosen a different NavigationLink in the first column I think we just have to keep submitting bug reports. – malhal Mar 26 '22 at 21:26
  • Yea, I have submitted a bug report in this regard. – Visal Rajapakse Mar 27 '22 at 02:19

0 Answers0