Enhance accessibility for toggle toolbar buttons. Issue #1581

This commit is contained in:
Maurice Parker 2020-01-09 14:38:25 -07:00
parent 75938a8153
commit 3115abc72e
4 changed files with 60 additions and 12 deletions

View File

@ -38,6 +38,24 @@ class ArticleExtractorButton: UIButton {
}
}
override var accessibilityLabel: String? {
get {
switch buttonState {
case .error:
return NSLocalizedString("Error - Reader View", comment: "Error - Reader View")
case .animated:
return NSLocalizedString("Processing - Reader View", comment: "Processing - Reader View")
case .on:
return NSLocalizedString("Selected - Reader View", comment: "Selected - Reader View")
case .off:
return NSLocalizedString("Reader View", comment: "Reader View")
}
}
set {
super.accessibilityLabel = newValue
}
}
override func layoutSubviews() {
super.layoutSubviews()
guard case .animated = buttonState else {

View File

@ -135,11 +135,21 @@ class ArticleViewController: UIViewController {
starBarButtonItem.isEnabled = true
actionBarButtonItem.isEnabled = true
let readImage = article.status.read ? AppAssets.circleOpenImage : AppAssets.circleClosedImage
readBarButtonItem.image = readImage
if article.status.read {
readBarButtonItem.image = AppAssets.circleOpenImage
readBarButtonItem.accLabelText = NSLocalizedString("Mark Article Unread", comment: "Mark Article Unread")
} else {
readBarButtonItem.image = AppAssets.circleClosedImage
readBarButtonItem.accLabelText = NSLocalizedString("Selected - Mark Article Unread", comment: "Selected - Mark Article Unread")
}
let starImage = article.status.starred ? AppAssets.starClosedImage : AppAssets.starOpenImage
starBarButtonItem.image = starImage
if article.status.starred {
starBarButtonItem.image = AppAssets.starClosedImage
starBarButtonItem.accLabelText = NSLocalizedString("Selected - Star Article", comment: "Selected - Star Article")
} else {
starBarButtonItem.image = AppAssets.starOpenImage
starBarButtonItem.accLabelText = NSLocalizedString("Star Article", comment: "Star Article")
}
}

View File

@ -402,10 +402,10 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
@IBAction func toggleFilter(_ sender: Any) {
if coordinator.isReadFeedsFiltered {
filterButton.image = AppAssets.filterInactiveImage
setFilterButtonToInactive()
coordinator.showAllFeeds()
} else {
filterButton.image = AppAssets.filterActiveImage
setFilterButtonToActive()
coordinator.hideReadFeeds()
}
}
@ -674,14 +674,24 @@ private extension MasterFeedViewController {
func updateUI() {
if coordinator.isReadFeedsFiltered {
filterButton?.image = AppAssets.filterActiveImage
setFilterButtonToActive()
} else {
filterButton?.image = AppAssets.filterInactiveImage
setFilterButtonToInactive()
}
refreshProgressView?.updateRefreshLabel()
addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty
}
func setFilterButtonToActive() {
filterButton?.image = AppAssets.filterActiveImage
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Feeds", comment: "Selected - Filter Read Feeds")
}
func setFilterButtonToInactive() {
filterButton?.image = AppAssets.filterInactiveImage
filterButton?.accLabelText = NSLocalizedString("Filter Read Feeds", comment: "Filter Read Feeds")
}
func reloadNode(_ node: Node) {
var snapshot = dataSource.snapshot()
snapshot.reloadItems([node])

View File

@ -112,10 +112,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// MARK: Actions
@IBAction func toggleFilter(_ sender: Any) {
if coordinator.isReadArticlesFiltered {
filterButton.image = AppAssets.filterInactiveImage
setFilterButtonToInactive()
coordinator.showAllArticles()
} else {
filterButton.image = AppAssets.filterActiveImage
setFilterButtonToActive()
coordinator.hideReadArticles()
}
}
@ -579,9 +579,9 @@ private extension MasterTimelineViewController {
}
if coordinator.isReadArticlesFiltered {
filterButton.image = AppAssets.filterActiveImage
setFilterButtonToActive()
} else {
filterButton.image = AppAssets.filterInactiveImage
setFilterButtonToInactive()
}
tableView.selectRow(at: nil, animated: false, scrollPosition: .top)
@ -599,6 +599,16 @@ private extension MasterTimelineViewController {
updateToolbar()
}
func setFilterButtonToActive() {
filterButton?.image = AppAssets.filterActiveImage
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles")
}
func setFilterButtonToInactive() {
filterButton?.image = AppAssets.filterInactiveImage
filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles")
}
func updateToolbar() {
markAllAsReadButton.isEnabled = coordinator.isTimelineUnreadAvailable
firstUnreadButton.isEnabled = coordinator.isTimelineUnreadAvailable