From 338f70ae2bd137ed3e6c2e6945e0895321a1310d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 8 Dec 2022 13:23:51 -0600 Subject: [PATCH] reactored textLInk to color config Signed-off-by: Matt Bruce --- .../Buttons/TextLink/TextLink.swift | 36 ++++--------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index d3ede278..872374aa 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -32,20 +32,11 @@ open class TextLink: ButtonBase { } open override var textColor: UIColor { - textColorConfiguration.getColor(self) + textColors.getColor(self) } - - private var textColorConfiguration = HighlightDisabledSurfaceColorConfiguration().with { - $0.disabled.lightColor = VDSColor.elementsSecondaryOnlight - $0.disabled.darkColor = VDSColor.elementsSecondaryOndark - $0.enabled.lightColor = VDSColor.elementsPrimaryOnlight - $0.enabled.darkColor = VDSColor.elementsPrimaryOndark - $0.highlighted.lightColor = VDSColor.interactiveActiveOnlight - $0.highlighted.darkColor = VDSColor.interactiveActiveOndark - - } - + private var textColors = ControlColorConfiguration() + private var height: CGFloat { switch size { case .large: @@ -80,6 +71,10 @@ open class TextLink: ButtonBase { open override func setup() { super.setup() + textColors.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal) + textColors.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forState: .disabled) + textColors.setSurfaceColors(VDSColor.interactiveActiveOnlight, VDSColor.interactiveActiveOndark, forState: .highlighted) + if let titleLabel { addSubview(line) line.pinLeading(titleLabel.leadingAnchor) @@ -119,20 +114,3 @@ open class TextLink: ButtonBase { } } - -class HighlightDisabledSurfaceColorConfiguration: ObjectColorable { - typealias ObjectType = Buttonable - public var highlighted = SurfaceColorConfiguration() - public var disabled = SurfaceColorConfiguration() - public var enabled = SurfaceColorConfiguration() - - required public init(){} - - public func getColor(_ object: any ObjectType) -> UIColor { - if object.isHighlighted { - return highlighted.getColor(object) - } else { - return object.disabled ? disabled.getColor(object) : enabled.getColor(object) - } - } -}