Modularised Navigation in SwiftUI ??? An Enum-based Approach

In iOS 16, SwiftUI finally allows us to properly encapsulate navigation without being forced to pass a ton of bindings or using NavigationLink directly in UI.

One thing that always introduces additional challenges, though, is modularisation.

In a best-case scenario, every module functions independently and has zero dependencies on other modules (in the same layer).

While it is possible to achieve that, there is always the need to navigate from one module to the other.

One approach that elegantly solves this issue is the use of enums for internal and external navigation.

Website