- Xcode 7+
- iOS 7.0+
- Swift 2.0+
Coming soon...
Run the following command:
git submodule add https://github.com/ra1028/Former.git
Add the following line to your Seedfile:
github "ra1028/Former", :files => "Former/**/*.{swift,h}"
You can setting the cell appearance and events callback at the same time.
ViewController and Cell does not need to override.
import Former
final class ViewController: FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
let labelRow = LabelRowFormer<FormLabelCell>()
.configure { row in
row.text = "Label Cell"
}.onSelected { row in
// Do Something
}
let inlinePickerRow = InlinePickerRowFormer<FormInlinePickerCell, Int>() {
$0.titleLabel.text = "Inline Picker Cell"
}.configure { row in
row.pickerItems = (1...5).map {
InlinePickerItem(title: "Option\($0)", value: Int($0))
}
}.onValueChanged { item in
// Do Something
}
let header = LabelViewFormer<FormLabelHeaderView>() { view in
view.titleLabel.text = "Label Header"
}
let section = SectionFormer(rowFormer: labelRow, inlinePickerRow)
.set(headerViewFormer: header)
former.append(sectionFormer: section)
}
}
RowFormer is the base of the class that manages the cell.
Cell that managed by the RowFormer class should conform to the corresponding protocol.
Each of RowFormer classes You can set the event handling in function named like on~ (onSelected, onValueChanged, etc...)
Default provided RowFormer classes and the protocols that corresponding to it are the below.
Former is available under the MIT license. See the LICENSE file for more info.