Better accessibility label for conversation toggle collapse button

This commit is contained in:
Shadowfacts 2022-12-14 22:05:17 -05:00
parent 1f37a5e7eb
commit 4b2a263889
1 changed files with 7 additions and 2 deletions

View File

@ -125,7 +125,7 @@ class ConversationTableViewController: EnhancedTableViewController {
})
visibilityBarButtonItem = UIBarButtonItem(image: ConversationTableViewController.showPostsImage, style: .plain, target: self, action: #selector(toggleVisibilityButtonPressed))
visibilityBarButtonItem.isSelected = showStatusesAutomatically
updateVisibilityBarButtonItem()
navigationItem.rightBarButtonItem = visibilityBarButtonItem
// disable transparent background when scroll to top because it looks weird when items earlier in the thread load in
// (it remains transparent slightly too long, resulting in a flash of the content under the transparent bar)
@ -138,6 +138,11 @@ class ConversationTableViewController: EnhancedTableViewController {
}
}
private func updateVisibilityBarButtonItem() {
visibilityBarButtonItem.isSelected = showStatusesAutomatically
visibilityBarButtonItem.accessibilityLabel = showStatusesAutomatically ? "Collapse All" : "Expand All"
}
@MainActor
private func loadMainStatus() async {
guard loadingState == .unloaded else { return }
@ -391,7 +396,7 @@ class ConversationTableViewController: EnhancedTableViewController {
tableView.beginUpdates()
tableView.endUpdates()
visibilityBarButtonItem.isSelected = showStatusesAutomatically
updateVisibilityBarButtonItem()
}
}