mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
implemented a11y for galleries
This commit is contained in:
@@ -21,6 +21,24 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
|
||||
action()
|
||||
}
|
||||
}
|
||||
// A gallery is a container so that each of its attachments can be focussed on its own.
|
||||
// Everything that isn't an attachment is announced when entering it, as the caption and
|
||||
// the send info are hidden where they're shown to avoid being read twice.
|
||||
case let timelineItem as GalleryRoomTimelineItem:
|
||||
content
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel { _ in
|
||||
Text(timelineItem.sender.displayName ?? timelineItem.sender.id)
|
||||
if let caption = timelineItem.content.caption, !caption.isBlank {
|
||||
Text(caption)
|
||||
}
|
||||
Text(timelineItem.localizedSendInfo)
|
||||
}
|
||||
.accessibilityActions {
|
||||
Button(L10n.commonMessageActions) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
case let timelineItem as EventBasedTimelineItemProtocol:
|
||||
content
|
||||
.accessibilityRepresentation {
|
||||
|
||||
@@ -18,6 +18,8 @@ extension View {
|
||||
modifier(TimelineItemSendInfoModifier(sendInfo: .init(timelineItem: timelineItem,
|
||||
adjustedDeliveryStatus: adjustedDeliveryStatus,
|
||||
hasContentScanningFailure: hasContentScanningFailure),
|
||||
// A gallery announces this when entering it instead.
|
||||
isAccessibilityHidden: timelineItem is GalleryRoomTimelineItem,
|
||||
context: context))
|
||||
}
|
||||
}
|
||||
@@ -25,6 +27,7 @@ extension View {
|
||||
/// Adds the send info to a view with the correct layout.
|
||||
private struct TimelineItemSendInfoModifier: ViewModifier {
|
||||
let sendInfo: TimelineItemSendInfo
|
||||
let isAccessibilityHidden: Bool
|
||||
let context: TimelineViewModel.Context
|
||||
|
||||
var layout: AnyLayout {
|
||||
@@ -43,6 +46,7 @@ private struct TimelineItemSendInfoModifier: ViewModifier {
|
||||
content
|
||||
|
||||
TimelineItemSendInfoLabel(sendInfo: sendInfo)
|
||||
.accessibilityHidden(isAccessibilityHidden)
|
||||
.contentShape(.rect)
|
||||
// Tap gesture to avoid the message being detected as a button by VoiceOver
|
||||
// (and the action shows a description that is already read to the user).
|
||||
|
||||
Reference in New Issue
Block a user