mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
Accessibility wip
This commit is contained in:
parent
c6d644feaf
commit
783a44a67e
7 changed files with 43 additions and 4 deletions
|
@ -250,6 +250,9 @@
|
|||
"status.visibility.private.description" = "Visible for followers only";
|
||||
"status.visibility.direct.description" = "Visible for mentioned users only";
|
||||
"submit" = "Submit";
|
||||
"tag.accessibility-recent-uses-%ld" = "%ld recent uses";
|
||||
"tag.accessibility-hint.post" = "View posts associated with trend";
|
||||
"tag.accessibility-hint.toot" = "View toots associated with trend";
|
||||
"timelines.home" = "Home";
|
||||
"timelines.local" = "Local";
|
||||
"timelines.federated" = "Federated";
|
||||
|
|
|
@ -36,6 +36,8 @@ final class ExploreViewController: UICollectionViewController {
|
|||
collectionView.dataSource = dataSource
|
||||
collectionView.backgroundColor = .systemBackground
|
||||
collectionView.contentInset.bottom = Self.bottomInset
|
||||
collectionView.isAccessibilityElement = false
|
||||
collectionView.shouldGroupAccessibilityChildren = true
|
||||
clearsSelectionOnViewWillAppear = true
|
||||
|
||||
collectionView.refreshControl = UIRefreshControl()
|
||||
|
|
|
@ -276,7 +276,7 @@ extension CollectionItemsViewModel: CollectionViewModel {
|
|||
return cachedViewModel
|
||||
}
|
||||
|
||||
let viewModel = TagViewModel(tag: tag)
|
||||
let viewModel = TagViewModel(tag: tag, identityContext: identityContext)
|
||||
|
||||
cache(viewModel: viewModel, forItem: item)
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public extension ExploreViewModel {
|
|||
}
|
||||
|
||||
func viewModel(tag: Tag) -> TagViewModel {
|
||||
.init(tag: tag)
|
||||
.init(tag: tag, identityContext: identityContext)
|
||||
}
|
||||
|
||||
func select(item: ExploreViewModel.Item) {
|
||||
|
|
|
@ -5,12 +5,14 @@ import Foundation
|
|||
import Mastodon
|
||||
|
||||
public struct TagViewModel: CollectionItemViewModel {
|
||||
public let identityContext: IdentityContext
|
||||
public let events: AnyPublisher<AnyPublisher<CollectionItemEvent, Error>, Never>
|
||||
|
||||
private let tag: Tag
|
||||
|
||||
init(tag: Tag) {
|
||||
init(tag: Tag, identityContext: IdentityContext) {
|
||||
self.tag = tag
|
||||
self.identityContext = identityContext
|
||||
events = Empty().eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ private extension InstanceView {
|
|||
stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor),
|
||||
imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: 16 / 9)
|
||||
])
|
||||
|
||||
setupAccessibility()
|
||||
}
|
||||
|
||||
func applyInstanceConfiguration() {
|
||||
|
@ -80,5 +82,11 @@ private extension InstanceView {
|
|||
|
||||
titleLabel.text = viewModel.instance.title
|
||||
uriLabel.text = viewModel.instance.uri
|
||||
|
||||
accessibilityLabel = viewModel.instance.title.appending("\n").appending(viewModel.instance.uri)
|
||||
}
|
||||
|
||||
func setupAccessibility() {
|
||||
isAccessibilityElement = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,17 +84,23 @@ private extension TagView {
|
|||
lineChartView.heightAnchor.constraint(equalTo: usesLabel.heightAnchor),
|
||||
lineChartView.widthAnchor.constraint(equalTo: lineChartView.heightAnchor, multiplier: 16 / 9)
|
||||
])
|
||||
|
||||
setupAccessibility()
|
||||
}
|
||||
|
||||
func applyTagConfiguration() {
|
||||
let viewModel = tagConfiguration.viewModel
|
||||
var accessibilityLabel = viewModel.name
|
||||
|
||||
nameLabel.text = viewModel.name
|
||||
|
||||
if let accounts = viewModel.accounts {
|
||||
accountsLabel.text = String.localizedStringWithFormat(
|
||||
let accountsText = String.localizedStringWithFormat(
|
||||
NSLocalizedString("tag.people-talking", comment: ""),
|
||||
accounts)
|
||||
accountsLabel.text = accountsText
|
||||
accessibilityLabel.append("\n")
|
||||
accessibilityLabel.append(accountsText)
|
||||
accountsLabel.isHidden = false
|
||||
} else {
|
||||
accountsLabel.isHidden = true
|
||||
|
@ -103,11 +109,29 @@ private extension TagView {
|
|||
if let uses = viewModel.uses {
|
||||
usesLabel.text = String(uses)
|
||||
usesLabel.isHidden = false
|
||||
let accessibilityRecentUses = String.localizedStringWithFormat(
|
||||
NSLocalizedString("tag.accessibility-recent-uses-%ld", comment: ""),
|
||||
uses)
|
||||
accessibilityLabel.append("\n")
|
||||
accessibilityLabel.append(accessibilityRecentUses)
|
||||
} else {
|
||||
usesLabel.isHidden = true
|
||||
}
|
||||
|
||||
lineChartView.values = viewModel.usageHistory.reversed()
|
||||
lineChartView.isHidden = viewModel.usageHistory.isEmpty
|
||||
|
||||
self.accessibilityLabel = accessibilityLabel
|
||||
|
||||
switch viewModel.identityContext.appPreferences.statusWord {
|
||||
case .toot:
|
||||
accessibilityHint = NSLocalizedString("tag.accessibility-hint.toot", comment: "")
|
||||
case .post:
|
||||
accessibilityHint = NSLocalizedString("tag.accessibility-hint.post", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
func setupAccessibility() {
|
||||
isAccessibilityElement = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue