From c75e2ceefcb7d632c6d8fe3019d48148f166e7af Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 5 Dec 2026 08:37:58 -0800 Subject: [PATCH] =?UTF-8?q?Add=20bottom=20padding=20to=20iOS=20timeline=20?= =?UTF-8?q?so=20it=E2=80=99s=20possible=20to=20scroll=20items=20out=20of?= =?UTF-8?q?=20view=20so=20they=20get=20marked-read.=20(Only=20when=20the?= =?UTF-8?q?=20setting=20is=20on.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainTimelineViewController.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index 31103833a..7e9bb185e 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -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 {