NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Nested Navigation Views

Forums > SwiftUI


I am trying to programmatically nest lists within each other so the app transitions like NavigationLinks towards the right, and you can progressively step in and out of lists, but the Navigation Bar keeps expanding (image in the StackOverflow link below). Is there a better way to structure and implement this than NavigationViews?

My data structure is as follows, some children may have nested arrays (I can change this). Eg:

  "Business": "Energy", "Industrials", "Finance" : [{"Banking", "Markets"}],
  "Tech": {"Developers", "Startups", "FAANG", "Indie"},
  "Current Affairs"

This StackOverflow discussion says there should only be one NavigationView.

When I used NavigationLinks without declaring it in a NavigationView for a "middle" child views ("Finance" or "Tech"), the back button goes directly to the root view, but I would like for it traverse the prior views too. For example, News -> Business -> Finance -> Banking, and then using the back button to go from Banking -> Finance -> Business -> News rather than Banking -> News

Using .navigationBarHidden(true) on the root and middle views ends up showing 2 or more back buttons as shown in this image

I'm trying to replicate the UI for browsing Spotify's Podcast Categories, but I have subcategories too.

I would really appreciate any help or pointers for this!


Hacking with Swift is sponsored by Stream

SPONSORED Check out Stream's cross-platform open source chat SDK on GitHub! Write once and deploy your app with fully featured chat UI on iOS and macOS.

Go to GitHub

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.