Add bottom padding to iOS timeline so it’s possible to scroll items out of view so they get marked-read. (Only when the setting is on.)

This commit is contained in:
Brent Simmons committed 2026-12-05 08:37:58 -08:00
1 parent 4204273031
commit c75e2ceefc
1 file changed
+22
@@ -29,6 +29,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
private var markReadBehavior = AppDefaults.markReadBehavior {
didSet {
if markReadBehavior != oldValue {
updateBottomPaddingForMarkReadOnScroll()
noteRowsScrolledPast()
}
}
@@ -244,6 +245,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
updateToolbarProgressView()
updateBottomPaddingForMarkReadOnScroll()
coordinator?.timelineDidLayout()
}
@@ -611,6 +613,11 @@ extension MainTimelineViewController: UICollectionViewDelegate {
}
}
/// The navigation bar’s height changes as the search bar collapses and expands.
func scrollViewDidChangeAdjustedContentInset(_ scrollView: UIScrollView) {
updateBottomPaddingForMarkReadOnScroll()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard markReadBehavior == .selectionAndScrolledPast else {
return
@@ -1154,6 +1161,21 @@ private extension MainTimelineViewController {
private extension MainTimelineViewController {
/// Adds empty space after the last row, the height of the area between the navigation bar and the toolbar, so every row can scroll under the navigation bar.
func updateBottomPaddingForMarkReadOnScroll() {
guard let collectionView else {
return
}
var bottomPadding: CGFloat = 0
if markReadBehavior == .selectionAndScrolledPast {
let systemBottomInset = collectionView.adjustedContentInset.bottom - collectionView.contentInset.bottom
bottomPadding = max(0, collectionView.bounds.height - collectionView.adjustedContentInset.top - systemBottomInset)
}
if collectionView.contentInset.bottom != bottomPadding {
collectionView.contentInset.bottom = bottomPadding
}
}
/// Rows at least `scrolledPastFraction` under the navigation bar or above it.
func numberOfRowsScrolledPast() -> Int {
guard let collectionView else {