reactored textLInk to color config
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
431ea81ad9
commit
338f70ae2b
@ -32,20 +32,11 @@ open class TextLink: ButtonBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override var textColor: UIColor {
|
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
|
private var textColors = ControlColorConfiguration()
|
||||||
$0.highlighted.darkColor = VDSColor.interactiveActiveOndark
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private var height: CGFloat {
|
private var height: CGFloat {
|
||||||
switch size {
|
switch size {
|
||||||
case .large:
|
case .large:
|
||||||
@ -80,6 +71,10 @@ open class TextLink: ButtonBase {
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.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 {
|
if let titleLabel {
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
line.pinLeading(titleLabel.leadingAnchor)
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user