updated badge
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
e027b05046
commit
1146006ca6
@ -102,74 +102,36 @@ public class Badge: View, Accessable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration
|
||||
//--------------------------------------------------
|
||||
public func backgroundColor() -> UIColor {
|
||||
var config: SurfaceColorConfiguration
|
||||
switch fillColor {
|
||||
case .red:
|
||||
config = SurfaceColorConfiguration().with {
|
||||
$0.lightColor = VDSColor.backgroundBrandhighlight
|
||||
$0.darkColor = VDSColor.backgroundBrandhighlight
|
||||
}
|
||||
case .yellow:
|
||||
config = SurfaceColorConfiguration().with {
|
||||
$0.lightColor = VDSColor.paletteYellow62
|
||||
$0.darkColor = VDSColor.paletteYellow62
|
||||
}
|
||||
case .green:
|
||||
config = SurfaceColorConfiguration().with {
|
||||
$0.lightColor = VDSColor.paletteGreen26
|
||||
$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 {
|
||||
private var backgroundColorConfig: StateColorConfiguration<BadgeFillColor> = {
|
||||
let config = StateColorConfiguration<BadgeFillColor>()
|
||||
config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forState: .red)
|
||||
config.setSurfaceColors(VDSColor.paletteYellow62, VDSColor.paletteYellow62, forState: .yellow)
|
||||
config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen34, forState: .green)
|
||||
config.setSurfaceColors(VDSColor.paletteOrange39, VDSColor.paletteOrange46, forState: .orange)
|
||||
config.setSurfaceColors(VDSColor.paletteBlue35, VDSColor.paletteBlue45, forState: .blue)
|
||||
config.setSurfaceColors(VDSColor.paletteBlack, VDSColor.paletteBlack, forState: .black)
|
||||
config.setSurfaceColors(VDSColor.paletteWhite, VDSColor.paletteWhite, forState: .white)
|
||||
return config
|
||||
}()
|
||||
|
||||
private var textColorConfig = ViewColorConfiguration()
|
||||
|
||||
public func updateTextColorConfig() {
|
||||
textColorConfig.reset()
|
||||
|
||||
switch fillColor {
|
||||
|
||||
case .red, .black:
|
||||
return DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.disabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
}.eraseToAnyColorable()
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: true)
|
||||
|
||||
case .yellow, .white:
|
||||
return DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
}.eraseToAnyColorable()
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: false)
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: true)
|
||||
|
||||
case .orange, .green, .blue:
|
||||
return DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
}.eraseToAnyColorable()
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: false)
|
||||
textColorConfig.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,9 +139,11 @@ public class Badge: View, Accessable {
|
||||
// MARK: - State
|
||||
//--------------------------------------------------
|
||||
open override func updateView() {
|
||||
backgroundColor = backgroundColor()
|
||||
updateTextColorConfig()
|
||||
|
||||
label.textColorConfiguration = textColorConfiguration()
|
||||
backgroundColor = backgroundColorConfig.getColor(surface, forState: fillColor)
|
||||
|
||||
label.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
||||
label.numberOfLines = numberOfLines
|
||||
label.text = text
|
||||
label.surface = surface
|
||||
|
||||
Loading…
Reference in New Issue
Block a user