Latest 0.1.3
Homepage https://github.com/manGoweb/Presentables
License MIT
Platforms ios 10.1
Authors

Carthage compatible
Version
License
Platform

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 MyCell: UITableViewCell, Presentable {

}

class MyCellPresenter: Presenter {

    var presentable: Presentable.Type = MyCell.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 = MyHeaderPresenter()
        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 = MyCellPresenter()
            presenter.configure = { presentable in
                guard let cell = presentable as? MyCell 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: PresentableManager = 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.1.3",
    "summary": "Simple reactive library 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.1.3"
    },
    "social_media_url": "https://twitter.com/rafiki270",
    "platforms": {
        "ios": "10.1"
    },
    "source_files": "Presentables/Classes/**/*",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This