VoiceOver improvements on fast account switcher

Closes #310
This commit is contained in:
Shadowfacts 2023-02-05 13:33:42 -05:00
parent 2d45fbbd91
commit 38eea44a8b
2 changed files with 26 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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() {