Use consolidated trends screen on iPhone

This commit is contained in:
Shadowfacts 2023-02-05 14:34:01 -05:00
parent d1a35620c9
commit 429dcefa88
1 changed files with 13 additions and 42 deletions

View File

@ -175,19 +175,14 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot<Section, Item>) {
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)