vds_ios/VDS/Components/Tilelet/TileletTitleModel.swift
Matt Bruce 46a1471282 implement Monarch in Tilelet (first cut)
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-05-06 16:49:21 -05:00

80 lines
3.1 KiB
Swift

//
// 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 {
//--------------------------------------------------
// 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)
}
}
}