From 7763d08816ada88fd87ada080ac489e4d034b571 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 4 Dec 2022 13:50:10 -0500 Subject: [PATCH] VoiceOver: Fix not being able to select account from conversation main status cell --- .../ConversationMainStatusTableViewCell.swift | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift index 186fdecf..d15f9ced 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift @@ -26,12 +26,12 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { @IBOutlet weak var totalReblogsButton: UIButton! @IBOutlet weak var timestampAndClientLabel: UILabel! - var profileAccessibilityElement: UIAccessibilityElement! + private var profileAccessibilityElement: ConversationMainStatusProfileAccessibilityElement! override func awakeFromNib() { super.awakeFromNib() - profileAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self) + profileAccessibilityElement = ConversationMainStatusProfileAccessibilityElement(accessibilityContainer: self) profileAccessibilityElement.accessibilityFrameInContainerSpace = profileDetailContainerView.convert(profileDetailContainerView.frame, to: self) accessibilityElements = [ profileAccessibilityElement!, @@ -101,8 +101,8 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { override func updateUI(account: AccountMO) { super.updateUI(account: account) - - profileAccessibilityElement.accessibilityLabel = account.displayNameWithoutCustomEmoji + profileAccessibilityElement.navigationDelegate = delegate + profileAccessibilityElement.accountID = account.id } override func updateUIForPreferences(account: AccountMO, status: StatusMO) { @@ -130,6 +130,27 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { } } +private class ConversationMainStatusProfileAccessibilityElement: UIAccessibilityElement { + var navigationDelegate: TuskerNavigationDelegate! + var mastodonController: MastodonController { navigationDelegate.apiController } + var accountID: String! + + override var accessibilityLabel: String? { + get { mastodonController.persistentContainer.account(for: accountID)?.displayNameWithoutCustomEmoji } + set {} + } + + override var accessibilityHint: String? { + get { "Double tap to show profile." } + set {} + } + + override func accessibilityActivate() -> Bool { + navigationDelegate.selected(account: accountID) + return true + } +} + extension ConversationMainStatusTableViewCell: UIContextMenuInteractionDelegate { func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { return UIContextMenuConfiguration(identifier: nil) {