Given a pretty basic TCA View
with a List
populated by a ViewStore
, how to know which cell in the list is tapped? in onTapGesture
, there is no access to the item, since its a scope above. If you add a onTapGesture
to the Text
, it will not trigger when tapping the whole cell.
WithViewStore(self.store) { viewStore in
NavigationView {
List {
ForEach(viewStore.state.listItems, id: \.self) { item in
Text(item.title)
}
}.onTapGesture {
print("Tapped row, but no access to item")
}
}
}