using type now and not the old way.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-10-14 15:57:25 -05:00
parent 4487f9b03b
commit 76b58ec88a

View File

@ -305,16 +305,6 @@ extension VDS.Badge.FillColor: Codable {
} }
public init(from decoder: Decoder) throws { public init(from decoder: Decoder) throws {
//try legacy ones that map to real fillColor cases
if let legacy = try? LegacyFillColor(from: decoder) {
self = legacy.fillColor
} //try to convert to a color
else if let color = try? Color(from: decoder) {
self = .custom(color.uiColor)
} //try to use new format
else {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(CustomColorType.self, forKey: .type) let type = try container.decode(CustomColorType.self, forKey: .type)
@ -338,30 +328,6 @@ extension VDS.Badge.FillColor: Codable {
self = .custom(color.uiColor) self = .custom(color.uiColor)
} }
} }
}
private enum LegacyFillColor: String, Decodable {
case red, yellow, green, orange, blue, black, white
var fillColor: Badge.FillColor {
switch self {
case .red:
return .red
case .yellow:
return .yellow
case .green:
return .green
case .orange:
return .orange
case .blue:
return .blue
case .black:
return .black
case .white:
return .white
}
}
}
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)