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:
@@ -162,15 +162,19 @@ struct TimelineItemMenu: View {
|
||||
.foregroundColor(reactionBackgroundColor(for: emoji)))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.accessibilityLabel(hasReacted(to: emoji) ? L10n.a11yRemoveReaction(emoji) : L10n.a11yAddReaction(emoji))
|
||||
}
|
||||
|
||||
private func hasReacted(to emoji: String) -> Bool {
|
||||
if let reaction = item.properties.reactions.first(where: { $0.key == emoji }),
|
||||
reaction.isHighlighted {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private func reactionBackgroundColor(for emoji: String) -> Color {
|
||||
if let reaction = item.properties.reactions.first(where: { $0.key == emoji }),
|
||||
reaction.isHighlighted {
|
||||
return .compound.bgActionPrimaryRest
|
||||
} else {
|
||||
return .clear
|
||||
}
|
||||
hasReacted(to: emoji) ? .compound.bgActionPrimaryRest : .clear
|
||||
}
|
||||
|
||||
private func viewsForActions(_ actions: [TimelineItemMenuAction]) -> some View {
|
||||
|
||||
@@ -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