Switch molecule

This commit is contained in:
Priya 2019-05-23 17:02:30 -04:00
parent b73c916192
commit f53bd03212

View File

@ -17,13 +17,13 @@ import UIKit
var delegateObject: DelegateObject? var delegateObject: DelegateObject?
@objc func switchChanged() { @objc func switchChanged() {
let delegate = delegateObject as? MVMCoreUIDelegateObject let delegate = delegateObject as? MVMCoreUIDelegateObject
if let delegate = delegate { if let delegate = delegate {
let formValidator = delegate.formValidationProtocol?.formValidatorModel?() let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
formValidator?.enableByValidation() formValidator?.enableByValidation()
} }
} }
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
leftContainerView.addSubview(label) leftContainerView.addSubview(label)
@ -47,8 +47,6 @@ import UIKit
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
isRequired = json?[KeyRequired] as? Bool ?? false
self.delegateObject = delegateObject
mvmSwitch.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) mvmSwitch.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData) label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
mfTextButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), 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 mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0).isActive = true
} }
} }
func setupContainerConstraints() { func setupContainerConstraints() {
leftContainerView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true leftContainerView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
var constraint = leftContainerView.topAnchor.constraint(equalTo: topAnchor) var constraint = leftContainerView.topAnchor.constraint(equalTo: topAnchor)
constraint.priority = UILayoutPriority(249) constraint.priority = UILayoutPriority(249)
constraint.isActive = true constraint.isActive = true
mvmSwitch.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true mvmSwitch.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
constraint = mvmSwitch.topAnchor.constraint(equalTo: topAnchor) constraint = mvmSwitch.topAnchor.constraint(equalTo: topAnchor)
@ -77,7 +75,7 @@ import UIKit
constraint.isActive = true constraint.isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: mvmSwitch.bottomAnchor).isActive = true bottomAnchor.constraint(greaterThanOrEqualTo: mvmSwitch.bottomAnchor).isActive = true
constraint = bottomAnchor.constraint(equalTo: leftContainerView.bottomAnchor) constraint = bottomAnchor.constraint(equalTo: leftContainerView.bottomAnchor)
constraint.isActive = true constraint.isActive = true
@ -92,7 +90,7 @@ import UIKit
leftContainerView.topAnchor.constraint(equalTo: label.topAnchor).isActive = true leftContainerView.topAnchor.constraint(equalTo: label.topAnchor).isActive = true
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true
constraint = leftContainerView.trailingAnchor.constraint(equalTo: label.trailingAnchor) constraint = leftContainerView.trailingAnchor.constraint(equalTo: label.trailingAnchor)
constraint.priority = UILayoutPriority(249) constraint.priority = UILayoutPriority(249)
constraint.isActive = true constraint.isActive = true
@ -111,10 +109,6 @@ import UIKit
mvmSwitch.setContentHuggingPriority(.defaultLow, for: .horizontal) mvmSwitch.setContentHuggingPriority(.defaultLow, for: .horizontal)
} }
public func formFieldName() -> String? {
return json?.optionalStringForKey(KeyFieldKey)
}
public override func needsToBeConstrained() -> Bool { public override func needsToBeConstrained() -> Bool {
return true return true
} }