Read the number of selected messages to VoiceOver

The count was only on the forward button at the bottom, so VoiceOver
users had to go and find it after every tap. While selecting, each
selectable message now starts its label with "N messages selected".
The label changes on every toggle, so VoiceOver reads the new count
followed by the message, as in other messaging apps.
This commit is contained in:
Mauro Romito
2026-10-01 16:23:32 +02:00
committed by Mauro
parent 8ddd161625
commit e67a4c388f
2 changed files with 12 additions and 3 deletions
@@ -13,7 +13,7 @@ enum TimelineItemAccessibilityMessageSelection {
/// No selection is active, the item offers its regular message actions.
case none
/// A selection is active, the item acts as a toggle when it can be selected.
case selecting(isSelected: Bool)
case selecting(isSelected: Bool, selectedCount: Int)
}
private struct TimelineItemAccessibilityModifier: ViewModifier {
@@ -76,9 +76,13 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
action()
}
}
case .selecting(let isSelected):
case .selecting(let isSelected, let selectedCount):
if let item = timelineItem as? EventBasedTimelineItemProtocol, item.isForwardable {
view
.accessibilityLabel { label in
Text(L10n.screenRoomSelectionCount(selectedCount))
label
}
.accessibilityAddTraits(isSelected ? [.isButton, .isSelected] : .isButton)
.accessibilityAction(.default, action)
} else {