BlockDataSource 0.4.0

BlockDataSource 0.4.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2018
SPMSupports SPM

Maintained by Adam Cumiskey.



  • By
  • Adam Cumiskey

BlockDataSource

Version License Platform

Conjure tables and collections out of thin air

Introduction

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 = "BlockDataSource 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))
        ]
    )
)

Installation

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

pod "BlockDataSource"

Author

Adam Cumiskey, [email protected]

License

BlockDataSource is available under the MIT license. See the LICENSE file for more info.