vds_ios/VDS/Components/Tilelet/TileletSubTitleModel.swift
2024-03-15 17:05:15 +05:30

71 lines
2.8 KiB
Swift

//
// TiletSubTitleModel.swift
// VDS
//
// Created by Matt Bruce on 1/6/23.
//
import Foundation
import UIKit
extension Tilelet {
/// Model that represents the options available for the sub title label.
public struct SubTitleModel {
//--------------------------------------------------
// MARK: - Enums
//--------------------------------------------------
/// Enum used to describe the textStyle of the subTitle label.
public enum OtherStandardStyle: String, EnumSubset {
case bodyLarge
case bodyMedium
case bodySmall
case titleSmall
case titleMedium
public var defaultValue: TitleLockup.OtherStandardStyle { .bodySmall }
}
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// Text that will be used for the subTitle label.
public var text: String = ""
/// Text style that will be used for the subTitle label.
public var otherStandardStyle: OtherStandardStyle = .bodySmall
/// Text attributes that will be used for the subTitle label.
public var textAttributes: [any LabelAttributeModel]?
/// Text color that will be used for the subTitle label.
public var textColor: Use = .primary
/// LineBreakMode used in Badge label.
public var lineBreakMode: NSLineBreakMode
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init(text: String,
otherStandardStyle: OtherStandardStyle = .bodySmall,
textColor: Use = .primary,
textAttributes: [any LabelAttributeModel]? = nil,
lineBreakMode: NSLineBreakMode = .byTruncatingTail) {
self.text = text
self.otherStandardStyle = otherStandardStyle
self.textAttributes = textAttributes
self.textColor = textColor
self.lineBreakMode = lineBreakMode
}
//--------------------------------------------------
// MARK: - Public Methods
//--------------------------------------------------
/// Converts this type of model to a TitleLockup.SubTitleModel.
public func toTitleLockupSubTitleModel() -> TitleLockup.SubTitleModel {
TitleLockup.SubTitleModel(text: text,
otherStandardStyle: otherStandardStyle.value,
textColor: textColor,
textAttributes: textAttributes, lineBreakMode: lineBreakMode)
}
}
}