diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index cad4fd18..373ab90c 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -13,6 +13,12 @@ public protocol Colorable: AnyObject, ObjectWithable { func getColor(_ viewModel: ModelType) -> UIColor } +extension Colorable { + public func eraseToAnyColorable() -> AnyColorable { + AnyColorable(colorable: self) + } +} + public class AnyColorable: Colorable { private var wrapper: (ModelType) -> UIColor diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index ed724abe..285b228d 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -138,26 +138,26 @@ open class BadgeBase: View { switch fillColor { case .red, .black: - return .init(colorable: DisabledSurfaceColorConfiguration().with { + return DisabledSurfaceColorConfiguration().with { $0.disabled.lightColor = VDSColor.elementsPrimaryOndark $0.disabled.darkColor = VDSColor.elementsPrimaryOndark $0.enabled.lightColor = VDSColor.elementsPrimaryOndark $0.enabled.darkColor = VDSColor.elementsPrimaryOndark - }) + }.eraseToAnyColorable() case .yellow, .white: - return .init(colorable: DisabledSurfaceColorConfiguration().with { + return DisabledSurfaceColorConfiguration().with { $0.disabled.lightColor = VDSColor.elementsPrimaryOnlight $0.disabled.darkColor = VDSColor.elementsPrimaryOnlight $0.enabled.lightColor = VDSColor.elementsPrimaryOnlight $0.enabled.darkColor = VDSColor.elementsPrimaryOnlight - }) + }.eraseToAnyColorable() case .orange, .green, .blue: - return .init(colorable: DisabledSurfaceColorConfiguration().with { + return DisabledSurfaceColorConfiguration().with { $0.disabled.lightColor = VDSColor.elementsPrimaryOndark $0.disabled.darkColor = VDSColor.elementsPrimaryOnlight $0.enabled.lightColor = VDSColor.elementsPrimaryOndark $0.enabled.darkColor = VDSColor.elementsPrimaryOnlight - }) + }.eraseToAnyColorable() } } diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index a6fdb666..b5f89610 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -67,12 +67,12 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- - public var textColorConfiguration: AnyColorable = .init(colorable: DisabledSurfaceColorConfiguration().with { + public var textColorConfiguration: AnyColorable = DisabledSurfaceColorConfiguration().with { $0.disabled.lightColor = VDSColor.elementsSecondaryOnlight $0.disabled.darkColor = VDSColor.elementsSecondaryOndark $0.enabled.lightColor = VDSColor.elementsPrimaryOnlight $0.enabled.darkColor = VDSColor.elementsPrimaryOndark - }) + }.eraseToAnyColorable() //-------------------------------------------------- // MARK: - Initializers