Created
July 2, 2020 17:28
-
-
Save stevencurtis/e510eaab083336e68426131c528c77b8 to your computer and use it in GitHub Desktop.
featuresection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct FeatureSection: LayoutSection { | |
func configureCell(collectionView: UICollectionView, indexPath: IndexPath, item: AnyHashable, position: Int) -> UICollectionViewCell { | |
guard let cell = collectionView.dequeueReusableCell( | |
withReuseIdentifier: String(describing: AppFeaturedCollectionViewCell.self), for: indexPath) as? AppFeaturedCollectionViewCell else { | |
fatalError("Unable to create new cell") } | |
if let item = item as? AppDataModel { | |
cell.configure(with: item, final: false) | |
} | |
return cell | |
} | |
var layoutSection: NSCollectionLayoutSection = { | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.9), heightDimension: .fractionalHeight(0.35)) | |
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) | |
let section = NSCollectionLayoutSection(group: group) | |
section.orthogonalScrollingBehavior = .groupPagingCentered | |
return section | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment