mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-24 17:20:59 +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.player = nil
|
||||||
playerView.isHidden = true
|
playerView.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func selectAttachment() {
|
||||||
|
parentViewModel.attachmentSelected(viewModel: viewModel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension AttachmentView {
|
private extension AttachmentView {
|
||||||
|
@ -136,11 +140,7 @@ private extension AttachmentView {
|
||||||
selectionButton.translatesAutoresizingMaskIntoConstraints = false
|
selectionButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
selectionButton.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
|
selectionButton.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
|
||||||
selectionButton.addAction(
|
selectionButton.addAction(
|
||||||
UIAction { [weak self] _ in
|
UIAction { [weak self] _ in self?.selectAttachment() },
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
self.parentViewModel.attachmentSelected(viewModel: self.viewModel)
|
|
||||||
},
|
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
selectionButton.accessibilityLabel = NSLocalizedString("compose.attachment.edit", comment: "")
|
selectionButton.accessibilityLabel = NSLocalizedString("compose.attachment.edit", comment: "")
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,18 @@ extension AttachmentsView {
|
||||||
|
|
||||||
return viewModel.attachmentViewModels.allSatisfy(\.shouldAutoplay)
|
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 {
|
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