diff options
| author | Fuwn <[email protected]> | 2026-02-23 11:18:18 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-23 13:33:42 -0800 |
| commit | 6a1fd75d265c7e85c538cca07cbaea7e7da8fec7 (patch) | |
| tree | ebee4775b0a133b558429efc8edba11b445028eb /Sora | |
| parent | fix: guard post detail url actions against invalid urls (diff) | |
| download | sora-testing-6a1fd75d265c7e85c538cca07cbaea7e7da8fec7.tar.xz sora-testing-6a1fd75d265c7e85c538cca07cbaea7e7da8fec7.zip | |
feat: add explicit accessibility metadata for grid cells
Diffstat (limited to 'Sora')
| -rw-r--r-- | Sora/Views/FavoritesView.swift | 23 | ||||
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 23 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Sora/Views/FavoritesView.swift b/Sora/Views/FavoritesView.swift index a0357da..1217441 100644 --- a/Sora/Views/FavoritesView.swift +++ b/Sora/Views/FavoritesView.swift @@ -642,6 +642,29 @@ struct FavoritesView: View { // swiftlint:disable:this type_body_length Label("Delete", systemImage: "trash") } } + .accessibilityElement(children: .ignore) + .accessibilityLabel(Text(favoriteAccessibilityLabel(for: favorite))) + .accessibilityValue(Text(favoriteAccessibilityValue(for: favorite))) + .accessibilityHint(Text("Opens post details.")) + } + + private func favoriteAccessibilityLabel(for favorite: SettingsFavoritePost) -> String { + let tagSummary = favorite.tags + .prefix(3) + .map { tag in + tag.replacingOccurrences(of: "_", with: " ") + } + .joined(separator: ", ") + + if tagSummary.isEmpty { + return "Favorite post \(favorite.postId)" + } + + return tagSummary + } + + private func favoriteAccessibilityValue(for favorite: SettingsFavoritePost) -> String { + "Rating \(favorite.rating.rawValue.uppercased()). Provider \(favorite.provider.rawValue)." } } diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 7a7b5fa..37c207e 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -514,6 +514,10 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length Label("Add to Collection", systemImage: "folder.badge.plus") } } + .accessibilityElement(children: .ignore) + .accessibilityLabel(Text(postAccessibilityLabel(for: post))) + .accessibilityValue(Text(postAccessibilityValue(for: post))) + .accessibilityHint(Text("Opens post details.")) } private func isFavoritedInFolder(post: BooruPost, folderId: UUID) -> Bool { @@ -536,6 +540,25 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length } } + private func postAccessibilityLabel(for post: BooruPost) -> String { + let tagSummary = post.tags + .prefix(3) + .map { tag in + tag.replacingOccurrences(of: "_", with: " ") + } + .joined(separator: ", ") + + if tagSummary.isEmpty { + return "Post \(post.id)" + } + + return tagSummary + } + + private func postAccessibilityValue(for post: BooruPost) -> String { + "Rating \(post.rating.rawValue.uppercased()). Score \(post.score)." + } + // MARK: - Local Search Methods private func performLocalSearch() async { let inputTags = localSearchText.components(separatedBy: .whitespaces).filter { component in |