I am a newbie in swift development with iOS. Currently I have started a project in Swift with SwiftUI that has different hierarchies of views. There are different switches between the views. I have attached a picture (architectur). My current problem is that switching between the views does not work properly for the right area (if no credentials are available) (consequently, of course, not for the left area either).
Currently I use NavigationView because I want to support iOS 15. In the @main I have placed the NavigationView and in this is the StartView as parent root. I tried to switch from the child views with the navigation link, using tag and selection via a button as the example for iOS 15 in this tutorial. Another attempt was the following code, in which currently only the right area and the mainview are implemented:
final class NavigationManager: ObservableObject {
@Published var view: Views? {
didSet {
print("View \(view)")
}
}
func push(to view: Views) {
self.view = view
}
func popToRoot() {
view = nil
}
}
enum Views {
case startView
case loginView
case mainView
case aboutView
case cred1View
case cred2View
}
Unfortunately the navigation does not work as desired. Does anyone have any tips on navigation for the architecture I mentioned?