VoiceOver improvement

This commit is contained in:
Justin Mazzocchi 2021-02-16 23:06:41 -08:00
parent 872a8722af
commit 8a7bf4ddb6
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 29 additions and 8 deletions

View file

@ -149,8 +149,10 @@
"identities.pending" = "Pending"; "identities.pending" = "Pending";
"lists.new-list-title" = "New List Title"; "lists.new-list-title" = "New List Title";
"load-more" = "Load More"; "load-more" = "Load More";
"load-more.newer.accessibility-label" = "Load newer items"; "load-more.above.accessibility-label.post" = "Load posts from post above";
"load-more.older.accessibility-label" = "Load older items"; "load-more.above.accessibility-label.toot" = "Load toots from toot above";
"load-more.below.accessibility-label.post" = "Load posts from post below";
"load-more.below.accessibility-label.toot" = "Load toots from toot below";
"main-navigation.timelines" = "Timelines"; "main-navigation.timelines" = "Timelines";
"main-navigation.explore" = "Explore"; "main-navigation.explore" = "Explore";
"main-navigation.notifications" = "Notifications"; "main-navigation.notifications" = "Notifications";

View file

@ -211,7 +211,8 @@ extension CollectionItemsViewModel: CollectionViewModel {
let viewModel = LoadMoreViewModel( let viewModel = LoadMoreViewModel(
loadMoreService: collectionService.navigationService.loadMoreService(loadMore: loadMore), loadMoreService: collectionService.navigationService.loadMoreService(loadMore: loadMore),
eventsSubject: eventsSubject) eventsSubject: eventsSubject,
identityContext: identityContext)
viewModelCache[item] = viewModel viewModelCache[item] = viewModel

View file

@ -6,14 +6,17 @@ import ServiceLayer
public final class LoadMoreViewModel: ObservableObject { public final class LoadMoreViewModel: ObservableObject {
public var direction = LoadMore.Direction.up public var direction = LoadMore.Direction.up
@Published public private(set) var loading = false @Published public private(set) var loading = false
public let identityContext: IdentityContext
private let loadMoreService: LoadMoreService private let loadMoreService: LoadMoreService
private let eventsSubject: PassthroughSubject<AnyPublisher<CollectionItemEvent, Error>, Never> private let eventsSubject: PassthroughSubject<AnyPublisher<CollectionItemEvent, Error>, Never>
init(loadMoreService: LoadMoreService, init(loadMoreService: LoadMoreService,
eventsSubject: PassthroughSubject<AnyPublisher<CollectionItemEvent, Error>, Never>) { eventsSubject: PassthroughSubject<AnyPublisher<CollectionItemEvent, Error>, Never>,
identityContext: IdentityContext) {
self.loadMoreService = loadMoreService self.loadMoreService = loadMoreService
self.eventsSubject = eventsSubject self.eventsSubject = eventsSubject
self.identityContext = identityContext
} }
} }

View file

@ -110,17 +110,32 @@ private extension LoadMoreView {
isAccessibilityElement = true isAccessibilityElement = true
accessibilityLabel = NSLocalizedString("load-more", comment: "") accessibilityLabel = NSLocalizedString("load-more", comment: "")
let aboveAccessibilityActionName: String
let belowAccessibilityActionName: String
switch loadMoreConfiguration.viewModel.identityContext.appPreferences.statusWord {
case .toot:
aboveAccessibilityActionName = NSLocalizedString("load-more.above.accessibility-label.toot", comment: "")
belowAccessibilityActionName = NSLocalizedString("load-more.below.accessibility-label.toot", comment: "")
case .post:
aboveAccessibilityActionName = NSLocalizedString("load-more.above.accessibility-label.post", comment: "")
belowAccessibilityActionName = NSLocalizedString("load-more.below.accessibility-label.post", comment: "")
}
accessibilityCustomActions = [ accessibilityCustomActions = [
UIAccessibilityCustomAction( UIAccessibilityCustomAction(
name: NSLocalizedString("load-more.older.accessibility-label", comment: "")) { [weak self] _ in name: aboveAccessibilityActionName) { [weak self] _ in
self?.loadMoreConfiguration.viewModel.direction = .down self?.directionChange = -Self.directionChangeMax
self?.updateDirectionChange(animated: false)
self?.loadMoreConfiguration.viewModel.loadMore() self?.loadMoreConfiguration.viewModel.loadMore()
return true return true
}, },
UIAccessibilityCustomAction( UIAccessibilityCustomAction(
name: NSLocalizedString("load-more.newer.accessibility-label", comment: "")) { [weak self] _ in name: belowAccessibilityActionName) { [weak self] _ in
self?.loadMoreConfiguration.viewModel.direction = .up self?.directionChange = Self.directionChangeMax
self?.updateDirectionChange(animated: false)
self?.loadMoreConfiguration.viewModel.loadMore() self?.loadMoreConfiguration.viewModel.loadMore()
return true return true