Skip to content

Commit 11e4303

Browse files
committed
Improve voting UX by making it possible taping the option as well
1 parent ac6b1c9 commit 11e4303

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,7 @@ struct PollOptionView: View {
198198
HStack(alignment: .top, spacing: checkboxButtonSpacing) {
199199
if !viewModel.poll.isClosed {
200200
Button {
201-
if viewModel.optionVotedByCurrentUser(option) {
202-
viewModel.removePollVote(for: option)
203-
} else {
204-
viewModel.castPollVote(for: option)
205-
}
201+
togglePollVote()
206202
} label: {
207203
if viewModel.optionVotedByCurrentUser(option) {
208204
Image(systemName: "checkmark.circle.fill")
@@ -239,6 +235,18 @@ struct PollOptionView: View {
239235
}
240236
}
241237
}
238+
.contentShape(Rectangle())
239+
.onTapGesture {
240+
togglePollVote()
241+
}
242+
}
243+
244+
func togglePollVote() {
245+
if viewModel.optionVotedByCurrentUser(option) {
246+
viewModel.removePollVote(for: option)
247+
} else {
248+
viewModel.castPollVote(for: option)
249+
}
242250
}
243251
}
244252

0 commit comments

Comments
 (0)