From 11e27d20d909515626c6182eb684e3019f3bf9ab Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:00:32 -0800 Subject: [PATCH] Improve profile VoiceOver --- Localizations/Localizable.strings | 1 + Views/UIKit/AccountHeaderView.swift | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index d5c29f6..4a740ab 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -21,6 +21,7 @@ "account.follows-you" = "Follows you"; "account.header.accessibility-label-%@" = "Header image: %@"; "account.hide-reblogs" = "Hide boosts"; +"account.locked.accessibility-label" = "Locked account"; "account.mute" = "Mute"; "account.reject-follow-request-button.accessibility-label" = "Reject follow request"; "account.request" = "Request"; diff --git a/Views/UIKit/AccountHeaderView.swift b/Views/UIKit/AccountHeaderView.swift index fbd71fb..a88b43a 100644 --- a/Views/UIKit/AccountHeaderView.swift +++ b/Views/UIKit/AccountHeaderView.swift @@ -75,6 +75,19 @@ final class AccountHeaderView: UIView { accountLabel.text = accountViewModel.accountName lockedImageView.isHidden = !accountViewModel.isLocked + var accountStackViewAccessibilityLabel = accountViewModel.accountName + + if !lockedImageView.isHidden { + accountStackViewAccessibilityLabel + .appendWithSeparator(NSLocalizedString("account.locked.accessibility-label", comment: "")) + } + + if !followsYouLabel.isHidden, let followsYouText = followsYouLabel.text { + accountStackViewAccessibilityLabel.appendWithSeparator(followsYouText) + } + + accountStackView.accessibilityLabel = accountStackViewAccessibilityLabel + for view in fieldsStackView.arrangedSubviews { fieldsStackView.removeArrangedSubview(view) view.removeFromSuperview() @@ -276,6 +289,7 @@ private extension AccountHeaderView { baseStackView.addArrangedSubview(accountStackView) accountStackView.spacing = .compactSpacing + accountStackView.isAccessibilityElement = true accountStackView.addArrangedSubview(accountLabel) accountLabel.numberOfLines = 0