added fillColor codable
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3b2dc2d447
commit
54b50bffd3
@ -16,7 +16,6 @@ import MVMCore
|
||||
//--------------------------------------------------
|
||||
|
||||
extension VDS.Surface: Codable {}
|
||||
extension VDS.Badge.FillColor: Codable {}
|
||||
extension VDS.BadgeIndicator.FillColor: Codable {}
|
||||
extension VDS.BadgeIndicator.Kind: Codable {}
|
||||
extension VDS.BadgeIndicator.MaximumDigits: Codable {}
|
||||
@ -294,6 +293,54 @@ extension VDS.TitleLockup.TextColor: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
extension VDS.Badge.FillColor: Codable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
case color
|
||||
}
|
||||
|
||||
enum CustomColorType: String, Codable {
|
||||
case red, yellow, green, orange, blue, black, white
|
||||
case custom
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decode(CustomColorType.self, forKey: .type)
|
||||
|
||||
switch type {
|
||||
case .red:
|
||||
self = .red
|
||||
case .yellow:
|
||||
self = .yellow
|
||||
case .green:
|
||||
self = .green
|
||||
case .orange:
|
||||
self = .orange
|
||||
case .blue:
|
||||
self = .blue
|
||||
case .black:
|
||||
self = .black
|
||||
case .white:
|
||||
self = .white
|
||||
case .custom:
|
||||
let color = try container.decode(Color.self, forKey: .color)
|
||||
self = .custom(color.uiColor)
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
switch self {
|
||||
case .custom(let color):
|
||||
try container.encode(CustomColorType.custom.rawValue, forKey: .type)
|
||||
try container.encode(Color(uiColor: color), forKey: .color)
|
||||
default:
|
||||
try container.encode("\(self)", forKey: .type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension VDS.TitleLockup.TitleTextColor: Codable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user