mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
Add accessibility actions for opening attachments
This commit is contained in:
parent
eb57176a8f
commit
1f21c3fe3f
3 changed files with 19 additions and 6 deletions
|
@ -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: "")
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -88,7 +88,8 @@ final class StatusBodyView: UIView {
|
|||
})
|
||||
}
|
||||
|
||||
self.accessibilityCustomActions = accessibilityCustomActions
|
||||
self.accessibilityCustomActions =
|
||||
accessibilityCustomActions + attachmentsView.attachmentViewAccessibilityCustomActions
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue