Accessibility improvements (#1603)

* Add an a11y hint to the navigationbar title

* Improve accessibility for merge contexts

* Improve accessibility for merge summaries

* Improve accessibility for the merge button
This commit is contained in:
Bas Broek
2018-03-05 03:36:48 +01:00
committed by Ryan Nystrom
parent ddddb6363f
commit 39dcc7145e
6 changed files with 41 additions and 4 deletions

View File

@@ -122,7 +122,10 @@ IssueManagingNavSectionControllerDelegate {
navigationTitle.configure(
title: "#\(model.number)",
subtitle: "\(model.owner)/\(model.repo)",
accessibilityLabel: labelString
accessibilityLabel: labelString,
accessibilityHint: NSLocalizedString(
"Gives the option to view the repository's overview or owner",
comment: "The hint for tapping the navigationBar's repository information.")
)
navigationItem.titleView = navigationTitle

View File

@@ -20,6 +20,7 @@ final class IssueMergeContextCell: IssueCommentBaseCell, ListBindable {
override init(frame: CGRect) {
super.init(frame: frame)
isAccessibilityElement = true
contentView.addSubview(avatarView)
contentView.addSubview(iconView)
@@ -28,6 +29,7 @@ final class IssueMergeContextCell: IssueCommentBaseCell, ListBindable {
avatarView.clipsToBounds = true
avatarView.layer.cornerRadius = Styles.Sizes.avatarCornerRadius
avatarView.accessibilityIgnoresInvertColors = true
avatarView.snp.makeConstraints { make in
make.size.equalTo(Styles.Sizes.icon)
make.centerY.equalToSuperview()
@@ -83,6 +85,9 @@ final class IssueMergeContextCell: IssueCommentBaseCell, ListBindable {
}
iconView.image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
iconView.tintColor = iconColor
let stateString = viewModel.state.rawValue.lowercased()
accessibilityLabel = .localizedStringWithFormat("Status for %@: %@. Context: %@.", viewModel.context, stateString, viewModel.description)
}
}

View File

@@ -17,6 +17,7 @@ final class IssueMergeSummaryCell: IssueCommentBaseCell, ListBindable {
override init(frame: CGRect) {
super.init(frame: frame)
isAccessibilityElement = true
contentView.addSubview(imageView)
contentView.addSubview(label)
@@ -67,6 +68,7 @@ final class IssueMergeSummaryCell: IssueCommentBaseCell, ListBindable {
}
imageView.backgroundColor = imageViewBackground
imageView.image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
accessibilityLabel = .localizedStringWithFormat("%@. (state: %@)", viewModel.title, viewModel.state.description)
}
}

View File

@@ -11,11 +11,24 @@ import IGListKit
final class IssueMergeSummaryModel: ListDiffable {
enum State: Int {
enum State: Int, CustomStringConvertible {
case success
case pending
case failure
case warning
var description: String {
switch self {
case .success:
return NSLocalizedString("success", comment: "The merge status' success state")
case .pending:
return NSLocalizedString("pending", comment: "The merge status' pending state")
case .failure:
return NSLocalizedString("failure", comment: "The merge status' failure state")
case .warning:
return NSLocalizedString("warning", comment: "The merge status' warning state")
}
}
}
let title: String

View File

@@ -27,6 +27,8 @@ final class MergeButton: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
isAccessibilityElement = true
accessibilityTraits |= UIAccessibilityTraitButton
addSubview(mergeLabel)
addSubview(optionIconView)
@@ -36,9 +38,11 @@ final class MergeButton: UIView {
layer.cornerRadius = Styles.Sizes.avatarCornerRadius
let image = UIImage(named: "chevron-down")?.withRenderingMode(.alwaysTemplate)
let optionButtonWidth = (image?.size.width ?? 0) + 2*Styles.Sizes.gutter
let optionButtonWidth = (image?.size.width ?? 0) + (2 * Styles.Sizes.gutter)
optionIconView.contentMode = .center
optionIconView.image = image
optionIconView.isAccessibilityElement = true
optionIconView.accessibilityTraits |= UIAccessibilityTraitButton
optionIconView.snp.makeConstraints { make in
make.top.right.bottom.equalToSuperview()
make.width.equalTo(optionButtonWidth)
@@ -94,6 +98,10 @@ final class MergeButton: UIView {
} else {
activityView.stopAnimating()
}
accessibilityLabel = title
// FIXME: This is currently not accessible in VoiceOver.
optionIconView.accessibilityLabel = NSLocalizedString("More merging options", comment: "More options button for merging")
}
// MARK: Overrides

View File

@@ -86,7 +86,12 @@ final class NavigationTitleDropdownView: UIControl {
// MARK: Public API
func configure(title: String?, subtitle: String?, accessibilityLabel: String? = nil) {
func configure(
title: String?,
subtitle: String?,
accessibilityLabel: String? = nil,
accessibilityHint: String? = nil
) {
guard let title = title else { return }
let titleAttributes: [NSAttributedStringKey: Any] = [
@@ -106,6 +111,7 @@ final class NavigationTitleDropdownView: UIControl {
label.attributedText = attributedTitle
self.accessibilityLabel = accessibilityLabel ?? title
self.accessibilityHint = accessibilityHint
}
// MARK: Private API