pushed out fix for using surface color config

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-22 08:45:31 -05:00
parent 3bc2b18962
commit dc4db4816d

View File

@ -56,10 +56,12 @@ open class Icon: View {
if let hex = color.hexString, !UIColor.isVDSColor(color: color) { if let hex = color.hexString, !UIColor.isVDSColor(color: color) {
print("icon.color is not a VDSColor. Hex: \(hex) is not a supported color") print("icon.color is not a VDSColor. Hex: \(hex) is not a supported color")
} }
setNeedsUpdate() colorConfiguration = SurfaceColorConfiguration(color, color)
} }
} }
open var colorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark) { didSet { setNeedsUpdate() } }
/// Size of the icon. /// Size of the icon.
open var size: Size = .medium { didSet { setNeedsUpdate() } } open var size: Size = .medium { didSet { setNeedsUpdate() } }
@ -98,15 +100,8 @@ open class Icon: View {
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
//get the color for the image //get the color for the image
var imageColor = color let imageColor = colorConfiguration.getColor(surface)
//ensure the correct color for white/black colors
if surface == .dark && color == VDSColor.paletteBlack {
imageColor = VDSColor.elementsPrimaryOndark
} else if surface == .light && color == VDSColor.paletteBlack {
imageColor = VDSColor.elementsPrimaryOnlight
}
//get the image name //get the image name
//set the image //set the image
if let name, let image = UIImage.image(for: name, color: imageColor) { if let name, let image = UIImage.image(for: name, color: imageColor) {