Latest 0.4.3
Homepage https://github.com/manGoweb/Presentables
License MIT
Platforms ios 10.3, tvos 10.3
Authors

Carthage compatible
Version
License
Platform

So what is Presentables really? It is a really small library that should help you develop apps with table views a little bit faster than you would using the conventional methods. It also introduces binding of your data to the table views so any time you change your dataset, the table will update accordingly.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Cocoapods

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

pod "Presentables"

Carthage

Presentables is also available through Carthage. To install
it, simply add the following line to your Cartfile:

github "manGoweb/Presentables"

Usage

Create your cell (or header, implementation is pretty much the same)

import UIKit
import Presentables

class TableViewCell: UITableViewCell, Presentable {

}

class TableViewCellPresenter: Presenter {

    var presentable: Presentable.Type = TableViewCell.self

    var configure: ((Presentable) -> ())?

}

Create a data manager

class MyDataManagager: PresentableTableViewDataManager {

    // MARK: Initialization

    override init() {
        super.init()

        // Start a new section
        let section = PresentableSection()

        // Every section needs a header ... obviously
        let header = TableViewHeaderPresenter()
        header.configure = { presentable in
            guard let header = presentable as? MyHeader else {
                return
            }
            header.titleLabel.text = "My section"
        }

        section.header = header

        // Create some basic cells
        for i: Int in 1...5 {
            let presenter = TableViewCellPresenter()
            presenter.configure = { presentable in
                guard let cell = presentable as? TableViewCell else {
                    return
                }
                cell.textLabel?.text = "Cell number: (i)"
            }
            section.presenters.append(presenter)
        }

        // Add section to the data set
        data.append(section)
    }

    // Override any delegate or datasource method you may want to
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 44
    }

}

And lastly, bind your table view to your data manager

import UIKit
import Presentables

class ViewController: UITableViewController {

    let dataController = MyDataManagager()

    // MARK: View lifecycle

    override func viewDidLoad() {
        super.viewDidLoad()

        title = "Presentables!"

        var dc: TableViewPresentableManager = dataController
        tableView.bind(withPresentableManager: &dc)
    }

}

And that’s all folks!

Author

Ondrej Rafaj, [email protected]

License

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

Latest podspec

{
    "name": "Presentables",
    "version": "0.4.3",
    "summary": "Simple reactive library for managing table & collection views, written in Swift",
    "description": "Simplify the way you use table views and collection views in your app. This library is not supposed to be competing with RxSwift at all, this is only for developers who want a quick way to simplify their screens.",
    "homepage": "https://github.com/manGoweb/Presentables",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ondrej Rafaj": "[email protected]"
    },
    "source": {
        "git": "https://github.com/manGoweb/Presentables.git",
        "tag": "0.4.3"
    },
    "social_media_url": "https://twitter.com/rafiki270",
    "platforms": {
        "ios": "10.3",
        "tvos": "10.3"
    },
    "source_files": "Presentables/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This