From f43b36dddad068fa8047af087911759f0b98c243 Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 4 Aug 2021 17:06:46 +0800 Subject: [PATCH] fix: animate emoji label break VoiceOver issue --- .../Section/Status/StatusSection.swift | 37 +++++++++++-------- .../Scene/Settings/View/AppearanceView.swift | 14 +++++++ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Mastodon/Diffiable/Section/Status/StatusSection.swift b/Mastodon/Diffiable/Section/Status/StatusSection.swift index c6cde80f..0958ec73 100644 --- a/Mastodon/Diffiable/Section/Status/StatusSection.swift +++ b/Mastodon/Diffiable/Section/Status/StatusSection.swift @@ -106,21 +106,7 @@ extension StatusSection { ) cell.delegate = statusTableViewCellDelegate cell.isAccessibilityElement = true - // FIXME: - cell.accessibilityLabel = { - var accessibilityViews: [UIView?] = [] - if !cell.statusView.headerContainerView.isHidden { - accessibilityViews.append(cell.statusView.headerInfoLabel) - } - accessibilityViews.append(contentsOf: [ - cell.statusView.nameMetaLabel, - cell.statusView.dateLabel, - cell.statusView.contentMetaText.textView, - ]) - return accessibilityViews - .compactMap { $0?.accessibilityLabel } - .joined(separator: " ") - }() + StatusSection.configureStatusAccessibilityLabel(cell: cell) return cell case .status(let objectID, let attribute), .root(let objectID, let attribute), @@ -182,7 +168,7 @@ extension StatusSection { cell.accessibilityElements = accessibilityElements default: cell.isAccessibilityElement = true - cell.accessibilityElements = nil + StatusSection.configureStatusAccessibilityLabel(cell: cell) } return cell case .leafBottomLoader: @@ -1116,6 +1102,25 @@ extension StatusSection { .store(in: &cell.disposeBag) self.setupStatusMoreButtonMenu(cell: cell, dependency: dependency, status: status) } + + static func configureStatusAccessibilityLabel(cell: StatusTableViewCell) { + // FIXME: + cell.accessibilityLabel = { + var accessibilityViews: [UIView?] = [] + if !cell.statusView.headerContainerView.isHidden { + accessibilityViews.append(cell.statusView.headerInfoLabel) + } + accessibilityViews.append(contentsOf: [ + cell.statusView.nameMetaLabel, + cell.statusView.dateLabel, + cell.statusView.contentMetaText.textView, + ]) + return accessibilityViews + .compactMap { $0?.accessibilityLabel } + .joined(separator: " ") + }() + cell.statusView.actionToolbarContainer.isUserInteractionEnabled = !UIAccessibility.isVoiceOverRunning + } } diff --git a/Mastodon/Scene/Settings/View/AppearanceView.swift b/Mastodon/Scene/Settings/View/AppearanceView.swift index e761d46e..fd08fd43 100644 --- a/Mastodon/Scene/Settings/View/AppearanceView.swift +++ b/Mastodon/Scene/Settings/View/AppearanceView.swift @@ -61,6 +61,20 @@ class AppearanceView: UIView { imageView.image = image titleLabel.text = title } + + override var isAccessibilityElement: Bool { + get { return true } + set { } + + } + override var accessibilityLabel: String? { + get { + return [titleLabel.text, checkBox.accessibilityLabel] + .compactMap { $0 } + .joined(separator: ", ") + } + set { } + } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented")