updated enums

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-07 13:28:17 -05:00
parent d7fd6f4465
commit 3e8c53ecdf

View File

@ -75,7 +75,7 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
var container = encoder.singleValueContainer()
switch self {
case .custom(let value):
try container.encode(value)
try container.encode(Color(uiColor: value))
default:
try container.encode(String(reflecting: self))
}
@ -96,9 +96,9 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
self = .black
default:
if let color = try? Color(from: decoder) {
self = .custom(color.hex)
self = .custom(color.uiColor)
} else {
self = .custom(type)
self = .custom(UIColor(hexString: type))
}
}
}
@ -128,9 +128,9 @@ extension VDS.TileContainerBase.BackgroundEffect: Codable {
case .none:
self = .none
case .gradient:
let firstColor = try container.decode(String.self, forKey: .firstColor)
let secondColor = try container.decode(String.self, forKey: .secondColor)
self = .gradient(firstColor, secondColor)
let firstColor = try container.decode(Color.self, forKey: .firstColor)
let secondColor = try container.decode(Color.self, forKey: .secondColor)
self = .gradient(firstColor.uiColor, secondColor.uiColor)
}
}
@ -143,8 +143,8 @@ extension VDS.TileContainerBase.BackgroundEffect: Codable {
try container.encode(BackgroundEffectType.none.rawValue, forKey: .type)
case .gradient(let firstColor, let secondColor):
try container.encode(BackgroundEffectType.gradient.rawValue, forKey: .type)
try container.encode(firstColor, forKey: .firstColor)
try container.encode(secondColor, forKey: .secondColor)
try container.encode(Color(uiColor: firstColor), forKey: .firstColor)
try container.encode(Color(uiColor: secondColor), forKey: .secondColor)
@unknown default:
break
}