Created
May 3, 2020 10:08
-
-
Save michzio/f27453ebbcb57da1fcfa1d12722cb740 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
extension CollectionView { | |
func makeCoordinator() -> Coordinator { | |
Coordinator(self) | |
} | |
func makeUIViewController(context: Context) -> CollectionViewController<Section, Item> { | |
print("CollectionView.make()") | |
let controller = CollectionViewController<Section, Item>() | |
controller.layout = layout | |
controller.content = content | |
controller.supplementaryKinds = supplementaryKinds | |
controller.supplementaryContent = supplementaryContent | |
controller.snapshot = snapshotForCurrentState() | |
controller.delegate = context.coordinator | |
return controller | |
} | |
func updateUIViewController(_ controller: CollectionViewController<Section, Item>, context: Context) { | |
print("CollectionView.update()") | |
context.coordinator.dataSource = controller.dataSource | |
controller.collectionView.delegate = context.coordinator | |
let animating = self.animateChanges ?? smallItemsCount() | |
controller.snapshot = snapshotForCurrentState() | |
controller.reloadDataSource(animating: animating) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment