Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SwiftForms/cells/base/FormBaseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ open class FormBaseCell: UITableViewCell {
}

internal func handleDoneAction(_: UIBarButtonItem) {
if let inputToolbarDoneClosure = rowDescriptor?.configuration.cell.inputToolbarDoneClosure {
inputToolbarDoneClosure(self)
}
firstResponderElement()?.resignFirstResponder()
}

Expand Down
26 changes: 19 additions & 7 deletions SwiftForms/descriptors/FormRowDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public final class FormRowDescriptor {
public var placeholder: String?
public var showsInputToolbar: Bool
public var required: Bool
public var willUpdateClosure: ((FormRowDescriptor) -> Void)?
public var willUpdateClosure: ((FormRowDescriptor, AnyObject?, inout AnyObject?) -> Void)?
public var didUpdateClosure: ((FormRowDescriptor) -> Void)?
public var visualConstraintsClosure: ((FormBaseCell) -> [String])?
public var inputToolbarDoneClosure: ((FormBaseCell) -> Void)?

public init() {
cellClass = nil
Expand All @@ -60,6 +61,7 @@ public final class FormRowDescriptor {
willUpdateClosure = nil
didUpdateClosure = nil
visualConstraintsClosure = nil
inputToolbarDoneClosure = nil
}
}

Expand Down Expand Up @@ -128,14 +130,24 @@ public final class FormRowDescriptor {

public var title: String?

private var _value: AnyObject?
public var value: AnyObject? {
willSet {
guard let willUpdateBlock = configuration.cell.willUpdateClosure else { return }
willUpdateBlock(self)
set {
if newValue !== _value {
var newV = newValue
if let willUpdateBlock = configuration.cell.willUpdateClosure {
willUpdateBlock(self, _value, &newV)
}

_value = newV

if let didUpdateBlock = configuration.cell.didUpdateClosure {
didUpdateBlock(self)
}
}
}
didSet {
guard let didUpdateBlock = configuration.cell.didUpdateClosure else { return }
didUpdateBlock(self)
get {
return _value
}
}

Expand Down