vds_ios/VDS/Components/Tilelet/TileletTitleModel.swift
Matt Bruce ba8e557cd0 updated didset
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-08-30 18:04:46 -05:00

66 lines
2.4 KiB
Swift

//
// TiletTitleModel.swift
// VDS
//
// Created by Matt Bruce on 1/6/23.
//
import Foundation
extension Tilelet {
/// Model that represents the options available for the title label.
public struct TitleModel: Equatable, Identifiable {
public static func == (lhs: TitleModel, rhs: TitleModel) -> Bool {
lhs.id == rhs.id
}
public var id: String = UUID().uuidString
//--------------------------------------------------
// MARK: - Enums
//--------------------------------------------------
/// Enum for the textStyle of the title label.
public enum StandardStyle: String, EnumSubset {
case titleXLarge
case titleLarge
case titleMedium
case titleSmall
public var defaultValue: TitleLockup.TitleStandardStyle { .titleSmall }
}
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// Text that will be used for the title label.
public var text: String = ""
/// 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
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init(text: String,
textAttributes: [any LabelAttributeModel]? = nil,
standardStyle: StandardStyle = .titleSmall) {
self.text = text
self.textAttributes = textAttributes
self.standardStyle = standardStyle
}
//--------------------------------------------------
// MARK: - Public Methods
//--------------------------------------------------
/// Converts this type of model to a TitleLockup.TitleModel.
public func toTitleLockupTitleModel() -> TitleLockup.TitleModel {
TitleLockup.TitleModel(text: text,
textAttributes: textAttributes,
standardStyle: standardStyle.value)
}
}
}