// // TiletTitleModel.swift // VDS // // Created by Matt Bruce on 1/6/23. // import Foundation import UIKit extension Tilelet { /// Model that represents the options available for the title label. public struct TitleModel: Equatable { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- /// Enum for the textStyle of the title label. public enum StandardStyle: String, EnumSubset { case titleXLarge case titleLarge case titleMedium case titleSmall case bodyLarge case bodyMedium case bodySmall public var defaultValue: TitleLockup.TitleStandardStyle { .titleSmall } } //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- /// Text that will be used for the title label. public var text: String = "" /// TextColor that will be used for the title label. public var textColor: TitleLockup.TitleTextColor /// Used in combination with standardStyle to set the textStyle that will be used for the title label. public var isBold: Bool = false /// Text attributes that will be used for the title label. public var textAttributes: [any LabelAttributeModel]? /// Text style that will be used for the title label. public var standardStyle: StandardStyle = .titleSmall /// LineBreakMode used in Badge label. public var lineBreakMode: NSLineBreakMode //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- public init(text: String, textColor: TitleLockup.TitleTextColor = .primary, textAttributes: [any LabelAttributeModel]? = nil, isBold: Bool = true, standardStyle: StandardStyle = .titleSmall, lineBreakMode: NSLineBreakMode = .byTruncatingTail) { self.text = text self.textColor = textColor self.textAttributes = textAttributes self.standardStyle = standardStyle self.isBold = isBold self.lineBreakMode = lineBreakMode } //-------------------------------------------------- // MARK: - Public Methods //-------------------------------------------------- /// Converts this type of model to a TitleLockup.TitleModel. public func toTitleLockupTitleModel() -> TitleLockup.TitleModel { TitleLockup.TitleModel(text: text, textColor: textColor, textAttributes: textAttributes, isBold: isBold, standardStyle: standardStyle.value, lineBreakMode: lineBreakMode) } public static func == (lhs: Tilelet.TitleModel, rhs: Tilelet.TitleModel) -> Bool { lhs.text == rhs.text && lhs.textColor == rhs.textColor && lhs.isBold == rhs.isBold && lhs.textAttributes == rhs.textAttributes && lhs.standardStyle == rhs.standardStyle && lhs.lineBreakMode == rhs.lineBreakMode } } }