0

I have such a code and I can't set up navigation

struct ContentView: View {
    
    var body: some View {
        TabView{
            RootView(title: "Main")
    
                .tabItem{
                    Image(systemName: "house")
                }
            
            RootView(title: "Messages")
                .tabItem{
                    Image(systemName: "message")
                }
        }
    }
}


struct RootView: View{
    let title: String
   
    var body: some View{
        NavigationView{
            List{
                ForEach(0..<10, id: \.self){index in
                    
                    NavigationLink(destination: {
                        Text("123")
                    }, label: {
                        Text("\(index)")
                    })
                }
                
                NavigationLink(destination: {
                    Text("This is new window")
                }, label: {
                    Text("New window")
                })
            }
            .navigationTitle(title)
            
            
        }
       
    }
}

Can I do this on SwiftUI 4 so that when I click on a "New Window" list item, that item opens on top of the TabView in a new window? But so that all the other elements of the list open inside the TabView

dev_nil
  • 89
  • 1
  • 8
  • Is this helpful https://stackoverflow.com/a/73669998/13278922? – Timmy Sep 26 '22 at 07:27
  • @Timmy, no. When I use TableView inside NavigationStack as in that example, when using Navigation Link inside TabView, it throws me to the root window. I would like to make it so that you can choose where to go from TabView to the root window or to the child window. – dev_nil Sep 26 '22 at 08:00
  • Have you searched how to open windows? What have you tried? What isn’t working as desired? – lorem ipsum Sep 26 '22 at 11:06

0 Answers0