From 38aff5a6372e602b7afd9cc887efe960e79eb01f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 24 May 2023 17:38:28 -0500 Subject: [PATCH] fixed issue in control configuration Signed-off-by: Matt Bruce --- VDS/Classes/ColorConfiguration.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index 9c7c25bd..c52a793f 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -81,7 +81,7 @@ public class ControlColorConfiguration: KeyColorConfigurable { public typealias KeyType = UIControl.State public typealias ObjectType = Surfaceable & UIControl public var keyColors: [KeyColorConfiguration] = [] - + private var lastKeyColor: KeyColorConfiguration? public required init() { } public func setSurfaceColors(_ lightColor: UIColor, _ darkColor: UIColor, forState state: KeyType) { @@ -94,16 +94,23 @@ public class ControlColorConfiguration: KeyColorConfigurable { // find the exact match if let keyColor = keyColors.first(where: {$0.key == state }) { + lastKeyColor = keyColor return keyColor.surfaceConfig.getColor(surface) } else if state.contains(.disabled), let keyColor = keyColors.first(where: {$0.key == .disabled }) { + lastKeyColor = keyColor return keyColor.surfaceConfig.getColor(surface) } else if state.contains(.highlighted), let keyColor = keyColors.first(where: {$0.key == .highlighted }) { + lastKeyColor = keyColor return keyColor.surfaceConfig.getColor(surface) } else { - return .clear + if let lastKeyColor { + return lastKeyColor.surfaceConfig.getColor(surface) + } else { + return .clear + } } } }