refactored enums for badge
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3b97e60298
commit
25144ae1bc
@ -11,15 +11,19 @@ import VDSColorTokens
|
|||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public enum BadgeFillColor: String, Codable, CaseIterable {
|
|
||||||
case red, yellow, green, orange, blue, black, white
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Badges are visual labels used to convey status or highlight supplemental information.
|
/// Badges are visual labels used to convey status or highlight supplemental information.
|
||||||
@objc(VDSBadge)
|
@objc(VDSBadge)
|
||||||
public class Badge: View, Accessable {
|
public class Badge: View, Accessable {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Enums
|
||||||
|
//--------------------------------------------------
|
||||||
|
public enum FillColor: String, Codable, CaseIterable {
|
||||||
|
case red, yellow, green, orange, blue, black, white
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Private Properties
|
||||||
|
//--------------------------------------------------
|
||||||
private var label = Label().with {
|
private var label = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.adjustsFontSizeToFitWidth = false
|
$0.adjustsFontSizeToFitWidth = false
|
||||||
@ -31,7 +35,7 @@ public class Badge: View, Accessable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var fillColor: BadgeFillColor = .red { didSet { didChange() }}
|
open var fillColor: FillColor = .red { didSet { didChange() }}
|
||||||
|
|
||||||
open var text: String = "" { didSet { didChange() }}
|
open var text: String = "" { didSet { didChange() }}
|
||||||
|
|
||||||
@ -102,8 +106,8 @@ public class Badge: View, Accessable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var backgroundColorConfig: StateColorConfiguration<BadgeFillColor> = {
|
private var backgroundColorConfig: StateColorConfiguration<FillColor> = {
|
||||||
let config = StateColorConfiguration<BadgeFillColor>()
|
let config = StateColorConfiguration<FillColor>()
|
||||||
config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forState: .red)
|
config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forState: .red)
|
||||||
config.setSurfaceColors(VDSColor.paletteYellow62, VDSColor.paletteYellow62, forState: .yellow)
|
config.setSurfaceColors(VDSColor.paletteYellow62, VDSColor.paletteYellow62, forState: .yellow)
|
||||||
config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen34, forState: .green)
|
config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen34, forState: .green)
|
||||||
|
|||||||
@ -9,11 +9,11 @@ import Foundation
|
|||||||
|
|
||||||
public struct TiletBadgeModel: Codable {
|
public struct TiletBadgeModel: Codable {
|
||||||
public var text: String = ""
|
public var text: String = ""
|
||||||
public var fillColor: BadgeFillColor
|
public var fillColor:Badge.FillColor
|
||||||
public var surface: Surface
|
public var surface: Surface
|
||||||
public var numberOfLines: Int
|
public var numberOfLines: Int
|
||||||
public var maxWidth: CGFloat?
|
public var maxWidth: CGFloat?
|
||||||
public init(text: String, fillColor: BadgeFillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) {
|
public init(text: String, fillColor: Badge.FillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) {
|
||||||
self.text = text
|
self.text = text
|
||||||
self.fillColor = fillColor
|
self.fillColor = fillColor
|
||||||
self.surface = surface
|
self.surface = surface
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user