65 lines
2.4 KiB
Swift
65 lines
2.4 KiB
Swift
//
|
|
// TitleLockupTitleModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 1/6/23.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
extension TitleLockup {
|
|
/// Model that represents the options available for the sub title label.
|
|
public struct TitleModel: Equatable {
|
|
/// Text that will be used for the title label.
|
|
public var text: String
|
|
|
|
/// Text color that will be used for the eyebrow label
|
|
public var textColor: TitleTextColor
|
|
|
|
/// Array of LabelAttributeModel objects used in rendering the text.
|
|
public var textAttributes: [any LabelAttributeModel]?
|
|
|
|
/// Used in combination with standardStyle to set the textStyle that will be used for the title label.
|
|
public var isBold: Bool
|
|
|
|
/// Text style that will be used for the title label.
|
|
public var standardStyle: TitleStandardStyle
|
|
|
|
/// Number of lines that will be used for the title label.
|
|
public var numberOfLines: Int
|
|
|
|
/// LineBreakMode used in subtitle label.
|
|
public var lineBreakMode: NSLineBreakMode
|
|
|
|
public init(text: String,
|
|
textColor: TitleTextColor = .primary,
|
|
textAttributes: [any LabelAttributeModel]? = nil,
|
|
isBold: Bool = true,
|
|
standardStyle: TitleStandardStyle = .featureXSmall,
|
|
numberOfLines: Int = 0,
|
|
lineBreakMode: NSLineBreakMode = .byTruncatingTail) {
|
|
self.text = text
|
|
self.textColor = textColor
|
|
self.isBold = isBold
|
|
self.textAttributes = textAttributes
|
|
self.standardStyle = standardStyle
|
|
self.numberOfLines = numberOfLines
|
|
self.lineBreakMode = lineBreakMode
|
|
}
|
|
|
|
/// TextStyle used to render the text.
|
|
public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular }
|
|
|
|
public static func == (lhs: TitleLockup.TitleModel, rhs: TitleLockup.TitleModel) -> Bool {
|
|
lhs.text == rhs.text
|
|
&& lhs.textColor == rhs.textColor
|
|
&& lhs.isBold == rhs.isBold
|
|
&& lhs.standardStyle == rhs.standardStyle
|
|
&& lhs.textAttributes == rhs.textAttributes
|
|
&& lhs.numberOfLines == rhs.numberOfLines
|
|
&& lhs.lineBreakMode == rhs.lineBreakMode
|
|
}
|
|
}
|
|
}
|