VDS radio button of size and color changes as per 3.0 design
This commit is contained in:
parent
2f10bf0ffe
commit
a241265bab
@ -7,14 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import VDSColorTokens
|
||||||
|
|
||||||
@objcMembers open class RadioButton: Control, MFButtonProtocol {
|
@objcMembers open class RadioButton: Control, MFButtonProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var diameter: CGFloat = 30 {
|
public var diameter: CGFloat = 20 {
|
||||||
didSet { widthConstraint?.constant = diameter }
|
didSet { widthConstraint?.constant = diameter }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,9 +24,12 @@ import UIKit
|
|||||||
updateAccessibilityLabel()
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public var enabledColor: UIColor {
|
||||||
public var enabledColor: UIColor = .mvmBlack
|
return radioModel?.inverted ?? false ? VDSColor.elementsPrimaryOndark : VDSColor.elementsPrimaryOnlight
|
||||||
public var disabledColor: UIColor = .mvmCoolGray3
|
}
|
||||||
|
public var disabledColor: UIColor {
|
||||||
|
return radioModel?.inverted ?? false ? VDSColor.interactiveDisabledOndark : VDSColor.interactiveDisabledOnlight
|
||||||
|
}
|
||||||
public var delegateObject: MVMCoreUIDelegateObject?
|
public var delegateObject: MVMCoreUIDelegateObject?
|
||||||
var additionalData: [AnyHashable: Any]?
|
var additionalData: [AnyHashable: Any]?
|
||||||
|
|
||||||
@ -141,9 +144,9 @@ import UIKit
|
|||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
backgroundColor = .mvmWhite
|
backgroundColor = .clear
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: 30)
|
widthConstraint = widthAnchor.constraint(equalToConstant: 20)
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1)
|
heightConstraint = heightAnchor.constraint(equalTo: widthAnchor, multiplier: 1)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
@ -169,6 +172,6 @@ import UIKit
|
|||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .mvmWhite
|
backgroundColor = .clear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = FormValidator.defaultGroupName
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
public var action: ActionModelProtocol?
|
public var action: ActionModelProtocol?
|
||||||
|
public var inverted: Bool = false
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
@ -44,6 +45,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
case groupName
|
case groupName
|
||||||
case action
|
case action
|
||||||
case readOnly
|
case readOnly
|
||||||
|
case inverted
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -94,6 +96,9 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
}
|
}
|
||||||
fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue)
|
fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue)
|
||||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
||||||
|
if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) {
|
||||||
|
self.inverted = inverted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -108,5 +113,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||||
try container.encodeIfPresent(fieldValue, forKey: .fieldValue)
|
try container.encodeIfPresent(fieldValue, forKey: .fieldValue)
|
||||||
try container.encodeModelIfPresent(action, forKey: .action)
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
|
try container.encodeIfPresent(inverted, forKey: .inverted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user