From 4685c6d3982bee8298805458841b754bdfff6be2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 6 May 2024 16:42:12 -0500 Subject: [PATCH] Implemented TextColor changes to TitleLockup Signed-off-by: Matt Bruce --- VDS/Components/TitleLockup/TitleLockup.swift | 21 ++++--------------- .../TitleLockup/TitleLockupEyebrowModel.swift | 6 ++++++ .../TitleLockupSubTitleModel.swift | 4 ++-- .../TitleLockup/TitleLockupTitleModel.swift | 7 ++++++- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index c0c3b0b5..a838c3b9 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -258,22 +258,10 @@ open class TitleLockup: View { bottomSpacing: VDSLayout.space6X) ]), ]) - - private var textColorSecondaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight , VDSColor.elementsSecondaryOnlight).eraseToAnyColorable() - - private var textColorPrimaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark).eraseToAnyColorable() - + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. - open override func setup() { - super.setup() - - titleLabel.textColorConfiguration = textColorPrimaryConfiguration - - } - open override func updateAccessibility() { super.updateAccessibility() var elements = [Any]() @@ -330,6 +318,7 @@ open class TitleLockup: View { if let eyebrowModel, !eyebrowModel.text.isEmpty { eyebrowLabel.textAlignment = allLabelsTextAlignment eyebrowLabel.text = eyebrowModel.text + eyebrowLabel.textColorConfiguration = eyebrowModel.textColor.configuration eyebrowLabel.attributes = eyebrowModel.textAttributes eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines eyebrowLabel.surface = surface @@ -339,15 +328,12 @@ open class TitleLockup: View { //When uniform size is true and the title is bold, //the eyebrow is always regular weight and the secondary color. eyebrowLabel.textStyle = otherStandardStyle.value.regular - eyebrowLabel.textColorConfiguration = textColorSecondaryConfiguration } else { //When uniform size is true and the title is regular weight //the eyebrow is always bold and uses the primary color. eyebrowLabel.textStyle = otherStandardStyle.value.bold - eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration } } else { - eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration eyebrowLabel.textStyle = eyebrowModel.isBold ? otherStandardStyle.value.bold : otherStandardStyle.value.regular } addSubview(eyebrowLabel) @@ -363,6 +349,7 @@ open class TitleLockup: View { if let titleModel, !titleModel.text.isEmpty { titleLabel.textAlignment = allLabelsTextAlignment titleLabel.textStyle = titleModel.textStyle + titleLabel.textColorConfiguration = titleModel.textColor.configuration titleLabel.text = titleModel.text titleLabel.attributes = titleModel.textAttributes titleLabel.numberOfLines = titleModel.numberOfLines @@ -381,7 +368,7 @@ open class TitleLockup: View { if let subTitleModel, !subTitleModel.text.isEmpty { subTitleLabel.textAlignment = allLabelsTextAlignment subTitleLabel.textStyle = otherStandardStyle.value.regular - subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration + subTitleLabel.textColorConfiguration = subTitleModel.textColor.configuration subTitleLabel.text = subTitleModel.text subTitleLabel.attributes = subTitleModel.textAttributes subTitleLabel.numberOfLines = subTitleModel.numberOfLines diff --git a/VDS/Components/TitleLockup/TitleLockupEyebrowModel.swift b/VDS/Components/TitleLockup/TitleLockupEyebrowModel.swift index 28305bfd..1139a6ee 100644 --- a/VDS/Components/TitleLockup/TitleLockupEyebrowModel.swift +++ b/VDS/Components/TitleLockup/TitleLockupEyebrowModel.swift @@ -13,6 +13,9 @@ extension TitleLockup { /// Text that will be used for the eyebrow label. public var text: String + /// Text color that will be used for the eyebrow label + public var textColor: TextColor + /// Used in combination with standardStyle to set the textStyle that will be used for the eyebrow label. public var isBold: Bool @@ -26,11 +29,13 @@ extension TitleLockup { public var numberOfLines: Int public init(text: String, + textColor: TextColor = .primary, isBold: Bool = true, standardStyle: OtherStandardStyle = .bodyLarge, textAttributes: [any LabelAttributeModel]? = nil, numberOfLines: Int = 0) { self.text = text + self.textColor = textColor self.isBold = isBold self.standardStyle = standardStyle self.textAttributes = textAttributes @@ -41,3 +46,4 @@ extension TitleLockup { public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular } } } + diff --git a/VDS/Components/TitleLockup/TitleLockupSubTitleModel.swift b/VDS/Components/TitleLockup/TitleLockupSubTitleModel.swift index f558ffb4..7dcbfb85 100644 --- a/VDS/Components/TitleLockup/TitleLockupSubTitleModel.swift +++ b/VDS/Components/TitleLockup/TitleLockupSubTitleModel.swift @@ -18,7 +18,7 @@ extension TitleLockup { public var otherStandardStyle: OtherStandardStyle /// Text color used in the subtitle label. - public var textColor: Use + public var textColor: TextColor /// Array of LabelAttributeModel objects used in rendering the text in the subtitle label. public var textAttributes: [any LabelAttributeModel]? @@ -31,7 +31,7 @@ extension TitleLockup { public init(text: String, otherStandardStyle: OtherStandardStyle = .bodyLarge, - textColor: Use = .primary, + textColor: TextColor = .primary, textAttributes: [any LabelAttributeModel]? = nil, numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping) { diff --git a/VDS/Components/TitleLockup/TitleLockupTitleModel.swift b/VDS/Components/TitleLockup/TitleLockupTitleModel.swift index 7541151f..2d7f7405 100644 --- a/VDS/Components/TitleLockup/TitleLockupTitleModel.swift +++ b/VDS/Components/TitleLockup/TitleLockupTitleModel.swift @@ -14,7 +14,10 @@ extension TitleLockup { /// Text that will be used for the title label. public var text: String - /// Array of LabelAttributeModel objects used in rendering the text. + /// 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. @@ -30,12 +33,14 @@ extension TitleLockup { 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