mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Supports viewing all NewsItems and StoreApps for a source
This commit is contained in:
@@ -16,6 +16,9 @@ import Nuke
|
||||
|
||||
class BrowseViewController: UICollectionViewController, PeekPopPreviewing
|
||||
{
|
||||
// Nil == Show apps from all sources.
|
||||
var source: Source?
|
||||
|
||||
private lazy var dataSource = self.makeDataSource()
|
||||
private lazy var placeholderView = RSTPlaceholderView(frame: .zero)
|
||||
|
||||
@@ -27,6 +30,18 @@ class BrowseViewController: UICollectionViewController, PeekPopPreviewing
|
||||
}
|
||||
}
|
||||
|
||||
init?(source: Source?, coder: NSCoder)
|
||||
{
|
||||
self.source = source
|
||||
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder)
|
||||
{
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
private var cachedItemSizes = [String: CGSize]()
|
||||
|
||||
@IBOutlet private var sourcesBarButtonItem: UIBarButtonItem!
|
||||
@@ -49,6 +64,22 @@ class BrowseViewController: UICollectionViewController, PeekPopPreviewing
|
||||
|
||||
(self as PeekPopPreviewing).registerForPreviewing(with: self, sourceView: self.collectionView)
|
||||
|
||||
if let source = self.source
|
||||
{
|
||||
let tintColor = source.effectiveTintColor ?? .altPrimary
|
||||
self.view.tintColor = tintColor
|
||||
|
||||
let appearance = NavigationBarAppearance()
|
||||
appearance.configureWithTintColor(tintColor)
|
||||
appearance.configureWithDefaultBackground()
|
||||
|
||||
let edgeAppearance = appearance.copy()
|
||||
edgeAppearance.configureWithTransparentBackground()
|
||||
|
||||
self.navigationItem.standardAppearance = appearance
|
||||
self.navigationItem.scrollEdgeAppearance = edgeAppearance
|
||||
}
|
||||
|
||||
self.update()
|
||||
}
|
||||
|
||||
@@ -78,9 +109,20 @@ private extension BrowseViewController
|
||||
NSSortDescriptor(keyPath: \StoreApp.name, ascending: true),
|
||||
NSSortDescriptor(keyPath: \StoreApp.bundleIdentifier, ascending: true)]
|
||||
fetchRequest.returnsObjectsAsFaults = false
|
||||
fetchRequest.predicate = NSPredicate(format: "%K != %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID)
|
||||
|
||||
let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource<StoreApp, UIImage>(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext)
|
||||
let predicate = NSPredicate(format: "%K != %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID)
|
||||
if let source = self.source
|
||||
{
|
||||
let filterPredicate = NSPredicate(format: "%K == %@", #keyPath(StoreApp._source), source)
|
||||
fetchRequest.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [filterPredicate, predicate])
|
||||
}
|
||||
else
|
||||
{
|
||||
fetchRequest.predicate = predicate
|
||||
}
|
||||
|
||||
let context = self.source?.managedObjectContext ?? DatabaseManager.shared.viewContext
|
||||
let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource<StoreApp, UIImage>(fetchRequest: fetchRequest, managedObjectContext: context)
|
||||
dataSource.cellConfigurationHandler = { (cell, app, indexPath) in
|
||||
let cell = cell as! BrowseCollectionViewCell
|
||||
cell.layoutMargins.left = self.view.layoutMargins.left
|
||||
|
||||
Reference in New Issue
Block a user