switch modification
This commit is contained in:
parent
b77ec675e0
commit
8ef420e3a4
@ -13,11 +13,8 @@ public class Switch: ViewConstrainingView, FormValidationProtocol {
|
||||
var label = Label()
|
||||
var mfTextButton = MFTextButton()
|
||||
var isRequired: Bool? = false
|
||||
var state: Bool? = false
|
||||
var onTintColor: UIColor? = .clear
|
||||
var offTintColor: UIColor? = .clear
|
||||
var isOnState: Bool? = false
|
||||
var fieldKey: String? = ""
|
||||
var delegate: DelegateObject?
|
||||
|
||||
public init() {
|
||||
@ -66,8 +63,6 @@ public class Switch: ViewConstrainingView, FormValidationProtocol {
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
isRequired = json?[KeyRequired] as? Bool
|
||||
state = json?["state"] as? Bool
|
||||
|
||||
self.delegate = delegateObject
|
||||
if let dict = json?.optionalDictionaryForKey("label") {
|
||||
label.setWithJSON(dict, delegateObject: delegateObject, additionalData: additionalData)
|
||||
@ -87,21 +82,17 @@ public class Switch: ViewConstrainingView, FormValidationProtocol {
|
||||
if let offColorString = json?.optionalStringForKey("offTintColor") {
|
||||
offTintColor = .mfGet(forHex: offColorString)
|
||||
}
|
||||
|
||||
aSwitch.onTintColor = onTintColor
|
||||
aSwitch.isOn = state ?? false
|
||||
aSwitch.isOn = json?.optionalBoolForKey("state") ?? false
|
||||
}
|
||||
|
||||
func setupConstraints(forView view: UIView) {
|
||||
NSLayoutConstraint.constraintPinRightSubview(aSwitch, rightConstant: 0)
|
||||
NSLayoutConstraint.constraintPinLeftSubview(label, leftConstant: 0)
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(aSwitch, pinTop: true, topConstant: 0, topRelation: .equal, pinBottom: true, bottomConstant: 0, bottomRelation: .greaterThanOrEqual, pinLeft: false, leftConstant: 0, leftRelation: .equal, pinRight: false, rightConstant: 0, rightRelation: .equal)
|
||||
|
||||
NSLayoutConstraint.constraintPinTopSubview(label, topConstant: 0)
|
||||
NSLayoutConstraint(pinFirstView: label, toSecondView: aSwitch, withConstant: PaddingOne, directionVertical: false)?.isActive = true
|
||||
NSLayoutConstraint(pinFirstView: label, toSecondView: mfTextButton, withConstant: PaddingOne, directionVertical: true)?.isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinLeftSubview(mfTextButton, leftConstant: 0)
|
||||
NSLayoutConstraint.constraintPinBottomSubview(mfTextButton, bottomConstant: 0)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user