forked from shadowfacts/Tusker
visionOS: Don't use certain nib-based cells
This commit is contained in:
parent
a2cc3a0436
commit
4500e9be27
|
@ -8,6 +8,9 @@
|
|||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
#if os(visionOS)
|
||||
import SwiftUI
|
||||
#endif
|
||||
|
||||
class SuggestedProfilesViewController: UIViewController, CollectionViewController {
|
||||
|
||||
|
@ -53,10 +56,22 @@ class SuggestedProfilesViewController: UIViewController, CollectionViewControlle
|
|||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
#if os(visionOS)
|
||||
let accountCell = UICollectionView.CellRegistration<UICollectionViewCell, (String, Suggestion.Source)> { [unowned self] cell, indexPath, item in
|
||||
if let account = self.mastodonController.persistentContainer.account(for: item.0) {
|
||||
cell.contentConfiguration = UIHostingConfiguration(content: {
|
||||
SuggestedProfileCardView(account: account)
|
||||
})
|
||||
} else {
|
||||
cell.contentConfiguration = nil
|
||||
}
|
||||
}
|
||||
#else
|
||||
let accountCell = UICollectionView.CellRegistration<SuggestedProfileCardCollectionViewCell, (String, Suggestion.Source)>(cellNib: UINib(nibName: "SuggestedProfileCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: item.0, source: item.1)
|
||||
}
|
||||
#endif
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .account(let id, let source):
|
||||
|
|
|
@ -11,6 +11,9 @@ import Pachyderm
|
|||
import WebURLFoundationExtras
|
||||
import SafariServices
|
||||
import Combine
|
||||
#if os(visionOS)
|
||||
import SwiftUI
|
||||
#endif
|
||||
|
||||
class TrendingLinksViewController: UIViewController, CollectionViewController {
|
||||
|
||||
|
@ -90,10 +93,18 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
|
|||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
#if os(visionOS)
|
||||
let linkCell = UICollectionView.CellRegistration<UICollectionViewCell, Card> { cell, indexPath, item in
|
||||
cell.contentConfiguration = UIHostingConfiguration(content: {
|
||||
TrendingLinkCardView(card: item)
|
||||
})
|
||||
}
|
||||
#else
|
||||
let linkCell = UICollectionView.CellRegistration<TrendingLinkCardCollectionViewCell, Card>(cellNib: UINib(nibName: "TrendingLinkCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.verticalSize = .compact
|
||||
cell.updateUI(card: item)
|
||||
}
|
||||
#endif
|
||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { cell, indexPath, isLoading in
|
||||
cell.confirmLoadMore = self.confirmLoadMore
|
||||
cell.isLoading = isLoading
|
||||
|
|
Loading…
Reference in New Issue