mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 17:50:59 +00:00
Ensure table view is laid out properly
This commit is contained in:
parent
d556d7986e
commit
9f350d1305
1 changed files with 18 additions and 14 deletions
|
@ -115,10 +115,6 @@ class TableViewController: UITableViewController {
|
||||||
for loadMoreView in visibleLoadMoreViews {
|
for loadMoreView in visibleLoadMoreViews {
|
||||||
loadMoreView.directionChanged(up: up)
|
loadMoreView.directionChanged(up: up)
|
||||||
}
|
}
|
||||||
|
|
||||||
if newItemsView.alpha > 0 {
|
|
||||||
hideNewItemsView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
||||||
|
@ -183,14 +179,6 @@ class TableViewController: UITableViewController {
|
||||||
|
|
||||||
sizeTableHeaderFooterViews()
|
sizeTableHeaderFooterViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool {
|
|
||||||
if newItemsView.alpha > 0 {
|
|
||||||
hideNewItemsView()
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.accessibilityScroll(direction)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TableViewController {
|
extension TableViewController {
|
||||||
|
@ -408,8 +396,20 @@ private extension TableViewController {
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
tableView.publisher(for: \.contentOffset)
|
tableView.publisher(for: \.contentOffset)
|
||||||
|
.removeDuplicates()
|
||||||
|
.handleEvents(receiveOutput: { [weak self] _ in
|
||||||
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
if (self.newItemsView.layer.animationKeys() ?? []).isEmpty, self.newItemsView.alpha > 0 {
|
||||||
|
self.hideNewItemsView()
|
||||||
|
}
|
||||||
|
})
|
||||||
.compactMap { [weak self] _ in self?.tableView.indexPathsForVisibleRows?.first }
|
.compactMap { [weak self] _ in self?.tableView.indexPathsForVisibleRows?.first }
|
||||||
.sink { [weak self] in self?.viewModel.viewedAtTop(indexPath: $0) }
|
.sink { [weak self] in
|
||||||
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
self.viewModel.viewedAtTop(indexPath: $0)
|
||||||
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
NotificationCenter.default.publisher(for: UIScene.willEnterForegroundNotification)
|
NotificationCenter.default.publisher(for: UIScene.willEnterForegroundNotification)
|
||||||
|
@ -477,6 +477,8 @@ private extension TableViewController {
|
||||||
} else if setPreviousOffset {
|
} else if setPreviousOffset {
|
||||||
self.tableView.contentOffset.y = preUpdateContentOffsetY
|
self.tableView.contentOffset.y = preUpdateContentOffsetY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.tableView.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,7 +801,7 @@ private extension TableViewController {
|
||||||
self.newItemsViewVisibleConstraint?.isActive = true
|
self.newItemsViewVisibleConstraint?.isActive = true
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
} completion: { _ in
|
} completion: { _ in
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,6 +811,8 @@ private extension TableViewController {
|
||||||
self.newItemsViewHiddenConstraint?.isActive = true
|
self.newItemsViewHiddenConstraint?.isActive = true
|
||||||
self.newItemsViewVisibleConstraint?.isActive = false
|
self.newItemsViewVisibleConstraint?.isActive = false
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
|
} completion: { _ in
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue