I would like to have multiple NavigationLink
inside the same List
row to replicate a CollectionView
behaviour.
Here is my code :
var body: some View {
NavigationView {
ZStack {
Color(.black)
.edgesIgnoringSafeArea(.all)
VStack(alignment: .center, spacing: 10) {
SearchBar(text: $searchViewModel.searchText)
List {
ForEach(0..<searchViewModel.items.count, id: \.self) { index in
HStack(alignment: .center, spacing: 10) {
ForEach(self.searchViewModel.items[index], id: \.id) { item in
self.cellFor(item)
}
Spacer()
}
}
}
}
}
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
func movieCellFor(_ item: SearchItemViewModel) -> some View {
return NavigationLink(destination: MovieDetails(movieId: item.sourceId)) {
cellUiFor(item)
}
}
If I tap one of my cells, it just seems to "consume" every NavigationLink in the row. I think this is because of the default List
behaviour. Is there a way to prevent it and to put multiple NavigationLink
in a row ?
I know that i could put my content into a ScrollView
and a VStack
but i'd like to keep the reuse system of the List
component.
EDIT:
func movieCellFor(_ item: SearchItemViewModel) -> some View {
return Button(action: {}) {
NavigationLink(destination: MovieDetails(movieId: item.sourceId)) { cellUiFor(item) }
}