1

I've had my app inside a NavigationView using the StackNavigationViewStyle style for some time with no problems. Recently I wanted to add a sidebar to it though, so I thought I should try using the DoubleColumnNavigationViewStyle style for this. At the moment I can kind of make it work but it has some quirks:

  • If I am in a subview, and I try to slide back into its parent view, sliding back always brings the side bar into view instead of taking me back into the parent view which is what I would expect. Now matter how deep into my view hierarchy I am. (If you use the default Notes app and select View as a Gallery, that is exactly the way I expect my app to work like).
  • Much less important but annoying nonetheless is that if I press the back button, the nice animations of the sliding < back buttons into/out of view I got when I used StackNavigationViewStyle no longer happen. The buttons work fine but the animations are much worse now.

Here is a sample minimum app and a video to show what I mean:


import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            Text("Sidebar")
            MainView()
        }
    }
}

struct MainView: View {
    var body: some View {
        Text("Main View")
        NavigationLink(destination: Text("Sub View")) {
            Text("Go to Sub View")
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

enter image description here

Thanks!

Hamster
  • 133
  • 3
  • 12

0 Answers0