mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Give the media upload preview a descriptive VoiceOver title
The QLPreviewItem used the media's file name as its title, which VoiceOver read as cryptic alt text. Provide a descriptive "Photo preview" / "Video preview" title based on the media type instead. Addresses #5240, #5241.
This commit is contained in:
+10
-1
@@ -264,7 +264,16 @@ private struct PreviewView: UIViewControllerRepresentable {
|
||||
}
|
||||
|
||||
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
|
||||
PreviewItem(previewItemURL: view.mediaURLs[index], previewItemTitle: view.title)
|
||||
let url = view.mediaURLs[index]
|
||||
// Use a descriptive title instead of the file name so VoiceOver doesn't read a cryptic name.
|
||||
return PreviewItem(previewItemURL: url, previewItemTitle: previewItemTitle(for: url))
|
||||
}
|
||||
|
||||
private func previewItemTitle(for url: URL) -> String? {
|
||||
guard let type = UTType(filenameExtension: url.pathExtension) else { return view.title }
|
||||
if type.conforms(to: .image) { return L10n.a11yPhotoPreview }
|
||||
if type.conforms(to: .movie) || type.conforms(to: .video) { return L10n.a11yVideoPreview }
|
||||
return view.title
|
||||
}
|
||||
|
||||
// MARK: - QLPreviewControllerDelegate
|
||||
|
||||
Reference in New Issue
Block a user