mirror of
https://github.com/metabolist/metatext.git
synced 2025-02-16 14:05:14 +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.private.description" = "Visible for followers only";
|
||||||
"status.visibility.direct.description" = "Visible for mentioned users only";
|
"status.visibility.direct.description" = "Visible for mentioned users only";
|
||||||
"submit" = "Submit";
|
"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.home" = "Home";
|
||||||
"timelines.local" = "Local";
|
"timelines.local" = "Local";
|
||||||
"timelines.federated" = "Federated";
|
"timelines.federated" = "Federated";
|
||||||
|
|
|
@ -36,6 +36,8 @@ final class ExploreViewController: UICollectionViewController {
|
||||||
collectionView.dataSource = dataSource
|
collectionView.dataSource = dataSource
|
||||||
collectionView.backgroundColor = .systemBackground
|
collectionView.backgroundColor = .systemBackground
|
||||||
collectionView.contentInset.bottom = Self.bottomInset
|
collectionView.contentInset.bottom = Self.bottomInset
|
||||||
|
collectionView.isAccessibilityElement = false
|
||||||
|
collectionView.shouldGroupAccessibilityChildren = true
|
||||||
clearsSelectionOnViewWillAppear = true
|
clearsSelectionOnViewWillAppear = true
|
||||||
|
|
||||||
collectionView.refreshControl = UIRefreshControl()
|
collectionView.refreshControl = UIRefreshControl()
|
||||||
|
|
|
@ -276,7 +276,7 @@ extension CollectionItemsViewModel: CollectionViewModel {
|
||||||
return cachedViewModel
|
return cachedViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
let viewModel = TagViewModel(tag: tag)
|
let viewModel = TagViewModel(tag: tag, identityContext: identityContext)
|
||||||
|
|
||||||
cache(viewModel: viewModel, forItem: item)
|
cache(viewModel: viewModel, forItem: item)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public extension ExploreViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
func viewModel(tag: Tag) -> TagViewModel {
|
func viewModel(tag: Tag) -> TagViewModel {
|
||||||
.init(tag: tag)
|
.init(tag: tag, identityContext: identityContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
func select(item: ExploreViewModel.Item) {
|
func select(item: ExploreViewModel.Item) {
|
||||||
|
|
|
@ -5,12 +5,14 @@ import Foundation
|
||||||
import Mastodon
|
import Mastodon
|
||||||
|
|
||||||
public struct TagViewModel: CollectionItemViewModel {
|
public struct TagViewModel: CollectionItemViewModel {
|
||||||
|
public let identityContext: IdentityContext
|
||||||
public let events: AnyPublisher<AnyPublisher<CollectionItemEvent, Error>, Never>
|
public let events: AnyPublisher<AnyPublisher<CollectionItemEvent, Error>, Never>
|
||||||
|
|
||||||
private let tag: Tag
|
private let tag: Tag
|
||||||
|
|
||||||
init(tag: Tag) {
|
init(tag: Tag, identityContext: IdentityContext) {
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
|
self.identityContext = identityContext
|
||||||
events = Empty().eraseToAnyPublisher()
|
events = Empty().eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ private extension InstanceView {
|
||||||
stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor),
|
stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor),
|
||||||
imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: 16 / 9)
|
imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: 16 / 9)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
setupAccessibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyInstanceConfiguration() {
|
func applyInstanceConfiguration() {
|
||||||
|
@ -80,5 +82,11 @@ private extension InstanceView {
|
||||||
|
|
||||||
titleLabel.text = viewModel.instance.title
|
titleLabel.text = viewModel.instance.title
|
||||||
uriLabel.text = viewModel.instance.uri
|
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.heightAnchor.constraint(equalTo: usesLabel.heightAnchor),
|
||||||
lineChartView.widthAnchor.constraint(equalTo: lineChartView.heightAnchor, multiplier: 16 / 9)
|
lineChartView.widthAnchor.constraint(equalTo: lineChartView.heightAnchor, multiplier: 16 / 9)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
setupAccessibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyTagConfiguration() {
|
func applyTagConfiguration() {
|
||||||
let viewModel = tagConfiguration.viewModel
|
let viewModel = tagConfiguration.viewModel
|
||||||
|
var accessibilityLabel = viewModel.name
|
||||||
|
|
||||||
nameLabel.text = viewModel.name
|
nameLabel.text = viewModel.name
|
||||||
|
|
||||||
if let accounts = viewModel.accounts {
|
if let accounts = viewModel.accounts {
|
||||||
accountsLabel.text = String.localizedStringWithFormat(
|
let accountsText = String.localizedStringWithFormat(
|
||||||
NSLocalizedString("tag.people-talking", comment: ""),
|
NSLocalizedString("tag.people-talking", comment: ""),
|
||||||
accounts)
|
accounts)
|
||||||
|
accountsLabel.text = accountsText
|
||||||
|
accessibilityLabel.append("\n")
|
||||||
|
accessibilityLabel.append(accountsText)
|
||||||
accountsLabel.isHidden = false
|
accountsLabel.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
accountsLabel.isHidden = true
|
accountsLabel.isHidden = true
|
||||||
|
@ -103,11 +109,29 @@ private extension TagView {
|
||||||
if let uses = viewModel.uses {
|
if let uses = viewModel.uses {
|
||||||
usesLabel.text = String(uses)
|
usesLabel.text = String(uses)
|
||||||
usesLabel.isHidden = false
|
usesLabel.isHidden = false
|
||||||
|
let accessibilityRecentUses = String.localizedStringWithFormat(
|
||||||
|
NSLocalizedString("tag.accessibility-recent-uses-%ld", comment: ""),
|
||||||
|
uses)
|
||||||
|
accessibilityLabel.append("\n")
|
||||||
|
accessibilityLabel.append(accessibilityRecentUses)
|
||||||
} else {
|
} else {
|
||||||
usesLabel.isHidden = true
|
usesLabel.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
lineChartView.values = viewModel.usageHistory.reversed()
|
lineChartView.values = viewModel.usageHistory.reversed()
|
||||||
lineChartView.isHidden = viewModel.usageHistory.isEmpty
|
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