From 19bf6cbf18f130032d86aa09a4baf728600bf3ce Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 4 Dec 2022 13:49:45 -0500 Subject: [PATCH] VoiceOver: Add show profile rotor action to timeline statuses Closes #285 --- .../Status/TimelineStatusCollectionViewCell.swift | 10 ++++++++-- Tusker/Views/Status/TimelineStatusTableViewCell.swift | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 1216a6f0..6b9a24f0 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -429,10 +429,16 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti override var accessibilityCustomActions: [UIAccessibilityCustomAction]? { get { - guard let text = contentTextView.attributedText else { + guard let text = contentTextView.attributedText, + let status = mastodonController.persistentContainer.status(for: statusID) else { return nil } - var actions: [UIAccessibilityCustomAction] = [] + var actions = [ + UIAccessibilityCustomAction(name: "Show \(status.account.displayNameWithoutCustomEmoji)", actionHandler: { [unowned self] _ in + self.delegate?.selected(account: status.account.id) + return true + }) + ] text.enumerateAttribute(.link, in: NSRange(location: 0, length: text.length)) { value, range, stop in guard let value = value as? URL else { return diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index d80a98a3..6af737ad 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -310,10 +310,16 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { override var accessibilityCustomActions: [UIAccessibilityCustomAction]? { get { - guard let text = contentTextView.attributedText else { + guard let text = contentTextView.attributedText, + let status = mastodonController.persistentContainer.status(for: statusID) else { return nil } - var actions: [UIAccessibilityCustomAction] = [] + var actions = [ + UIAccessibilityCustomAction(name: "Show \(status.account.displayNameWithoutCustomEmoji)", actionHandler: { [unowned self] _ in + self.delegate?.selected(account: status.account.id) + return true + }) + ] text.enumerateAttribute(.link, in: NSRange(location: 0, length: text.length)) { value, range, stop in guard let value = value as? URL else { return