Skip to content

aryaxt/Binder

Repository files navigation

Binder

Build Status Version

A simple UI Binder for swift

*** Still in development, DO NOT USE ***

UIControl

Bind to any existing UIControlEvents

anyUiControl.bindControlEvent(.AllEvents) { print("Any Event") }

UIButton

button.bindTap { print("tap on button") }

UITextField

textField.bindTextChange { print("text value: \($0)") }

UISegmentedControl

segmentedControl.bindValueChange { print("selected index \($0)") }

UITableView

Populate a table, this will use the class name as the cell identifier

tableview
  .bindNumberOfRowsForSection { _ in self.tableData.count }
  .bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }

Provide custom identifier for the cells

tableview
  .bindNumberOfRowsForSection { _ in self.tableData.count }
  .bindCellIdentifier { _ in "AwesomeCellNumber2" }
  .bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }

Customize number of section

tableview
  .bindNumberOfSections { return 2 }
  .bindNumberOfRowsForSection { _ in self.tableData.count }
  .bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }

Selection & Deselection

tableview
  .bindNumberOfRowsForSection { _ in self.tableData.count }
  .bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }
  .bindSelection { indexPath in print("selected row: \(self.tableData[indexPath.row]))") }
  .bindDeselection { indexPath in print("deselected row: \(self.tableData[indexPath.row]))") }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published