Since SwiftUI's NavigationView
is extremely rigid and does not provide an easy way for programatic navigation, I wanted to create an AppNavigationView
that has an array of views and updates its rendered view based on push/pop.
Because a SwiftUI view is a protocol with an associatedType, I cannot either create an array of Views or even pass a few in my public func pushView(view:View)
.
So how can I store a list of View structs?
// Error: Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements.
@State var navigationStack: [View]