diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 09c1ffec..e5069f8f 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -56,10 +56,12 @@ open class Icon: View { if let hex = color.hexString, !UIColor.isVDSColor(color: 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. open var size: Size = .medium { didSet { setNeedsUpdate() } } @@ -98,15 +100,8 @@ open class Icon: View { open override func updateView() { super.updateView() //get the color for the image - var imageColor = color - - //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 - } - + let imageColor = colorConfiguration.getColor(surface) + //get the image name //set the image if let name, let image = UIImage.image(for: name, color: imageColor) {