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 UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
#if os(visionOS)
|
||||||
|
import SwiftUI
|
||||||
|
#endif
|
||||||
|
|
||||||
class SuggestedProfilesViewController: UIViewController, CollectionViewController {
|
class SuggestedProfilesViewController: UIViewController, CollectionViewController {
|
||||||
|
|
||||||
|
@ -53,10 +56,22 @@ class SuggestedProfilesViewController: UIViewController, CollectionViewControlle
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
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
|
let accountCell = UICollectionView.CellRegistration<SuggestedProfileCardCollectionViewCell, (String, Suggestion.Source)>(cellNib: UINib(nibName: "SuggestedProfileCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
cell.updateUI(accountID: item.0, source: item.1)
|
cell.updateUI(accountID: item.0, source: item.1)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||||
switch itemIdentifier {
|
switch itemIdentifier {
|
||||||
case .account(let id, let source):
|
case .account(let id, let source):
|
||||||
|
|
|
@ -11,6 +11,9 @@ import Pachyderm
|
||||||
import WebURLFoundationExtras
|
import WebURLFoundationExtras
|
||||||
import SafariServices
|
import SafariServices
|
||||||
import Combine
|
import Combine
|
||||||
|
#if os(visionOS)
|
||||||
|
import SwiftUI
|
||||||
|
#endif
|
||||||
|
|
||||||
class TrendingLinksViewController: UIViewController, CollectionViewController {
|
class TrendingLinksViewController: UIViewController, CollectionViewController {
|
||||||
|
|
||||||
|
@ -90,10 +93,18 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
|
||||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||||
cell.indicator.startAnimating()
|
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
|
let linkCell = UICollectionView.CellRegistration<TrendingLinkCardCollectionViewCell, Card>(cellNib: UINib(nibName: "TrendingLinkCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||||
cell.verticalSize = .compact
|
cell.verticalSize = .compact
|
||||||
cell.updateUI(card: item)
|
cell.updateUI(card: item)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { cell, indexPath, isLoading in
|
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { cell, indexPath, isLoading in
|
||||||
cell.confirmLoadMore = self.confirmLoadMore
|
cell.confirmLoadMore = self.confirmLoadMore
|
||||||
cell.isLoading = isLoading
|
cell.isLoading = isLoading
|
||||||
|
|
Loading…
Reference in New Issue