38 lines
986 B
Swift
38 lines
986 B
Swift
//
|
|
// TiletBadgeModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 1/6/23.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct TiletBadgeModel {
|
|
public var text: String = ""
|
|
public var fillColor: BadgeFillColor
|
|
public var surface: Surface
|
|
public var numberOfLines: Int
|
|
public var maxWidth: CGFloat?
|
|
public init(text: String, fillColor: BadgeFillColor = .red, surface: Surface = .light, numberOfLines: Int = 0, maxWidth: CGFloat? = nil) {
|
|
self.text = text
|
|
self.fillColor = fillColor
|
|
self.surface = surface
|
|
self.numberOfLines = numberOfLines
|
|
self.maxWidth = maxWidth
|
|
}
|
|
}
|
|
|
|
extension Badge {
|
|
public func set(with model: TiletBadgeModel?) {
|
|
if let model, !model.text.isEmpty {
|
|
text = model.text
|
|
fillColor = model.fillColor
|
|
numberOfLines = model.numberOfLines
|
|
surface = model.surface
|
|
maxWidth = model.maxWidth
|
|
} else {
|
|
reset()
|
|
}
|
|
}
|
|
}
|