Merge pull request #520 from j-f1/account-switcher-a11y

Improve accessibility of the account switcher
This commit is contained in:
CMK 2022-11-16 18:51:17 +08:00 committed by GitHub
commit c2bb14eaab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 29 deletions

View File

@ -13,15 +13,15 @@
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>zero</key>
<string>no unread notification</string>
<string>no unread notifications</string>
<key>one</key>
<string>1 unread notification</string>
<key>few</key>
<string>%ld unread notifications</string>
<key>many</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
<key>other</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
</dict>
</dict>
<key>a11y.plural.count.input_limit_exceeds</key>

View File

@ -13,15 +13,15 @@
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>zero</key>
<string>no unread notification</string>
<string>no unread notifications</string>
<key>one</key>
<string>1 unread notification</string>
<key>few</key>
<string>%ld unread notifications</string>
<key>many</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
<key>other</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
</dict>
</dict>
<key>a11y.plural.count.input_limit_exceeds</key>

View File

@ -166,7 +166,7 @@ extension AccountListViewModel {
cell.badgeButton.accessibilityLabel
]
.compactMap { $0 }
.joined(separator: " ")
.joined(separator: ", ")
}
}

View File

@ -34,7 +34,9 @@ final class AccountListViewController: UIViewController, NeedsDependency {
return barButtonItem
}()
let dragIndicatorView = DragIndicatorView()
lazy var dragIndicatorView = DragIndicatorView { [weak self] in
self?.dismiss(animated: true, completion: nil)
}
var hasLoaded = false
private(set) lazy var tableView: UITableView = {
@ -130,14 +132,6 @@ extension AccountListViewController {
self.panModalTransition(to: .shortForm)
}
.store(in: &disposeBag)
if UIAccessibility.isVoiceOverRunning {
let dragIndicatorTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
dragIndicatorView.addGestureRecognizer(dragIndicatorTapGestureRecognizer)
dragIndicatorTapGestureRecognizer.addTarget(self, action: #selector(AccountListViewController.dragIndicatorTapGestureRecognizerHandler(_:)))
dragIndicatorView.isAccessibilityElement = true
dragIndicatorView.accessibilityLabel = L10n.Scene.AccountList.dismissAccountSwitcher
}
}
private func setupBackgroundColor(theme: Theme) {
@ -160,10 +154,11 @@ extension AccountListViewController {
logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
_ = coordinator.present(scene: .welcome, from: self, transition: .modal(animated: true, completion: nil))
}
@objc private func dragIndicatorTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
override func accessibilityPerformEscape() -> Bool {
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)")
dismiss(animated: true, completion: nil)
return true
}
}

View File

@ -69,6 +69,7 @@ extension AccountListTableViewCell {
])
avatarButton.setContentHuggingPriority(.defaultLow, for: .horizontal)
avatarButton.setContentHuggingPriority(.defaultLow, for: .vertical)
avatarButton.isAccessibilityElement = false
let labelContainerStackView = UIStackView()
labelContainerStackView.axis = .vertical
@ -124,6 +125,8 @@ extension AccountListTableViewCell {
badgeButton.setBadge(number: 0)
checkmarkImageView.isHidden = true
accessibilityTraits.insert(.button)
}
}

View File

@ -108,6 +108,8 @@ extension AddAccountTableViewCell {
separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)),
])
accessibilityTraits.insert(.button)
}
}

View File

@ -15,17 +15,17 @@ final class DragIndicatorView: UIView {
let barView = UIView()
let separatorLine = UIView.separatorLine
let onDismiss: () -> Void
override init(frame: CGRect) {
super.init(frame: frame)
init(onDismiss: @escaping () -> Void) {
self.onDismiss = onDismiss
super.init(frame: .zero)
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
fatalError("init(coder:) is not supported")
}
}
extension DragIndicatorView {
@ -52,6 +52,14 @@ extension DragIndicatorView {
separatorLine.bottomAnchor.constraint(equalTo: bottomAnchor),
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: self)),
])
isAccessibilityElement = true
accessibilityTraits = .button
accessibilityLabel = L10n.Scene.AccountList.dismissAccountSwitcher
}
override func accessibilityActivate() -> Bool {
self.onDismiss()
return true
}
}

View File

@ -306,12 +306,11 @@ extension MainTabBarController {
guard user.managedObjectContext != nil else { return }
self.avatarURL = user.avatarImageURL()
}
// a11y
let _profileTabItem = self.tabBar.items?.first { item in item.tag == Tab.me.tag }
guard let profileTabItem = _profileTabItem else { return }
let currentUserDisplayName = user.displayNameWithFallback ?? "no user"
profileTabItem.accessibilityHint = L10n.Scene.AccountList.tabBarHint(currentUserDisplayName)
profileTabItem.accessibilityHint = L10n.Scene.AccountList.tabBarHint(user.displayNameWithFallback)
context.authenticationService.updateActiveUserAccountPublisher
.sink { [weak self] in

View File

@ -13,15 +13,15 @@
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>zero</key>
<string>no unread notification</string>
<string>no unread notifications</string>
<key>one</key>
<string>1 unread notification</string>
<key>few</key>
<string>%ld unread notifications</string>
<key>many</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
<key>other</key>
<string>%ld unread notification</string>
<string>%ld unread notifications</string>
</dict>
</dict>
<key>a11y.plural.count.input_limit_exceeds</key>