3

I have collapse list in main view, i wanna to go in another view when i tap in a child of section in list, i tried but it didint work. Nothing didnt change when i tapped. What im doing wrong ?

 func sectionIndex(section : Theme) -> Int {
    userData.data.firstIndex(where: {$0.name == section.name})!
 }
 var body: some View {
        
        NavigationView {
            List {
                ForEach(userData.data) { section in
                    Section(header: HeaderView(section: section)
                                .onTapGesture {
                                    self.userData.data[self.sectionIndex(section: section)].expanded.toggle()
                                }, footer: EmptyView()) {
                        
                        if section.expanded {
                            
                            ForEach(section.questions!) { question in
                                QuoteView(question: question)
                                    .onTapGesture {
                                        
                                        NavigationLink(destination: DetailView()) {
                                            Text("Do Something")
                                        }
                                        print("dsdsw")
                                    }
                            }
                        }
                    }
                }
            }
        }
        
        
    }
    
    
}


struct DetailView : View {
    var body: some View {
        Text("Hello World B")
    }
}

1 Answer 1

3

I don't know what is QuoteView, but try to put link into background of that view, NavigationView should handle link in it automatically, ie.

ForEach(section.questions!) { question in
    QuoteView(question: question)
        .background (
            NavigationLink(destination: DetailView()) {
                EmptyView() // << content is not needed here
            }
        )
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.