Port NavigationView to NavigationStack (with NavigationLink) Question

I am porting an existing app to iOS16. It contains a NavigationView that looks like the following:


    var body: some View {
           NavigationView {
            VStack {
                Text("Main Content")
                    .frame(height: 400)
                   
                NavigationView {
                    NavigationLink(destination:
                        Text("Navigation Detail")
                    )
                    {
                        Text("Navigation Link")
                    }
                    .navigationTitle("Properties Frame")
                    .navigationBarTitleDisplayMode(.inline)
                }.navigationViewStyle(.stack)
                    
            }
            .navigationTitle("Main Frame")
            .navigationBarTitleDisplayMode(.inline)
        }
        .navigationViewStyle(.stack)
    }


Clicking on Navigation Link gives the following (as originally intended) :

When the above is ported to NavigationStack

 var body: some View {
        NavigationStack {
            VStack {
                Text("Main Content")
                    .frame(height: 400)
              
                NavigationStack {
                    NavigationLink(destination:
                        Text("Navigation Detail")
                    )
                    {
                        Text("Navigation Link")
                    }
                    .navigationTitle("Properties Frame")
                    .navigationBarTitleDisplayMode(.inline)
                }
            }
            .navigationTitle("Main Frame")
            .navigationBarTitleDisplayMode(.inline)
        }
    }

It gives a full screen Properties Frame when clicking on Navigation Link:

Will be grateful for any suggestions on how I can achieve the same behavior (half screen Properties Frame) as NavigationView in NavigationStack. Leaving the code as NavigationView (Deprecated) in iOS16 does still work.

Or does it means, I should move away from the above half screen design. It is still useful to see the changes to the Main Content when changing the properties.

Replies

Hi,

If I can't go with NavigationStack. Any recommendations or workarounds are also sincerely appreciated. Thanks.