diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index 9a4f855b..c14e6f1c 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -15,6 +15,23 @@ public class ControlColorConfiguration: StateColorConfiguration required public override init() {} + public override func getColor(_ surface: Surface, forState state: UIControl.State) -> UIColor { + + // find the exact match + if let stateColor = stateColors.first(where: {$0.state == state }) { + return stateColor.surfaceConfig.getColor(surface) + + } else if state.contains(.disabled), let stateColor = stateColors.first(where: {$0.state == .disabled }) { + return stateColor.surfaceConfig.getColor(surface) + + } else if state.contains(.highlighted), let stateColor = stateColors.first(where: {$0.state == .highlighted }) { + return stateColor.surfaceConfig.getColor(surface) + + } else { + return .clear + + } + } public func getColor(_ object: any ObjectType) -> UIColor { return getColor(object.surface, forState: object.state) } @@ -41,7 +58,7 @@ public class StateColorConfiguration { var surfaceConfig: SurfaceColorConfiguration } - private var stateColors: [StateColor] = [] + internal var stateColors: [StateColor] = [] public init() { }