Convenient component displaying elements in UICollectionView - Supports SwiftUI-based cell
- iOS 14 +
- iPhone Platform
Works in UIKit
let list = DynamicListView<Section, Element>.init(...)
Setting how displays cells
list.setUp(
cellProvider: { context in
let data = context.data
// return cell
}
)
the context in cellProvider closure supports making SwiftUI based cells.
let cell = context.cell { state in
Text("Hello")
}
return cell
setting how handles the events of selected or deselected
list.setSelectionHandler { action in
switch action {
case .didSelect(let item):
print("Selected \(String(describing: item))")
case .didDeselect(let item):
print("Deselected \(String(describing: item))")
}
}
basic configuration is completed.
then set the content that displays.
list.setContents(contents, inSection: targetSection)
it supports a trigger event when the scrolling will be reaching the tail.
that will be good timing to trigger loading additional data.
list.setIncrementalContentLoader {
await loadMoreData()
}