Last active
May 3, 2020 10:04
-
-
Save michzio/0b1e5117ce19fed467e325a06cc20d57 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 CollectionView<Section: Hashable & CaseIterable, Item: Hashable>: UIViewControllerRepresentable { | |
// MARK: - Properties | |
let layout: UICollectionViewLayout | |
let sections: [Section] | |
let items: [Section: [Item]] | |
let supplementaryKinds: [String] | |
let animateChanges: Bool? | |
// MARK: - Actions | |
let content: (_ indexPath: IndexPath, _ item: Item) -> AnyView | |
let snapshot: (() -> NSDiffableDataSourceSnapshot<Section, Item>)? | |
let supplementaryContent: ((_ kind: String, _ indexPath: IndexPath, _ item: Item?) -> AnyView)? | |
init(layout: UICollectionViewLayout, | |
sections: [Section], | |
items: [Section: [Item]], | |
snapshot: (() -> NSDiffableDataSourceSnapshot<Section, Item>)? = nil, | |
supplementaryKinds: [String] = [], | |
animateChanges: Bool? = nil, | |
supplementaryContent: ((_ kind: String, _ IndexPath: IndexPath, _ item: Item?) -> AnyView)? = nil, | |
@ViewBuilder content: @escaping (_ indexPath: IndexPath, _ item: Item) -> AnyView) { | |
self.layout = layout | |
self.sections = sections | |
self.items = items | |
self.snapshot = snapshot | |
self.animateChanges = animateChanges | |
self.supplementaryKinds = supplementaryKinds | |
self.supplementaryContent = supplementaryContent | |
self.content = content | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment