Hello! As you can see on the image I have the following problem: I have a tab view with tags and a tab bar(see code below). This tab bar brings me to View 1, 2, 3 and 4. Inside of these Views I have Navigationlinks, that bring me to their subviews. The problem? Now I want a Navigationlink from View 1 to View 2. I might also have to navigate from for example View1->subview to View2 ->subview. For this, I tried wrapping the Tabview into a NavigationView and deleting all other Navigationviews, but that caused weird UI behavior and also didn’t switch to a different screen. I also thought about changing the tabIndex of the Tabview, but then I can’t switch between subviews, and passing around data gets complicated. What is a good way of solving this?
struct MainView: View {
@State var tabIndex = 1
var body: some View {
TabView(selection: $tabIndex) {
View1()
.tabItem {
Label("1", systemImage: "list.dash")
}.tag(0)
View2()
.tabItem {
Label("2", systemImage: "square.and.pencil")
}.tag(1)
View3()
.tabItem {
Label("3", systemImage: "bus.fill")
}.tag(2)
View4()
.tabItem {
Label("4", systemImage: "sun.min")
}.tag(3)
}
}
}