Improve TimelineAccessibilityModifier

This commit is contained in:
Alfonso Grillo 2023-11-06 16:56:14 +01:00 committed by Alfonso Grillo
parent f7f3404312
commit 30e8753663
4 changed files with 15 additions and 9 deletions

View File

@ -24,8 +24,18 @@ private struct TimelineAccessibilityModifier: ViewModifier {
switch timelineItem {
case is PollRoomTimelineItem, is VoiceMessageRoomTimelineItem:
content
case let timelineItem as EventBasedTimelineItemProtocol:
content
.accessibilityRepresentation {
VStack {
Text(timelineItem.sender.displayName ?? timelineItem.sender.id)
content
}
}
.accessibilityElement(children: .combine)
default:
content.accessibilityElement(children: .combine)
content
.accessibilityElement(children: .combine)
}
}
}

View File

@ -87,6 +87,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
.lineLimit(1)
.padding(.vertical, senderNameVerticalPadding)
}
// sender info are read inside the `TimelineAccessibilityModifier`
.accessibilityHidden(true)
.onTapGesture {
context.send(viewAction: .tappedOnUser(userID: timelineItem.sender.id))
@ -99,14 +100,6 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
// Figma overlaps reactions by 3
VStack(alignment: alignment, spacing: -3) {
messageBubble
.accessibilityRepresentation {
VStack(spacing: 0) {
Text(timelineItem.sender.displayName ?? timelineItem.sender.id)
// Workaround: fixes VoiceOver frames offset when children accessibility element aren't combined
.frame(height: 0)
messageBubble
}
}
.timelineAccessibility(timelineItem)
if !timelineItem.properties.reactions.isEmpty {

View File

@ -114,6 +114,8 @@ struct TimelineItemPlainStylerView<Content: View>: View {
.font(.compound.bodyXS)
}
.padding(.top, 16)
// sender info are read inside the `TimelineAccessibilityModifier`
.accessibilityHidden(true)
}
}

View File

@ -54,6 +54,7 @@ struct PollRoomTimelineView: View {
Image(asset.name)
.resizable()
.frame(width: iconSize, height: iconSize)
.accessibilityHidden(true)
Text(poll.question)
.multilineTextAlignment(.leading)