EZSource 1.0.0

EZSource 1.0.0

Maintained by Alex Hmelevski, Alex Hmelevski, Piyush Sharma.



 
Depends on:
SwiftyCollection>= 0
xDiffCollection>= 0
 

EZSource 1.0.0

  • By
  • Swift Gurus

EZSource

Build Status Version License Platform

Usage

  • Cells

Should conform to the protocols ReusableCell and Configurable.

final class StringCell: UITableViewCell, ReusableCell, Configurable {
typealias Model = String

    func configure(with text: String) {
        textLabel?.text = text
    }
}
  • Source Initialization

let source = TableViewDataSource(tableView: tableView, withTypes: [StringCell.self], reusableViews: [])
  • Create Rows

var row = TableViewRow<StringCell>(model: "My Row")
  • Creating TableViewSectionUpdate

    TableViewSectionUpdate provides API to config updates for different sections like animations,
var updates = TableViewSectionUpdate(sectionID: "\(0)")
updates.addAddOperation(row , at: IndexPath(row: 0, section: 0))
source.applyChanges([updates])

Advanced Usage

Add Swipe actions to cells:

  • Create Action
	let action =  RowAction { [weak self] in
		guard let `self` = self else { return }
		let alertController = self.alertControllerExample
		let act = self.dismissAction(for: alertController)
		alertController.addAction(act)
		self.present(alertController, animated: true, completion: nil)
	}
  • Add Action to the Row as tralling or leading
	row.addRowLeadingActions([action])
	row.addRowTrailingActions([action])

Add Headers/Footers to cells:

  • Create a ReusableView
final class TestReusableView: UITableViewHeaderFooterView, ReusableView, Configurable {

    typealias Model = String

    func configure(with txt: String) {
        label.text = txt
    }
}
  • Create Header/Footer
let header = ImmutableHeaderFooterProvider<TestReusableView>(model: "Section with text labels")
let footer = ImmutableHeaderFooterProvider<TestReusableView>(model: "Footer with text labels")
  • Add Header/Footer
section.addHeader(header)
section.addFooter(footer)

Example

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

Requirements

Installation

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

pod 'EZSource'

Author

Swift Gurus., [email protected]

License

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