Use consolidated trends screen on iPhone
This commit is contained in:
parent
d1a35620c9
commit
429dcefa88
|
@ -175,19 +175,14 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
||||||
|
|
||||||
private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot<Section, Item>) {
|
private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot<Section, Item>) {
|
||||||
snapshot.insertSections([.discover], afterSection: .bookmarks)
|
snapshot.insertSections([.discover], afterSection: .bookmarks)
|
||||||
snapshot.appendItems([.trendingTags], toSection: .discover)
|
snapshot.appendItems([.trends], toSection: .discover)
|
||||||
if mastodonController.instanceFeatures.trendingStatusesAndLinks {
|
|
||||||
snapshot.insertItems([.trendingStatuses], beforeItem: .trendingTags)
|
|
||||||
snapshot.insertItems([.trendingLinks], afterItem: .trendingTags)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func ownInstanceLoaded(_ instance: Instance) {
|
private func ownInstanceLoaded(_ instance: Instance) {
|
||||||
var snapshot = self.dataSource.snapshot()
|
var snapshot = self.dataSource.snapshot()
|
||||||
if mastodonController.instanceFeatures.trends,
|
if mastodonController.instanceFeatures.trends,
|
||||||
!snapshot.sectionIdentifiers.contains(.discover) {
|
!snapshot.sectionIdentifiers.contains(.discover) {
|
||||||
snapshot.insertSections([.discover], afterSection: .bookmarks)
|
addDiscoverSection(to: &snapshot)
|
||||||
snapshot.appendItems([.trendingTags], toSection: .discover)
|
|
||||||
}
|
}
|
||||||
self.dataSource.apply(snapshot)
|
self.dataSource.apply(snapshot)
|
||||||
}
|
}
|
||||||
|
@ -339,14 +334,8 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
||||||
case .favorites:
|
case .favorites:
|
||||||
show(FavoritesViewController(mastodonController: mastodonController), sender: nil)
|
show(FavoritesViewController(mastodonController: mastodonController), sender: nil)
|
||||||
|
|
||||||
case .trendingStatuses:
|
case .trends:
|
||||||
show(TrendingStatusesViewController(mastodonController: mastodonController), sender: nil)
|
show(TrendsViewController(mastodonController: mastodonController), sender: nil)
|
||||||
|
|
||||||
case .trendingTags:
|
|
||||||
show(TrendingHashtagsViewController(mastodonController: mastodonController), sender: nil)
|
|
||||||
|
|
||||||
case .trendingLinks:
|
|
||||||
show(TrendingLinksViewController(mastodonController: mastodonController), sender: nil)
|
|
||||||
|
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil)
|
show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil)
|
||||||
|
@ -395,7 +384,7 @@ extension ExploreViewController {
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return nil
|
return nil
|
||||||
case .discover:
|
case .discover:
|
||||||
return NSLocalizedString("Discover", comment: "discover section title")
|
return nil
|
||||||
case .lists:
|
case .lists:
|
||||||
return NSLocalizedString("Lists", comment: "explore lists section title")
|
return NSLocalizedString("Lists", comment: "explore lists section title")
|
||||||
case .savedHashtags:
|
case .savedHashtags:
|
||||||
|
@ -409,9 +398,7 @@ extension ExploreViewController {
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case bookmarks
|
case bookmarks
|
||||||
case favorites
|
case favorites
|
||||||
case trendingStatuses
|
case trends
|
||||||
case trendingTags
|
|
||||||
case trendingLinks
|
|
||||||
case list(List)
|
case list(List)
|
||||||
case addList
|
case addList
|
||||||
case savedHashtag(Hashtag)
|
case savedHashtag(Hashtag)
|
||||||
|
@ -425,12 +412,8 @@ extension ExploreViewController {
|
||||||
return NSLocalizedString("Bookmarks", comment: "bookmarks nav item title")
|
return NSLocalizedString("Bookmarks", comment: "bookmarks nav item title")
|
||||||
case .favorites:
|
case .favorites:
|
||||||
return NSLocalizedString("Favorites", comment: "favorites nav item title")
|
return NSLocalizedString("Favorites", comment: "favorites nav item title")
|
||||||
case .trendingStatuses:
|
case .trends:
|
||||||
return NSLocalizedString("Trending Posts", comment: "trending statuses nav item title")
|
return NSLocalizedString("Trends", comment: "trends 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 let .list(list):
|
case let .list(list):
|
||||||
return list.title
|
return list.title
|
||||||
case .addList:
|
case .addList:
|
||||||
|
@ -453,12 +436,8 @@ extension ExploreViewController {
|
||||||
name = "bookmark.fill"
|
name = "bookmark.fill"
|
||||||
case .favorites:
|
case .favorites:
|
||||||
name = "star.fill"
|
name = "star.fill"
|
||||||
case .trendingStatuses:
|
case .trends:
|
||||||
name = "doc.text.image"
|
name = "chart.line.uptrend.xyaxis"
|
||||||
case .trendingTags:
|
|
||||||
name = "number"
|
|
||||||
case .trendingLinks:
|
|
||||||
name = "link"
|
|
||||||
case .list(_):
|
case .list(_):
|
||||||
name = "list.bullet"
|
name = "list.bullet"
|
||||||
case .addList, .addSavedHashtag:
|
case .addList, .addSavedHashtag:
|
||||||
|
@ -479,11 +458,7 @@ extension ExploreViewController {
|
||||||
return true
|
return true
|
||||||
case (.favorites, .favorites):
|
case (.favorites, .favorites):
|
||||||
return true
|
return true
|
||||||
case (.trendingStatuses, .trendingStatuses):
|
case (.trends, .trends):
|
||||||
return true
|
|
||||||
case (.trendingTags, .trendingTags):
|
|
||||||
return true
|
|
||||||
case (.trendingLinks, .trendingLinks):
|
|
||||||
return true
|
return true
|
||||||
case let (.list(a), .list(b)):
|
case let (.list(a), .list(b)):
|
||||||
return a.id == b.id && a.title == b.title
|
return a.id == b.id && a.title == b.title
|
||||||
|
@ -508,12 +483,8 @@ extension ExploreViewController {
|
||||||
hasher.combine("bookmarks")
|
hasher.combine("bookmarks")
|
||||||
case .favorites:
|
case .favorites:
|
||||||
hasher.combine("favorites")
|
hasher.combine("favorites")
|
||||||
case .trendingStatuses:
|
case .trends:
|
||||||
hasher.combine("trendingStatuses")
|
hasher.combine("trends")
|
||||||
case .trendingTags:
|
|
||||||
hasher.combine("trendingTags")
|
|
||||||
case .trendingLinks:
|
|
||||||
hasher.combine("trendingLinks")
|
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
hasher.combine("list")
|
hasher.combine("list")
|
||||||
hasher.combine(list.id)
|
hasher.combine(list.id)
|
||||||
|
|
Loading…
Reference in New Issue