form validation fixes
This commit is contained in:
parent
a86492d85d
commit
3a32d78004
@ -19,7 +19,8 @@ import MVMCore
|
|||||||
// Form Validation
|
// Form Validation
|
||||||
var isRequired = false
|
var isRequired = false
|
||||||
var fieldKey: String?
|
var fieldKey: String?
|
||||||
var delegateObject: DelegateObject?
|
var groupName: String?
|
||||||
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
public static let defaultHeightWidth: CGFloat = 18.0
|
public static let defaultHeightWidth: CGFloat = 18.0
|
||||||
|
|
||||||
@ -104,12 +105,8 @@ import MVMCore
|
|||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
shapeLayer?.removeAllAnimations()
|
shapeLayer?.removeAllAnimations()
|
||||||
|
|
||||||
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
|
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
|
||||||
|
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
|
||||||
if let delegate = delegateObject as? FormValidationProtocol {
|
|
||||||
delegate.formValidatorModel?()?.enableByValidation()
|
|
||||||
}
|
|
||||||
|
|
||||||
updateAccessibilityLabel()
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +208,6 @@ import MVMCore
|
|||||||
|
|
||||||
/// This will toggle the state of the Checkbox and execute the actionBlock if provided.
|
/// This will toggle the state of the Checkbox and execute the actionBlock if provided.
|
||||||
public func toggleAndAction() {
|
public func toggleAndAction() {
|
||||||
|
|
||||||
isSelected.toggle()
|
isSelected.toggle()
|
||||||
actionBlock?()
|
actionBlock?()
|
||||||
}
|
}
|
||||||
@ -409,7 +405,8 @@ import MVMCore
|
|||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
||||||
|
|
||||||
guard let dictionary = json else { return }
|
guard let dictionary = json else { return }
|
||||||
|
|
||||||
|
groupName = dictionary.optionalStringForKey("groupName")
|
||||||
if let fieldKey = dictionary[KeyFieldKey] as? String {
|
if let fieldKey = dictionary[KeyFieldKey] as? String {
|
||||||
self.fieldKey = fieldKey
|
self.fieldKey = fieldKey
|
||||||
}
|
}
|
||||||
@ -463,7 +460,11 @@ import MVMCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK:- FormValidationProtocol
|
// MARK:- FormValidationProtocol
|
||||||
extension Checkbox: FormValidationProtocol {
|
extension Checkbox: FormValidationFormFieldProtocol {
|
||||||
|
|
||||||
|
public func formFieldGroupName() -> String? {
|
||||||
|
return groupName
|
||||||
|
}
|
||||||
|
|
||||||
public func isValidField() -> Bool {
|
public func isValidField() -> Bool {
|
||||||
return isRequired ? isSelected : true
|
return isRequired ? isSelected : true
|
||||||
|
|||||||
@ -22,7 +22,7 @@ const CGFloat SwitchKnobWidth = 20;
|
|||||||
const CGFloat SwitchKnobHeight = 20;
|
const CGFloat SwitchKnobHeight = 20;
|
||||||
const CGFloat SwitchShakeIntensity = 2;
|
const CGFloat SwitchShakeIntensity = 2;
|
||||||
|
|
||||||
@interface MVMCoreUISwitch () <FormValidationProtocol, MVMCoreUIViewConstrainingProtocol>
|
@interface MVMCoreUISwitch () <FormValidationFormFieldProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||||
|
|
||||||
@property (weak, nonatomic) UIView *baseView;
|
@property (weak, nonatomic) UIView *baseView;
|
||||||
@property (weak, nonatomic) UIView *knobView;
|
@property (weak, nonatomic) UIView *knobView;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - FormValidationProtocol
|
// MARK: - FormValidationFormFieldProtocol
|
||||||
extension RadioButtonModel: FormValidationFormFieldProtocol {
|
extension RadioButtonModel: FormValidationFormFieldProtocol {
|
||||||
public func formFieldGroupName() -> String? {
|
public func formFieldGroupName() -> String? {
|
||||||
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user