protocol implementation
This commit is contained in:
parent
1d843ae29a
commit
ccc535360c
@ -9,6 +9,10 @@
|
||||
import UIKit
|
||||
import MVMCore
|
||||
|
||||
@objc public protocol TextFieldListHelperProtocol {
|
||||
@objc optional func fieldForMap(_ map: [String: Any], textField: MFTextField)
|
||||
@objc optional func spaceBetweenField() -> CGFloat
|
||||
}
|
||||
|
||||
public class MFTextFieldListView: ViewConstrainingView {
|
||||
|
||||
@ -48,6 +52,8 @@ public class MFTextFieldListView: ViewConstrainingView {
|
||||
for textFieldMap in textFieldMapList {
|
||||
if let textField = getTextFieldForMap(textFieldMap) {
|
||||
|
||||
(parentViewContoller as? TextFieldListHelperProtocol)?.fieldForMap?(textFieldMap, textField: textField)
|
||||
|
||||
if textFieldMap.boolForKey("required") {
|
||||
textFieldsToValidate.append(textField)
|
||||
}
|
||||
@ -60,11 +66,13 @@ public class MFTextFieldListView: ViewConstrainingView {
|
||||
}
|
||||
}
|
||||
|
||||
let spaceBtwField = (parentViewContoller as? TextFieldListHelperProtocol)?.spaceBetweenField?() ?? 0.0
|
||||
StackableViewController.populateView(self, withUIArray: viewList) { (viewObject) -> UIEdgeInsets in
|
||||
var edgeInsets = StackableViewController.standardSpaceAroundUIObject()
|
||||
edgeInsets.left = 0
|
||||
edgeInsets.right = 0
|
||||
edgeInsets.top = 0
|
||||
edgeInsets.bottom = spaceBtwField
|
||||
return edgeInsets
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
open class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewController {
|
||||
open class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewController, TextFieldListHelperProtocol {
|
||||
|
||||
|
||||
public var textFieldListView: MFTextFieldListView?
|
||||
@ -30,7 +30,7 @@ open class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewControl
|
||||
open override func buildViewsBetweenLabelsAndButtons() -> [UIView]? {
|
||||
var viewList: [UIView] = []
|
||||
|
||||
if let textFieldsList = loadObject?.pageJSON?.arrayForKey("textFieldList") as? [[String: Any]] {
|
||||
if let textFieldsList = textFieldsLists() {
|
||||
let textFieldListView = MFTextFieldListView(textFieldMapList: textFieldsList,
|
||||
parentViewContoller: self,
|
||||
primaryButton: self.primaryButton)
|
||||
@ -48,5 +48,18 @@ open class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewControl
|
||||
open override func spaceAboveBetweenView() -> NSNumber? {
|
||||
return PaddingFour as NSNumber
|
||||
}
|
||||
|
||||
open func textFieldsLists() -> [[String: Any]]? {
|
||||
return loadObject?.pageJSON?.arrayForKey("textFieldList") as? [[String: Any]]
|
||||
}
|
||||
|
||||
//MARK: - Textfield list protocol
|
||||
open func spaceBetweenField() -> CGFloat {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
open func fieldForMap(_ map: [String : Any], textField: MFTextField) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user