updated button traits dynamically
This commit is contained in:
parent
d7c472b667
commit
eb9ec00866
@ -73,6 +73,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
_backgroundColor = newValue
|
||||
}
|
||||
}
|
||||
public var accessibilityTraits: UIAccessibilityTraits?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
@ -195,6 +196,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
case disabledTextColor
|
||||
case disabledBorderColor
|
||||
case width
|
||||
case accessibilityTraits
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -263,6 +265,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width)
|
||||
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
|
||||
}
|
||||
|
||||
open func encode(to encoder: Encoder) throws {
|
||||
@ -286,5 +289,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
try container.encodeIfPresent(size, forKey: .size)
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
try container.encodeIfPresent(width, forKey: .width)
|
||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,9 @@ import Foundation
|
||||
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
FormValidator.setupValidation(for: castModel, delegate: delegateObject?.formHolderDelegate)
|
||||
|
||||
if let traits = model.accessibilityTraits {
|
||||
accessibilityTraits = traits
|
||||
}
|
||||
}
|
||||
|
||||
public func setState() {
|
||||
|
||||
@ -24,7 +24,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
public var enabled: Bool = true
|
||||
public var enabledTintColor: Color?
|
||||
public var disabledTintColor: Color?
|
||||
|
||||
public var accessibilityTraits: UIAccessibilityTraits?
|
||||
public var groupName: String = ""
|
||||
|
||||
public var updateUI: ActionBlock?
|
||||
@ -45,6 +45,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
case groupName
|
||||
case enabledTintColor
|
||||
case disabledTintColor
|
||||
case accessibilityTraits
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -59,7 +60,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image)
|
||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
action = try typeContainer.decodeModel(codingKey: .action)
|
||||
|
||||
accessibilityTraits = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityTraits)
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
@ -90,5 +91,6 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
try container.encodeIfPresent(enabledTintColor, forKey: .enabledTintColor)
|
||||
try container.encodeIfPresent(disabledTintColor, forKey: .disabledTintColor)
|
||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +173,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||
}
|
||||
|
||||
FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate)
|
||||
if let traits = model.accessibilityTraits {
|
||||
accessibilityTraits = traits
|
||||
}
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user