override getColor for state
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
66c39fb701
commit
11416b5343
@ -15,6 +15,23 @@ public class ControlColorConfiguration: StateColorConfiguration<UIControl.State>
|
||||
|
||||
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<StateType: Equatable> {
|
||||
var surfaceConfig: SurfaceColorConfiguration
|
||||
}
|
||||
|
||||
private var stateColors: [StateColor] = []
|
||||
internal var stateColors: [StateColor] = []
|
||||
|
||||
public init() { }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user