From 98529ca5afb7cb8f87f2e48dccaf78c22dfce59a Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 10 May 2020 12:44:07 -0400 Subject: [PATCH] Remove notifications from the bottom when scrolling up notifications list --- .../NotificationsTableViewController.swift | 27 +++++++++++++++++++ .../TimelineTableViewController.swift | 16 +++-------- .../EnhancedTableViewController.swift | 12 +++++++++ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Tusker/Screens/Notifications/NotificationsTableViewController.swift b/Tusker/Screens/Notifications/NotificationsTableViewController.swift index e5f1061a..70142897 100644 --- a/Tusker/Screens/Notifications/NotificationsTableViewController.swift +++ b/Tusker/Screens/Notifications/NotificationsTableViewController.swift @@ -127,6 +127,33 @@ class NotificationsTableViewController: EnhancedTableViewController { // MARK: - Table view delegate override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + // see TimelineTableViewController.tableView(_:willDisplay:forRowAt:) + if !isCurrentlyScrollingToTop, scrollViewDirection < 0 { + let pageSize = 20 + if groups.count > 2 * pageSize, + indexPath.row < groups.count - (2 * pageSize) { + let groupsToRemove = groups[groups.count - pageSize.. Bool { if let offset = prevScrollToTopOffset { @@ -37,7 +41,15 @@ class EnhancedTableViewController: UITableViewController { prevScrollToTopOffset = nil } + override func scrollViewDidScroll(_ scrollView: UIScrollView) { + if let prev = prevScrollViewContentOffset { + scrollViewDirection = scrollView.contentOffset.y - prev.y + } + prevScrollViewContentOffset = scrollView.contentOffset + } + // MARK: Table View Delegate + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let cell = tableView.cellForRow(at: indexPath) as? SelectableTableViewCell { cell.didSelectCell()