Skip to content
This repository was archived by the owner on Sep 20, 2025. It is now read-only.

adam-leitgeb/DataSource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataSource

Wrapper around UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource and UICollectionViewDelegate. Havily inspired by Futured's (my former employer) CellKit: https://github.com/futuredapp/CellKit

Support

  • UITableView & UICollectionView
  • Selecting cells
  • Actions (swipe to delete, ...)
  • Lazy loading (pagination)
  • Headers / Footers

Example

Cell

final class TextCell: UITableViewCell {
    @IBOutlet private weak var titleLabel: UILabel!
}

extension TextCell: CellConfigurable {
    func configure(with model: TextCellModel) {
        titleLabel.text = model.title
    }
}

CellModel

struct TextCellModel {
    let title: String
}

extension TextCellModel: CellModelConvertible {
    typealias Cell = PriceDetailCell

    var height: CGFloat {
        UITableView.automaticDimension
    }
}

ViewController

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()
        }
    }
}

About

Wrapper for UITableView & UICollectionView

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages