Created
April 5, 2020 13:15
-
-
Save tifoaudii/6e93601c8d4aef8e4b273f73882bfafa to your computer and use it in GitHub Desktop.
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
fileprivate func createOnGoingMovieSection() -> NSCollectionLayoutSection { | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(2/3)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(1.0)) | |
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: item, count: 3) | |
group.contentInsets = .init(top: 5, leading: 0, bottom: 5, trailing: 20) | |
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .estimated(44)) | |
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: MovieViewController.sectionHeaderElementKind, alignment: .top) | |
let section = NSCollectionLayoutSection(group: group) | |
section.orthogonalScrollingBehavior = .groupPaging | |
section.boundarySupplementaryItems = [sectionHeader] | |
return section | |
} | |
fileprivate func createUpcomingMovieSection() -> NSCollectionLayoutSection { | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalHeight(1.0)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(0.75)) | |
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 2) | |
group.contentInsets = .init(top: 5, leading: 5, bottom: 5, trailing: 5) | |
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .estimated(44)) | |
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: MovieViewController.sectionHeaderElementKind, alignment: .top) | |
let section = NSCollectionLayoutSection(group: group) | |
section.boundarySupplementaryItems = [sectionHeader] | |
return section | |
} | |
fileprivate func createPopularMovieSection() -> NSCollectionLayoutSection { | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(1.0)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(1.5)) | |
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: item, count: 1) | |
group.contentInsets = .init(top: 5, leading: 5, bottom: 5, trailing: 5) | |
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .estimated(44)) | |
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: MovieViewController.sectionHeaderElementKind, alignment: .top) | |
let section = NSCollectionLayoutSection(group: group) | |
section.boundarySupplementaryItems = [sectionHeader] | |
return section | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment