Accessibility label audit wip

This commit is contained in:
Justin Mazzocchi 2021-02-01 11:53:47 -08:00
parent 3ca541d37e
commit 9383340843
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 71 additions and 1 deletions

View file

@ -55,16 +55,28 @@
"camera-access.description" = "Open system settings to allow camera access"; "camera-access.description" = "Open system settings to allow camera access";
"camera-access.open-system-settings" = "Open system settings"; "camera-access.open-system-settings" = "Open system settings";
"cancel" = "Cancel"; "cancel" = "Cancel";
"compose.add-button-accessibility-label.post" = "Add another post";
"compose.add-button-accessibility-label.toot" = "Add another toot";
"compose.attachment.uploading" = "Uploading"; "compose.attachment.uploading" = "Uploading";
"compose.attachments-button.accessibility-label" = "Add images, a video or an audio file";
"compose.attachments-will-be-discarded" = "Attachments will be discarded when changing accounts"; "compose.attachments-will-be-discarded" = "Attachments will be discarded when changing accounts";
"compose.browse" = "Browse"; "compose.browse" = "Browse";
"compose.characters-remaining-accessibility-label-%ld" = "%ld characters remaining";
"compose.content-warning-button.add" = "Add content warning";
"compose.content-warning-button.remove" = "Remove content warning";
"compose.emoji-button" = "Emoji picker";
"compose.mark-media-sensitive" = "Mark media as sensitive"; "compose.mark-media-sensitive" = "Mark media as sensitive";
"compose.photo-library" = "Photo Library"; "compose.photo-library" = "Photo Library";
"compose.poll.add-choice" = "Add a choice"; "compose.poll.add-choice" = "Add a choice";
"compose.poll.allow-multiple-choices" = "Allow multiple choices"; "compose.poll.allow-multiple-choices" = "Allow multiple choices";
"compose.poll.option-%ld" = "Option %ld"; "compose.poll.option-%ld" = "Option %ld";
"compose.poll-button.accessibility-label" = "Add a poll";
"compose.prompt" = "What's on your mind?"; "compose.prompt" = "What's on your mind?";
"compose.take-photo-or-video" = "Take Photo or Video"; "compose.take-photo-or-video" = "Take Photo or Video";
"compose.visibility-button.accessibility-label.toot" = "Adjust toot privacy";
"compose.visibility-button.accessibility-label.post" = "Adjust post privacy";
"compose-button.accessibility-label.post" = "Compose Post";
"compose-button.accessibility-label.toot" = "Compose Toot";
"emoji.custom" = "Custom"; "emoji.custom" = "Custom";
"emoji.default-skin-tone" = "Default skin tone"; "emoji.default-skin-tone" = "Default skin tone";
"emoji.frequently-used" = "Frequently used"; "emoji.frequently-used" = "Frequently used";
@ -100,6 +112,7 @@
"secondary-navigation.lists" = "Lists"; "secondary-navigation.lists" = "Lists";
"secondary-navigation.my-profile" = "My Profile"; "secondary-navigation.my-profile" = "My Profile";
"secondary-navigation.preferences" = "Preferences"; "secondary-navigation.preferences" = "Preferences";
"secondary-navigation-button.accessibility-title" = "Account Menu";
"identities.accounts" = "Accounts"; "identities.accounts" = "Accounts";
"identities.browsing" = "Browsing"; "identities.browsing" = "Browsing";
"identities.pending" = "Pending"; "identities.pending" = "Pending";

View file

@ -102,7 +102,7 @@ private extension MainNavigationViewController {
let newStatusNavigationController = UINavigationController(rootViewController: newStatusViewController) let newStatusNavigationController = UINavigationController(rootViewController: newStatusViewController)
if UIDevice.current.userInterfaceIdiom == .phone { if UIDevice.current.userInterfaceIdiom == .phone {
newStatusNavigationController.modalPresentationStyle = .overFullScreen newStatusNavigationController.modalPresentationStyle = .fullScreen
} else { } else {
newStatusNavigationController.isModalInPresentation = true newStatusNavigationController.isModalInPresentation = true
} }
@ -113,6 +113,18 @@ private extension MainNavigationViewController {
view.addSubview(newStatusButtonView) view.addSubview(newStatusButtonView)
newStatusButtonView.translatesAutoresizingMaskIntoConstraints = false newStatusButtonView.translatesAutoresizingMaskIntoConstraints = false
viewModel.identityContext.$appPreferences.map(\.statusWord).removeDuplicates().sink {
switch $0 {
case .toot:
newStatusButtonView.button.accessibilityLabel =
NSLocalizedString("compose-button.accessibility-label.toot", comment: "")
case.post:
newStatusButtonView.button.accessibilityLabel =
NSLocalizedString("compose-button.accessibility-label.post", comment: "")
}
}
.store(in: &cancellables)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
newStatusButtonView.widthAnchor.constraint(equalToConstant: .newStatusButtonDimension), newStatusButtonView.widthAnchor.constraint(equalToConstant: .newStatusButtonDimension),
newStatusButtonView.heightAnchor.constraint(equalToConstant: .newStatusButtonDimension), newStatusButtonView.heightAnchor.constraint(equalToConstant: .newStatusButtonDimension),

View file

@ -69,15 +69,44 @@ private extension CompositionInputAccessoryView {
let attachmentButton = UIBarButtonItem( let attachmentButton = UIBarButtonItem(
image: UIImage(systemName: "paperclip"), image: UIImage(systemName: "paperclip"),
menu: UIMenu(children: attachmentActions)) menu: UIMenu(children: attachmentActions))
attachmentButton.accessibilityLabel =
NSLocalizedString("compose.attachments-button.accessibility-label", comment: "")
let pollButton = UIBarButtonItem( let pollButton = UIBarButtonItem(
image: UIImage(systemName: "chart.bar.xaxis"), image: UIImage(systemName: "chart.bar.xaxis"),
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayPoll.toggle() }) primaryAction: UIAction { [weak self] _ in self?.viewModel.displayPoll.toggle() })
pollButton.accessibilityLabel = NSLocalizedString("compose.poll-button.accessibility-label", comment: "")
let visibilityButton = UIBarButtonItem( let visibilityButton = UIBarButtonItem(
image: UIImage(systemName: parentViewModel.visibility.systemImageName), image: UIImage(systemName: parentViewModel.visibility.systemImageName),
menu: visibilityMenu(selectedVisibility: parentViewModel.visibility)) menu: visibilityMenu(selectedVisibility: parentViewModel.visibility))
switch parentViewModel.identityContext.appPreferences.statusWord {
case .toot:
visibilityButton.accessibilityLabel =
NSLocalizedString("compose.visibility-button.accessibility-label.toot", comment: "")
case .post:
visibilityButton.accessibilityLabel =
NSLocalizedString("compose.visibility-button.accessibility-label.post", comment: "")
}
let contentWarningButton = UIBarButtonItem( let contentWarningButton = UIBarButtonItem(
title: NSLocalizedString("status.content-warning-abbreviation", comment: ""), title: NSLocalizedString("status.content-warning-abbreviation", comment: ""),
primaryAction: UIAction { [weak self] _ in self?.viewModel.displayContentWarning.toggle() }) primaryAction: UIAction { [weak self] _ in self?.viewModel.displayContentWarning.toggle() })
viewModel.$displayContentWarning.sink {
if $0 {
contentWarningButton.accessibilityHint =
NSLocalizedString("compose.content-warning-button.remove", comment: "")
} else {
contentWarningButton.accessibilityHint =
NSLocalizedString("compose.content-warning-button.add", comment: "")
}
}
.store(in: &cancellables)
let emojiButton = UIBarButtonItem( let emojiButton = UIBarButtonItem(
image: UIImage(systemName: "face.smiling"), image: UIImage(systemName: "face.smiling"),
primaryAction: UIAction { [weak self] _ in primaryAction: UIAction { [weak self] _ in
@ -85,6 +114,9 @@ private extension CompositionInputAccessoryView {
self.parentViewModel.presentEmojiPicker(tag: self.tagForInputView) self.parentViewModel.presentEmojiPicker(tag: self.tagForInputView)
}) })
emojiButton.accessibilityLabel = NSLocalizedString("compose.emoji-button", comment: "")
let addButton = UIBarButtonItem( let addButton = UIBarButtonItem(
image: UIImage(systemName: "plus.circle.fill"), image: UIImage(systemName: "plus.circle.fill"),
primaryAction: UIAction { [weak self] _ in primaryAction: UIAction { [weak self] _ in
@ -93,6 +125,15 @@ private extension CompositionInputAccessoryView {
self.parentViewModel.insert(after: self.viewModel) self.parentViewModel.insert(after: self.viewModel)
}) })
switch parentViewModel.identityContext.appPreferences.statusWord {
case .toot:
addButton.accessibilityLabel =
NSLocalizedString("compose.add-button-accessibility-label.toot", comment: "")
case .post:
addButton.accessibilityLabel =
NSLocalizedString("compose.add-button-accessibility-label.post", comment: "")
}
let charactersLabel = UILabel() let charactersLabel = UILabel()
charactersLabel.font = .preferredFont(forTextStyle: .callout) charactersLabel.font = .preferredFont(forTextStyle: .callout)
@ -128,6 +169,9 @@ private extension CompositionInputAccessoryView {
viewModel.$remainingCharacters.sink { viewModel.$remainingCharacters.sink {
charactersLabel.text = String($0) charactersLabel.text = String($0)
charactersLabel.textColor = $0 < 0 ? .systemRed : .label charactersLabel.textColor = $0 < 0 ? .systemRed : .label
charactersLabel.accessibilityLabel = String.localizedStringWithFormat(
NSLocalizedString("compose.characters-remaining-accessibility-label-%ld", comment: ""),
$0)
} }
.store(in: &cancellables) .store(in: &cancellables)

View file

@ -15,6 +15,7 @@ final class SecondaryNavigationButton: UIBarButtonItem {
type: .custom, type: .custom,
primaryAction: UIAction { _ in viewModel.presentingSecondaryNavigation = true }) primaryAction: UIAction { _ in viewModel.presentingSecondaryNavigation = true })
button.accessibilityLabel = NSLocalizedString("secondary-navigation-button.accessibility-title", comment: "")
button.imageView?.contentMode = .scaleAspectFill button.imageView?.contentMode = .scaleAspectFill
button.layer.cornerRadius = .barButtonItemDimension / 2 button.layer.cornerRadius = .barButtonItemDimension / 2
button.clipsToBounds = true button.clipsToBounds = true