Switch molecule
This commit is contained in:
parent
b73c916192
commit
f53bd03212
@ -17,13 +17,13 @@ import UIKit
|
||||
var delegateObject: DelegateObject?
|
||||
|
||||
@objc func switchChanged() {
|
||||
let delegate = delegateObject as? MVMCoreUIDelegateObject
|
||||
let delegate = delegateObject as? MVMCoreUIDelegateObject
|
||||
if let delegate = delegate {
|
||||
let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
|
||||
formValidator?.enableByValidation()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
leftContainerView.addSubview(label)
|
||||
@ -47,8 +47,6 @@ import UIKit
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
isRequired = json?[KeyRequired] as? Bool ?? false
|
||||
self.delegateObject = delegateObject
|
||||
mvmSwitch.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
mfTextButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
@ -56,14 +54,14 @@ import UIKit
|
||||
mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0).isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func setupContainerConstraints() {
|
||||
leftContainerView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||
|
||||
var constraint = leftContainerView.topAnchor.constraint(equalTo: topAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
|
||||
mvmSwitch.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||
|
||||
constraint = mvmSwitch.topAnchor.constraint(equalTo: topAnchor)
|
||||
@ -77,7 +75,7 @@ import UIKit
|
||||
constraint.isActive = true
|
||||
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: mvmSwitch.bottomAnchor).isActive = true
|
||||
|
||||
|
||||
constraint = bottomAnchor.constraint(equalTo: leftContainerView.bottomAnchor)
|
||||
constraint.isActive = true
|
||||
|
||||
@ -92,7 +90,7 @@ import UIKit
|
||||
|
||||
leftContainerView.topAnchor.constraint(equalTo: label.topAnchor).isActive = true
|
||||
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true
|
||||
|
||||
|
||||
constraint = leftContainerView.trailingAnchor.constraint(equalTo: label.trailingAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
@ -111,10 +109,6 @@ import UIKit
|
||||
mvmSwitch.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||
}
|
||||
|
||||
public func formFieldName() -> String? {
|
||||
return json?.optionalStringForKey(KeyFieldKey)
|
||||
}
|
||||
|
||||
public override func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user