Notification a11y actions (#1890)

* Add custom a11y actions for notification cell actions

* Cleanup
This commit is contained in:
Bas Broek
2018-07-09 20:48:31 +02:00
committed by Ryan Nystrom
parent 8452d73ab9
commit 5cf550684a
5 changed files with 33 additions and 6 deletions

View File

@@ -73,7 +73,7 @@ final class IssueCommentDetailCell: IssueCommentBaseCell, ListBindable {
moreButton.imageView?.contentMode = .center
moreButton.tintColor = Styles.Colors.Gray.light.color
moreButton.addTarget(self, action: #selector(IssueCommentDetailCell.onMore(sender:)), for: .touchUpInside)
moreButton.accessibilityLabel = NSLocalizedString("More options", comment: "")
moreButton.accessibilityLabel = Constants.Strings.moreOptions
contentView.addSubview(moreButton)
moreButton.snp.makeConstraints { make in
make.size.equalTo(Styles.Sizes.buttonMin)

View File

@@ -139,7 +139,7 @@ final class NotificationCell: SelectableCell {
}
override var accessibilityLabel: String? {
get { return AccessibilityHelper.generatedLabel(forCell: self)}
get { return AccessibilityHelper.generatedLabel(forCell: self) }
set {}
}
@@ -157,7 +157,7 @@ final class NotificationCell: SelectableCell {
NSAttributedStringKey.foregroundColor: Styles.Colors.Gray.light.color
]
let title = NSMutableAttributedString(string: "\(model.owner)/\(model.repo) ", attributes: titleAttributes)
titleAttributes[NSAttributedStringKey.font] = Styles.Text.secondary.preferredFont
titleAttributes[.font] = Styles.Text.secondary.preferredFont
switch model.number {
case .number(let number): title.append(NSAttributedString(string: "#\(number)", attributes: titleAttributes))
default: break
@@ -182,6 +182,31 @@ final class NotificationCell: SelectableCell {
watchButton.setImage(UIImage(named: "\(watchingImageName)-small")?.withRenderingMode(.alwaysTemplate), for: .normal)
contentView.alpha = model.read ? 0.5 : 1
let watchAccessibilityAction = UIAccessibilityCustomAction(
name: model.watching ?
NSLocalizedString("Unwatch notification", comment: "") :
NSLocalizedString("Watch notification", comment: ""),
target: self,
selector: #selector(onWatch(sender:))
)
let readAccessibilityAction = UIAccessibilityCustomAction(
name: Constants.Strings.markRead,
target: self,
selector: #selector(onRead(sender:))
)
let moreOptionsAccessibilityAction = UIAccessibilityCustomAction(
name: Constants.Strings.moreOptions,
target: self,
selector: #selector(onMore(sender:))
)
var customActions = [watchAccessibilityAction, moreOptionsAccessibilityAction]
if model.read == false {
customActions.append(readAccessibilityAction)
}
accessibilityCustomActions = customActions
}
@objc func onRead(sender: UIView) {

View File

@@ -60,7 +60,7 @@ BaseListViewController2EmptyDataSource {
target: self,
action: #selector(NotificationsViewController.onMore(sender:))
)
item.accessibilityLabel = NSLocalizedString("More options", comment: "")
item.accessibilityLabel = Constants.Strings.moreOptions
navigationItem.leftBarButtonItem = item
case .repo, .all: break
}
@@ -205,7 +205,7 @@ BaseListViewController2EmptyDataSource {
alert.addActions([
UIAlertAction(
title: NSLocalizedString("Mark Read", comment: ""),
title: Constants.Strings.markRead,
style: .destructive,
handler: { [weak self] _ in
self?.markRead()

View File

@@ -23,7 +23,7 @@ NewIssueTableViewControllerDelegate {
var moreOptionsItem: UIBarButtonItem {
let rightItem = UIBarButtonItem(image: UIImage(named: "bullets-hollow"), target: self, action: #selector(RepositoryViewController.onMore(sender:)))
rightItem.accessibilityLabel = NSLocalizedString("More options", comment: "")
rightItem.accessibilityLabel = Constants.Strings.moreOptions
return rightItem
}

View File

@@ -17,6 +17,7 @@ enum Constants {
enum Strings {
static let all = NSLocalizedString("All", comment: "")
static let markRead = NSLocalizedString("Mark Read", comment: "")
static let unread = NSLocalizedString("Unread", comment: "")
static let ok = NSLocalizedString("OK", comment: "")
static let cancel = NSLocalizedString("Cancel", comment: "")
@@ -35,6 +36,7 @@ enum Constants {
static let newIssue = NSLocalizedString("New Issue", comment: "")
static let bullet = "\u{2022}"
static let bulletHollow = "\u{25E6}"
static let moreOptions = NSLocalizedString("More options", comment: "")
static let search = NSLocalizedString("Search", comment: "")
static let searchGitHub = NSLocalizedString("Search GitHub", comment: "Used as a placeholder for the searchbar when searching for repositories.")
static let searchBookmarks = NSLocalizedString("Search Bookmarks", comment: "Used as a placeholder for the searchbar when searching within bookmarks.")