Fix load more accessibility custom actions

This commit is contained in:
Justin Mazzocchi 2021-02-18 00:22:24 -08:00
parent dcc22bf260
commit 8e1a654479
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
2 changed files with 17 additions and 2 deletions

View file

@ -383,6 +383,18 @@ private extension TableViewController {
.merge(with: NotificationCenter.default.publisher(for: NewStatusViewController.newStatusPostedNotification))
.sink { [weak self] _ in self?.refreshIfAble() }
.store(in: &cancellables)
NotificationCenter.default.publisher(for: LoadMoreView.accessibilityCustomAction)
.sink { [weak self] notification in
guard let self = self,
let loadMoreView = notification.object as? LoadMoreView,
let cell = self.tableView.visibleCells.first(where: { $0.contentView === loadMoreView }),
let indexPath = self.tableView.indexPath(for: cell)
else { return }
self.tableView(self.tableView, didSelectRowAt: indexPath)
}
.store(in: &cancellables)
}
func update(_ update: CollectionUpdate) {

View file

@ -28,6 +28,9 @@ final class LoadMoreView: UIView {
}
extension LoadMoreView {
static let accessibilityCustomAction =
Notification.Name("com.metabolist.metatext.load-more-view.accessibility-custom-action")
static var estimatedHeight: CGFloat {
.defaultSpacing * 2 + UIFont.preferredFont(forTextStyle: .title2).lineHeight
}
@ -128,7 +131,7 @@ private extension LoadMoreView {
name: aboveAccessibilityActionName) { [weak self] _ in
self?.directionChange = -Self.directionChangeMax
self?.updateDirectionChange(animated: false)
self?.loadMoreConfiguration.viewModel.loadMore()
NotificationCenter.default.post(name: Self.accessibilityCustomAction, object: self)
return true
},
@ -136,7 +139,7 @@ private extension LoadMoreView {
name: belowAccessibilityActionName) { [weak self] _ in
self?.directionChange = Self.directionChangeMax
self?.updateDirectionChange(animated: false)
self?.loadMoreConfiguration.viewModel.loadMore()
NotificationCenter.default.post(name: Self.accessibilityCustomAction, object: self)
return true
}