54 lines
1.4 KiB
Swift
54 lines
1.4 KiB
Swift
//
|
|
// BadgeModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 9/22/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import VDSColorTokens
|
|
|
|
public enum BadgeFillColor: String, Codable, CaseIterable {
|
|
case red, yellow, green, orange, blue, black, white
|
|
}
|
|
|
|
public protocol BadgeModel: Modelable, Accessable {
|
|
var fillColor: BadgeFillColor { get set }
|
|
var text: String { get set }
|
|
var maxWidth: CGFloat? { get set }
|
|
var numberOfLines: Int { get set }
|
|
}
|
|
|
|
extension BadgeModel {
|
|
public var label: DefaultLabelModel {
|
|
var model = DefaultLabelModel()
|
|
model.textPosition = .left
|
|
model.typograpicalStyle = .BoldBodySmall
|
|
model.text = text
|
|
model.surface = surface
|
|
model.disabled = disabled
|
|
return model
|
|
}
|
|
}
|
|
|
|
public struct DefaultBadgeModel: BadgeModel {
|
|
public var id = UUID()
|
|
public var fillColor: BadgeFillColor = .red
|
|
public var text: String = ""
|
|
public var maxWidth: CGFloat?
|
|
public var numberOfLines: Int = 1
|
|
|
|
public var surface: Surface = .light
|
|
public var disabled: Bool = false
|
|
|
|
public var accessibilityHintEnabled: String?
|
|
public var accessibilityHintDisabled: String?
|
|
public var accessibilityValueEnabled: String?
|
|
public var accessibilityValueDisabled: String?
|
|
public var accessibilityLabelEnabled: String?
|
|
public var accessibilityLabelDisabled: String?
|
|
|
|
public init() { }
|
|
}
|