mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
improved reactions a11y
This commit is contained in:
@@ -138,11 +138,24 @@ struct TimelineCollapseButtonLabel: View {
|
||||
}
|
||||
|
||||
struct TimelineReactionButton: View {
|
||||
@Environment(\.accessibilityVoiceOverEnabled) private var voiceOverEnabled
|
||||
|
||||
let reaction: AggregatedReaction
|
||||
let toggleReaction: (String) -> Void
|
||||
let showReactionSummary: (String) -> Void
|
||||
@ScaledMetric(relativeTo: .subheadline) private var lineHeight = 20
|
||||
|
||||
private var accessibilityLabel: String {
|
||||
if reaction.isHighlighted {
|
||||
return reaction.count > 1 ? L10n.tr("Localizable", "screen_room_timeline_reaction_including_you_a11y", reaction.count - 1, reaction.displayKey) : L10n.screenRoomTimelineReactionYouA11y(reaction.displayKey)
|
||||
}
|
||||
return L10n.tr("Localizable", "screen_room_timeline_reaction_a11y", reaction.count, reaction.displayKey)
|
||||
}
|
||||
|
||||
private var toggleReactionAccessibilityActionName: String {
|
||||
reaction.isHighlighted ? L10n.a11yRemoveReaction(reaction.displayKey) : L10n.a11yAddReaction(reaction.displayKey)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
label
|
||||
.onTapGesture {
|
||||
@@ -151,8 +164,12 @@ struct TimelineReactionButton: View {
|
||||
.longPressWithFeedback {
|
||||
showReactionSummary(reaction.key)
|
||||
}
|
||||
.accessibilityHint(L10n.commonReaction)
|
||||
.accessibilityAddTraits(reaction.isHighlighted ? .isSelected : [])
|
||||
.accessibilityAddTraits(.isButton)
|
||||
.accessibilityLabel(accessibilityLabel)
|
||||
.accessibilityHint(toggleReactionAccessibilityActionName)
|
||||
.accessibilityAction(named: L10n.screenRoomTimelineReactionsShowReactionsSummary) {
|
||||
showReactionSummary(reaction.key)
|
||||
}
|
||||
}
|
||||
|
||||
var label: some View {
|
||||
|
||||
Reference in New Issue
Block a user