Conjure tables and collections out of thin air
A DataSource
is an embedded DSL for construcing UIs with UITableViews and UICollectionViews.
You define the structure of your list and DataSource will automatically conform to UITableViewControllerDataSource
, UITableViewControllerDelegate
, UICollectionViewControllerDataSource
, and UICollectionViewControllerDelegate
.
For example, this is how you can create a simple UITableViewController:
let vc = BlockTableViewController(
style: .grouped,
dataSource: DataSource(
sections: [
Section(
items: [
Item { (cell: BedazzledTableViewCell) in
cell.titleLabel.text = "Custom cells"
},
Item { (cell: SubtitleTableViewCell) in
cell.textLabel?.text = "Load any cell with ease"
cell.detailTextLabel?.text = "Sorcery automatically registers and loads the correct cell by using the class specified in the configure block."
cell.detailTextLabel?.numberOfLines = 0
}
]
)
],
middleware: [
Middleware.noCellSelectionStyle,
Middleware.separatorInset(UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))
]
)
)
DataSorcery is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DataSorcery"
Adam Cumiskey, [email protected]
Sorcery is available under the MIT license. See the LICENSE file for more info.