0

I have a list and inside each cell there are multiple navigation links to different views, I thought it was possible but it doesn't work properly, here is an example:

struct ContentView: View {
    var body: some View {
        NavigationView {
            
            List(0..<10) { index in
                HStack {
                    NavigationLink(destination: A()) {
                        Text("\(index) - Destination 1")
                    }
                    
                    NavigationLink(destination: B()) {
                        Text("\(index) - Destination 2")
                    }
                } .padding()
            }
            
        }
    }
}

Is there a workaround or should I rewrite everything using a lazyVStack instead of a list? I'd prefer to use a list since it has built-in swipe and pull to refresh gestures

6pounder
  • 67
  • 7
  • 1
    Yes, it is. This https://stackoverflow.com/a/63497954/12299030 and this https://stackoverflow.com/a/61188788/12299030 should be helpful. – Asperi Dec 06 '21 at 16:00
  • @Asperi thanks but unfortunately it's not suitable for me because with your solution you need to already know the upcoming views and also the data, it works for one layer but if you need to use it more than once it isn't because data may not be available – 6pounder Dec 06 '21 at 16:56
  • It was not obvious from your question. Then look at this https://stackoverflow.com/a/62909832/12299030 and entire topic. – Asperi Dec 06 '21 at 16:58

0 Answers0