Wrapper around UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource and UICollectionViewDelegate. Havily inspired by Futured's (my former employer) CellKit: https://github.com/futuredapp/CellKit
- UITableView & UICollectionView
- Selecting cells
- Actions (swipe to delete, ...)
- Lazy loading (pagination)
- Headers / Footers
final class TextCell: UITableViewCell {
@IBOutlet private weak var titleLabel: UILabel!
}
extension TextCell: CellConfigurable {
func configure(with model: TextCellModel) {
titleLabel.text = model.title
}
}
struct TextCellModel {
let title: String
}
extension TextCellModel: CellModelConvertible {
typealias Cell = PriceDetailCell
var height: CGFloat {
UITableView.automaticDimension
}
}
final class HomeViewController: UITableViewController {
// MARK: - Properties
private var userNetworkingWorker = UserNetworkingWorker()
private var dataSource = DataSource()
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = dataSource
tableView.delegate = dataSource
userNetworkingWorker.loadData() { users in
let cells = users.map { TextCellModel(title: $0.name) }
let section = Section(cells: cells)
self.dataSource.sections = [section]
self.tableView.reloadData()
}
}
}