EasyList 0.1.5

EasyList 0.1.5

Maintained by Matan.



EasyList 0.1.5

  • By
  • YOURNAME

Pod version Language

EasyList Icon

Why EasyList?

EasyList is a UITableView subclass, that will help you create type-safe lists, with less code, and easier to read and maintain.

As you probably know, using UITableView forces you to implement delegate pattern, switch statements (In case of different cell types) force casting (UITableViewCell to your custom cell type), and redundant code as 'cellIdentifier'.

EasyList is a new way of dealing with simple to complex table views; it wrapped logic for you, so you have a less boilerplate redundant code.

Basic usage

Configuration type: EasyListConfigurationDefault, Supports multiple cell types, static height

let cellConfiguration = CellConfiguration { (cell, indexPath) -> YourCustomCell in
    cell.setText(self.dataSource[indexPath.row])
    return cell
}
let config = EasyListConfigurationDefault.init(
        cellConfiguration: { indexPath -> CellConfigurationType in
            return cellConfiguration
        }, dataSourceCount: { () -> Int in
    return self.dataSource.count
}, rowHeight: { indexPath -> CGFloat in
    return 50
}) { (selectedCell, selectedIndexPath) in
        ///Did select cell
}
self.easyList = EasyList.init(config)

Advanced usage

Configuration type: EasyListConfigurationAutoSizingCells, Supports multiple cell types, dynamic cell height

let cellConfiguration = CellConfiguration { (cell, indexPath) -> YourCustomCell in
    cell.setText(self.dataSource[indexPath.row])
    return cell
}
let cellConfiguration2 = CellConfiguration { (cell, indexPath) -> YourCustomCellWithDinamicSize in
    cell.setText(self.dataSource[indexPath.row])
    return cell
}
let config = EasyListConfigurationAutoSizingCells.init(
        cellConfiguration: { indexPath -> CellConfigurationType in
         if (indexPath.row == 5) {
                return cellConfiguration2
         }
          return cellConfiguration 
        }, dataSourceCount: { () -> Int in
     return self.dataSource.count
}, estimatedRowsHeight: 100) { (selectedCell, selectedIndexPath) in
        ///Did select cell
}
self.easyList = EasyList.init(config)

In detail

'CellConfiguration' block is used to define different cell types. Set Its return type to your custom cell, and set Its params. After creating the amount of cell configuration blocks you need, choose your 'EasyListConfiguration' type:

  • EasyListConfigurationAutoSizingCells for auto sizing cells
  • EasyListConfigurationDefault static cell sizes

Create it, pass CellConfiguration for index path, and the rest of the params (Should be autocompleted)

Reload is called as any UITableView (It is at the end, just a tableView) using: "reloadData()"

And you are ready to go! (:

Installation

Cocoapods

EasyList is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EasyList'

Manually

  1. Download and drop /EasyList folder in your project.
  2. Congratulations!

Author

Matan made this with ❤️.