From 38eea44a8b8059fa183e39f8ac6670d168009955 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 5 Feb 2023 13:33:42 -0500 Subject: [PATCH] VoiceOver improvements on fast account switcher Closes #310 --- .../FastAccountSwitcherViewController.swift | 20 +++++++++++++++++++ .../FastSwitchingAccountView.swift | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/Tusker/Screens/Fast Account Switcher/FastAccountSwitcherViewController.swift b/Tusker/Screens/Fast Account Switcher/FastAccountSwitcherViewController.swift index aa4ca4cd..408e10ce 100644 --- a/Tusker/Screens/Fast Account Switcher/FastAccountSwitcherViewController.swift +++ b/Tusker/Screens/Fast Account Switcher/FastAccountSwitcherViewController.swift @@ -42,6 +42,8 @@ class FastAccountSwitcherViewController: UIViewController { view.isHidden = true + view.accessibilityViewIsModal = true + view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))) accountsStack.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))) } @@ -67,10 +69,16 @@ class FastAccountSwitcherViewController: UIViewController { view.isHidden = false + func completion() { + UIAccessibility.post(notification: .screenChanged, argument: accountViews.first) + } + if UIAccessibility.prefersCrossFadeTransitions { view.alpha = 0 UIView.animate(withDuration: 0.2, delay: 0, options: [.curveEaseInOut, .allowUserInteraction]) { self.view.alpha = 1 + } completion: { _ in + completion() } } else { let totalDuration: TimeInterval = 0.5 @@ -95,6 +103,8 @@ class FastAccountSwitcherViewController: UIViewController { accountView.transform = .identity } } + } completion: { _ in + completion() } } } @@ -114,6 +124,8 @@ class FastAccountSwitcherViewController: UIViewController { self.view.isHidden = true completion?() self.view.removeFromSuperview() + + UIAccessibility.post(notification: .screenChanged, argument: nil) } } @@ -271,6 +283,14 @@ class FastAccountSwitcherViewController: UIViewController { super.touchesBegan(touches, with: event) } + + override func accessibilityPerformEscape() -> Bool { + guard !view.isHidden else { + return false + } + hide() + return true + } } diff --git a/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift b/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift index 3f1733c2..e5930cf7 100644 --- a/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift +++ b/Tusker/Screens/Fast Account Switcher/FastSwitchingAccountView.swift @@ -117,6 +117,8 @@ class FastSwitchingAccountView: UIView { } updateLabelColors() + + isAccessibilityElement = true } private func setupAccount(account: LocalData.UserAccountInfo) { @@ -134,12 +136,16 @@ class FastSwitchingAccountView: UIView { } } } + + accessibilityLabel = "\(account.username!)@\(account.instanceURL.host!)" } private func setupPlaceholder() { usernameLabel.text = "Add Account" instanceLabel.isHidden = true avatarImageView.image = UIImage(systemName: "plus") + + accessibilityLabel = "Add Account" } private func updateLabelColors() {