I'm trying out working on a reminder app with SwiftUI. My ContentView has a list of reminders in a ForEach, which opens each reminder in a ReminderView. The main ContentView has a state variable isModal which shows a modal sheet when trying to edit a particular reminder, so I have the .onTapGesture in the ForEach, instead of inside each ReminderView struct.
However, it appears that whenever we tap any reminder, it just thinks we tapped the first one. Any way to fix this?
ForEach(model.reminders, id: \.self) { reminder in
ReminderView(reminder: reminder)
.onTapGesture {
self.isEModal = true
}
.sheet(isPresented: $isEModal, content: {
EditView(model: self, reminder: reminder)
})
.frame(height: geometry.size.height * 0.08)
}