summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Grid/PostGridView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
-rw-r--r--Sora/Views/Post/Grid/PostGridView.swift23
1 files changed, 23 insertions, 0 deletions
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