diff --git a/Views/UIKit/AttachmentView.swift b/Views/UIKit/AttachmentView.swift index 6da67f2..b9ea517 100644 --- a/Views/UIKit/AttachmentView.swift +++ b/Views/UIKit/AttachmentView.swift @@ -97,6 +97,10 @@ extension AttachmentView { playerView.player = nil playerView.isHidden = true } + + func selectAttachment() { + parentViewModel.attachmentSelected(viewModel: viewModel) + } } private extension AttachmentView { @@ -136,11 +140,7 @@ private extension AttachmentView { selectionButton.translatesAutoresizingMaskIntoConstraints = false selectionButton.setBackgroundImage(.highlightedButtonBackground, for: .highlighted) selectionButton.addAction( - UIAction { [weak self] _ in - guard let self = self else { return } - - self.parentViewModel.attachmentSelected(viewModel: self.viewModel) - }, + UIAction { [weak self] _ in self?.selectAttachment() }, for: .touchUpInside) selectionButton.accessibilityLabel = NSLocalizedString("compose.attachment.edit", comment: "") diff --git a/Views/UIKit/AttachmentsView.swift b/Views/UIKit/AttachmentsView.swift index 515f346..2c9e50d 100644 --- a/Views/UIKit/AttachmentsView.swift +++ b/Views/UIKit/AttachmentsView.swift @@ -131,6 +131,18 @@ extension AttachmentsView { return viewModel.attachmentViewModels.allSatisfy(\.shouldAutoplay) } + + var attachmentViewAccessibilityCustomActions: [UIAccessibilityCustomAction] { + attachmentViews.compactMap { attachmentView in + guard let accessibilityLabel = attachmentView.accessibilityLabel else { return nil } + + return UIAccessibilityCustomAction(name: accessibilityLabel) { _ in + attachmentView.selectAttachment() + + return true + } + } + } } private extension AttachmentsView { diff --git a/Views/UIKit/StatusBodyView.swift b/Views/UIKit/StatusBodyView.swift index d7eb57d..5f3e6de 100644 --- a/Views/UIKit/StatusBodyView.swift +++ b/Views/UIKit/StatusBodyView.swift @@ -88,7 +88,8 @@ final class StatusBodyView: UIView { }) } - self.accessibilityCustomActions = accessibilityCustomActions + self.accessibilityCustomActions = + accessibilityCustomActions + attachmentsView.attachmentViewAccessibilityCustomActions } }