From 429dcefa889f4fa99ebaf5ae826ef90f90bb8281 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 5 Feb 2023 14:34:01 -0500 Subject: [PATCH] Use consolidated trends screen on iPhone --- .../Explore/ExploreViewController.swift | 55 +++++-------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/Tusker/Screens/Explore/ExploreViewController.swift b/Tusker/Screens/Explore/ExploreViewController.swift index e82b1e6c..03580dac 100644 --- a/Tusker/Screens/Explore/ExploreViewController.swift +++ b/Tusker/Screens/Explore/ExploreViewController.swift @@ -175,19 +175,14 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot) { snapshot.insertSections([.discover], afterSection: .bookmarks) - snapshot.appendItems([.trendingTags], toSection: .discover) - if mastodonController.instanceFeatures.trendingStatusesAndLinks { - snapshot.insertItems([.trendingStatuses], beforeItem: .trendingTags) - snapshot.insertItems([.trendingLinks], afterItem: .trendingTags) - } + snapshot.appendItems([.trends], toSection: .discover) } private func ownInstanceLoaded(_ instance: Instance) { var snapshot = self.dataSource.snapshot() if mastodonController.instanceFeatures.trends, !snapshot.sectionIdentifiers.contains(.discover) { - snapshot.insertSections([.discover], afterSection: .bookmarks) - snapshot.appendItems([.trendingTags], toSection: .discover) + addDiscoverSection(to: &snapshot) } self.dataSource.apply(snapshot) } @@ -339,14 +334,8 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect case .favorites: show(FavoritesViewController(mastodonController: mastodonController), sender: nil) - case .trendingStatuses: - show(TrendingStatusesViewController(mastodonController: mastodonController), sender: nil) - - case .trendingTags: - show(TrendingHashtagsViewController(mastodonController: mastodonController), sender: nil) - - case .trendingLinks: - show(TrendingLinksViewController(mastodonController: mastodonController), sender: nil) + case .trends: + show(TrendsViewController(mastodonController: mastodonController), sender: nil) case let .list(list): show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil) @@ -395,7 +384,7 @@ extension ExploreViewController { case .bookmarks: return nil case .discover: - return NSLocalizedString("Discover", comment: "discover section title") + return nil case .lists: return NSLocalizedString("Lists", comment: "explore lists section title") case .savedHashtags: @@ -409,9 +398,7 @@ extension ExploreViewController { enum Item: Hashable { case bookmarks case favorites - case trendingStatuses - case trendingTags - case trendingLinks + case trends case list(List) case addList case savedHashtag(Hashtag) @@ -425,12 +412,8 @@ extension ExploreViewController { return NSLocalizedString("Bookmarks", comment: "bookmarks nav item title") case .favorites: return NSLocalizedString("Favorites", comment: "favorites nav item title") - case .trendingStatuses: - return NSLocalizedString("Trending Posts", comment: "trending statuses nav item title") - case .trendingTags: - return NSLocalizedString("Trending Hashtags", comment: "trending hashtags nav item title") - case .trendingLinks: - return NSLocalizedString("Trending Links", comment: "trending links nav item title") + case .trends: + return NSLocalizedString("Trends", comment: "trends nav item title") case let .list(list): return list.title case .addList: @@ -453,12 +436,8 @@ extension ExploreViewController { name = "bookmark.fill" case .favorites: name = "star.fill" - case .trendingStatuses: - name = "doc.text.image" - case .trendingTags: - name = "number" - case .trendingLinks: - name = "link" + case .trends: + name = "chart.line.uptrend.xyaxis" case .list(_): name = "list.bullet" case .addList, .addSavedHashtag: @@ -479,11 +458,7 @@ extension ExploreViewController { return true case (.favorites, .favorites): return true - case (.trendingStatuses, .trendingStatuses): - return true - case (.trendingTags, .trendingTags): - return true - case (.trendingLinks, .trendingLinks): + case (.trends, .trends): return true case let (.list(a), .list(b)): return a.id == b.id && a.title == b.title @@ -508,12 +483,8 @@ extension ExploreViewController { hasher.combine("bookmarks") case .favorites: hasher.combine("favorites") - case .trendingStatuses: - hasher.combine("trendingStatuses") - case .trendingTags: - hasher.combine("trendingTags") - case .trendingLinks: - hasher.combine("trendingLinks") + case .trends: + hasher.combine("trends") case let .list(list): hasher.combine("list") hasher.combine(list.id)