Refactors SourcesViewController from Main.storyboard to new Sources.storyboard

Also refactors BannerCollectionViewCell to AppBannerCollectionViewCell to support initializing from code.
This commit is contained in:
Riley Testut
2023-04-04 14:37:11 -05:00
committed by Magesh K
parent 20cd6d98fc
commit 5145e355ce
6 changed files with 199 additions and 163 deletions

View File

@@ -70,6 +70,16 @@ final class SourcesViewController: UICollectionViewController
{
super.viewDidLoad()
self.view.tintColor = .altPrimary
self.navigationController?.view.tintColor = .altPrimary
if let navigationBar = self.navigationController?.navigationBar as? NavigationBar
{
// Don't automatically adjust item positions when being presented non-full screen,
// or else the navigation bar content won't be vertically centered.
navigationBar.automaticallyAdjustsItemPositions = false
}
self.collectionView.dataSource = self.dataSource
#if !BETA
@@ -113,7 +123,7 @@ private extension SourcesViewController
dataSource.cellConfigurationHandler = { (cell, source, indexPath) in
let tintColor = UIColor.altPrimary
let cell = cell as! BannerCollectionViewCell
let cell = cell as! AppBannerCollectionViewCell
cell.layoutMargins.left = self.view.layoutMargins.left
cell.layoutMargins.right = self.view.layoutMargins.right
cell.tintColor = tintColor
@@ -622,7 +632,7 @@ extension SourcesViewController
}
case .trusted:
if let cell = collectionView.cellForItem(at: indexPath) as? BannerCollectionViewCell, !cell.bannerView.button.isHidden
if let cell = collectionView.cellForItem(at: indexPath) as? AppBannerCollectionViewCell, !cell.bannerView.button.isHidden
{
actions.append(addAction)
}
@@ -638,7 +648,7 @@ extension SourcesViewController
override func collectionView(_ collectionView: UICollectionView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview?
{
guard let indexPath = configuration.identifier as? NSIndexPath else { return nil }
guard let cell = collectionView.cellForItem(at: indexPath as IndexPath) as? BannerCollectionViewCell else { return nil }
guard let cell = collectionView.cellForItem(at: indexPath as IndexPath) as? AppBannerCollectionViewCell else { return nil }
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear