Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 3, 2020 10:08
Show Gist options
  • Save michzio/f27453ebbcb57da1fcfa1d12722cb740 to your computer and use it in GitHub Desktop.
Save michzio/f27453ebbcb57da1fcfa1d12722cb740 to your computer and use it in GitHub Desktop.
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