Michael Long
Mar 1, 2024

--

It's somewhat axiomatic from my perspective that a view in a given module must NOT know where it's being presented. The fact that the host application is using a tab view is irrelevant. It could well decided to use a hamburger or popup menu or whatever.

As such, it's up to the application to setup the environment (NavigationStack) in which the view will operated. That may in a tab view, or it could be in a Split View, or it could be presented in a sheet or cover.

The trick is coming up with a mechanism where modules (which can't see each other and which have no knowledge of the host application) can request that the application navigate to some other location within the app.

"Hey, app! I know there's a settings screen somewhere. Take the user there please!"

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet