A11y: added a hint to inform the user that max selections have been reached (#4308)

* a11y added a hint to inform the user that max selections have been reached

* added string
This commit is contained in:
Mauro
2025-07-08 17:33:47 +02:00
committed by GitHub
parent c60fd88577
commit b816f0cf56
4 changed files with 31 additions and 10 deletions
@@ -92,19 +92,33 @@ struct PollView: View {
private var optionsView: some View {
ForEach(poll.options, id: \.id) { option in
Button {
guard !option.isSelected else { return }
actionHandler(.selectOption(optionID: option.id))
feedbackGenerator.impactOccurred()
} label: {
PollOptionView(pollOption: option,
showVotes: showVotes,
isFinalResult: poll.hasEnded)
.foregroundColor(progressBarColor(for: option))
if #available(iOS 18, *) {
pollOption(option: option)
.accessibilityHint(L10n.a11yPollsWillRemoveSelection,
isEnabled: isRemovePreviousSelectionHintEnabled(option: option))
} else {
pollOption(option: option)
}
.disabled(poll.hasEnded)
}
}
private func isRemovePreviousSelectionHintEnabled(option: Poll.Option) -> Bool {
!poll.hasEnded && poll.hasMaxSelections && !option.isSelected
}
private func pollOption(option: Poll.Option) -> some View {
Button {
guard !option.isSelected else { return }
actionHandler(.selectOption(optionID: option.id))
feedbackGenerator.impactOccurred()
} label: {
PollOptionView(pollOption: option,
showVotes: showVotes,
isFinalResult: poll.hasEnded)
.foregroundColor(progressBarColor(for: option))
}
.disabled(poll.hasEnded)
}
@ViewBuilder
private var summaryView: some View {