added textColor
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d2e841c533
commit
c737ca1344
@ -31,6 +31,7 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol {
|
|||||||
self.accessibilityIdentifier = accessibilityIdentifier
|
self.accessibilityIdentifier = accessibilityIdentifier
|
||||||
}
|
}
|
||||||
text = viewModel.text
|
text = viewModel.text
|
||||||
|
textColor = viewModel.textColor
|
||||||
maxWidth = viewModel.maxWidth
|
maxWidth = viewModel.maxWidth
|
||||||
numberOfLines = viewModel.numberOfLines
|
numberOfLines = viewModel.numberOfLines
|
||||||
fillColor = viewModel.fillColor
|
fillColor = viewModel.fillColor
|
||||||
|
|||||||
@ -22,6 +22,7 @@ open class BadgeModel: MoleculeModelProtocol {
|
|||||||
// MARK: - VDS Properties
|
// MARK: - VDS Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public var text: String = ""
|
public var text: String = ""
|
||||||
|
public var textColor: Badge.TextColor? = nil
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
public var maxWidth: CGFloat?
|
public var maxWidth: CGFloat?
|
||||||
public var numberOfLines: Int = 1
|
public var numberOfLines: Int = 1
|
||||||
@ -29,7 +30,7 @@ open class BadgeModel: MoleculeModelProtocol {
|
|||||||
public var surface: Surface = .light
|
public var surface: Surface = .light
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case id, accessibilityIdentifier, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth
|
case id, accessibilityIdentifier, text, textColor, accessibilityText, fillColor, surface, numberOfLines, maxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
required public convenience init(from decoder: Decoder) throws {
|
required public convenience init(from decoder: Decoder) throws {
|
||||||
@ -38,6 +39,9 @@ open class BadgeModel: MoleculeModelProtocol {
|
|||||||
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
text = try container.decode(String.self, forKey: .text)
|
text = try container.decode(String.self, forKey: .text)
|
||||||
|
if let foundTextColor = try container.decodeIfPresent(Color.self, forKey: .textColor) {
|
||||||
|
textColor = .custom(foundTextColor.uiColor)
|
||||||
|
}
|
||||||
accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText)
|
accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red
|
fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red
|
||||||
surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light
|
surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light
|
||||||
@ -55,6 +59,12 @@ open class BadgeModel: MoleculeModelProtocol {
|
|||||||
try container.encode(surface, forKey: .surface)
|
try container.encode(surface, forKey: .surface)
|
||||||
try container.encode(numberOfLines, forKey: .numberOfLines)
|
try container.encode(numberOfLines, forKey: .numberOfLines)
|
||||||
try container.encodeIfPresent(maxWidth, forKey: .maxWidth)
|
try container.encodeIfPresent(maxWidth, forKey: .maxWidth)
|
||||||
|
switch textColor {
|
||||||
|
case .custom(let color):
|
||||||
|
try container.encode(Color(uiColor: color), forKey: .textColor)
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user