From 76b58ec88aa192f7e78d7aa449060045668f42d4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 14 Oct 2024 15:57:25 -0500 Subject: [PATCH] using type now and not the old way. Signed-off-by: Matt Bruce --- .../Atomic/Extensions/VDS-Enums+Codable.swift | 74 +++++-------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index b7477ed4..93669dc4 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -305,61 +305,27 @@ extension VDS.Badge.FillColor: Codable { } 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 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) - } - } - } - - private enum LegacyFillColor: String, Decodable { - case red, yellow, green, orange, blue, black, white + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(CustomColorType.self, forKey: .type) - 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 - } + 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) } }