updated badge

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-12-08 12:47:40 -06:00
parent e027b05046
commit 1146006ca6

View File

@ -102,74 +102,36 @@ public class Badge: View, Accessable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Configuration // MARK: - Configuration
//-------------------------------------------------- //--------------------------------------------------
public func backgroundColor() -> UIColor { private var backgroundColorConfig: StateColorConfiguration<BadgeFillColor> = {
var config: SurfaceColorConfiguration let config = StateColorConfiguration<BadgeFillColor>()
switch fillColor { config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forState: .red)
case .red: config.setSurfaceColors(VDSColor.paletteYellow62, VDSColor.paletteYellow62, forState: .yellow)
config = SurfaceColorConfiguration().with { config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen34, forState: .green)
$0.lightColor = VDSColor.backgroundBrandhighlight config.setSurfaceColors(VDSColor.paletteOrange39, VDSColor.paletteOrange46, forState: .orange)
$0.darkColor = VDSColor.backgroundBrandhighlight config.setSurfaceColors(VDSColor.paletteBlue35, VDSColor.paletteBlue45, forState: .blue)
} config.setSurfaceColors(VDSColor.paletteBlack, VDSColor.paletteBlack, forState: .black)
case .yellow: config.setSurfaceColors(VDSColor.paletteWhite, VDSColor.paletteWhite, forState: .white)
config = SurfaceColorConfiguration().with { return config
$0.lightColor = VDSColor.paletteYellow62 }()
$0.darkColor = VDSColor.paletteYellow62
} private var textColorConfig = ViewColorConfiguration()
case .green:
config = SurfaceColorConfiguration().with { public func updateTextColorConfig() {
$0.lightColor = VDSColor.paletteGreen26 textColorConfig.reset()
$0.darkColor = VDSColor.paletteGreen34
}
case .orange:
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteOrange39
$0.darkColor = VDSColor.paletteOrange46
}
case .blue:
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteBlue35
$0.darkColor = VDSColor.paletteBlue45
}
case .black:
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteBlack
$0.darkColor = VDSColor.paletteBlack
}
case .white:
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteWhite
$0.darkColor = VDSColor.paletteWhite
}
}
return config.getColor(self)
}
public func textColorConfiguration() -> AnyColorable {
switch fillColor { switch fillColor {
case .red, .black: case .red, .black:
return DisabledSurfaceColorConfiguration().with { textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: false)
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: true)
$0.disabled.darkColor = VDSColor.elementsPrimaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
}.eraseToAnyColorable()
case .yellow, .white: case .yellow, .white:
return DisabledSurfaceColorConfiguration().with { textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: false)
$0.disabled.lightColor = VDSColor.elementsPrimaryOnlight textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: true)
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
}.eraseToAnyColorable()
case .orange, .green, .blue: case .orange, .green, .blue:
return DisabledSurfaceColorConfiguration().with { textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: false)
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: true)
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
}.eraseToAnyColorable()
} }
} }
@ -177,9 +139,11 @@ public class Badge: View, Accessable {
// MARK: - State // MARK: - State
//-------------------------------------------------- //--------------------------------------------------
open override func updateView() { open override func updateView() {
backgroundColor = backgroundColor() updateTextColorConfig()
label.textColorConfiguration = textColorConfiguration() backgroundColor = backgroundColorConfig.getColor(surface, forState: fillColor)
label.textColorConfiguration = textColorConfig.eraseToAnyColorable()
label.numberOfLines = numberOfLines label.numberOfLines = numberOfLines
label.text = text label.text = text
label.surface = surface label.surface = surface