Implemented TextColor changes to TitleLockup
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d703595e5a
commit
4685c6d398
@ -258,22 +258,10 @@ open class TitleLockup: View {
|
|||||||
bottomSpacing: VDSLayout.space6X)
|
bottomSpacing: VDSLayout.space6X)
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
|
||||||
private var textColorSecondaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight , VDSColor.elementsSecondaryOnlight).eraseToAnyColorable()
|
|
||||||
|
|
||||||
private var textColorPrimaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark).eraseToAnyColorable()
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// 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() {
|
open override func updateAccessibility() {
|
||||||
super.updateAccessibility()
|
super.updateAccessibility()
|
||||||
var elements = [Any]()
|
var elements = [Any]()
|
||||||
@ -330,6 +318,7 @@ open class TitleLockup: View {
|
|||||||
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
||||||
eyebrowLabel.textAlignment = allLabelsTextAlignment
|
eyebrowLabel.textAlignment = allLabelsTextAlignment
|
||||||
eyebrowLabel.text = eyebrowModel.text
|
eyebrowLabel.text = eyebrowModel.text
|
||||||
|
eyebrowLabel.textColorConfiguration = eyebrowModel.textColor.configuration
|
||||||
eyebrowLabel.attributes = eyebrowModel.textAttributes
|
eyebrowLabel.attributes = eyebrowModel.textAttributes
|
||||||
eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines
|
eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines
|
||||||
eyebrowLabel.surface = surface
|
eyebrowLabel.surface = surface
|
||||||
@ -339,15 +328,12 @@ open class TitleLockup: View {
|
|||||||
//When uniform size is true and the title is bold,
|
//When uniform size is true and the title is bold,
|
||||||
//the eyebrow is always regular weight and the secondary color.
|
//the eyebrow is always regular weight and the secondary color.
|
||||||
eyebrowLabel.textStyle = otherStandardStyle.value.regular
|
eyebrowLabel.textStyle = otherStandardStyle.value.regular
|
||||||
eyebrowLabel.textColorConfiguration = textColorSecondaryConfiguration
|
|
||||||
} else {
|
} else {
|
||||||
//When uniform size is true and the title is regular weight
|
//When uniform size is true and the title is regular weight
|
||||||
//the eyebrow is always bold and uses the primary color.
|
//the eyebrow is always bold and uses the primary color.
|
||||||
eyebrowLabel.textStyle = otherStandardStyle.value.bold
|
eyebrowLabel.textStyle = otherStandardStyle.value.bold
|
||||||
eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration
|
|
||||||
eyebrowLabel.textStyle = eyebrowModel.isBold ? otherStandardStyle.value.bold : otherStandardStyle.value.regular
|
eyebrowLabel.textStyle = eyebrowModel.isBold ? otherStandardStyle.value.bold : otherStandardStyle.value.regular
|
||||||
}
|
}
|
||||||
addSubview(eyebrowLabel)
|
addSubview(eyebrowLabel)
|
||||||
@ -363,6 +349,7 @@ open class TitleLockup: View {
|
|||||||
if let titleModel, !titleModel.text.isEmpty {
|
if let titleModel, !titleModel.text.isEmpty {
|
||||||
titleLabel.textAlignment = allLabelsTextAlignment
|
titleLabel.textAlignment = allLabelsTextAlignment
|
||||||
titleLabel.textStyle = titleModel.textStyle
|
titleLabel.textStyle = titleModel.textStyle
|
||||||
|
titleLabel.textColorConfiguration = titleModel.textColor.configuration
|
||||||
titleLabel.text = titleModel.text
|
titleLabel.text = titleModel.text
|
||||||
titleLabel.attributes = titleModel.textAttributes
|
titleLabel.attributes = titleModel.textAttributes
|
||||||
titleLabel.numberOfLines = titleModel.numberOfLines
|
titleLabel.numberOfLines = titleModel.numberOfLines
|
||||||
@ -381,7 +368,7 @@ open class TitleLockup: View {
|
|||||||
if let subTitleModel, !subTitleModel.text.isEmpty {
|
if let subTitleModel, !subTitleModel.text.isEmpty {
|
||||||
subTitleLabel.textAlignment = allLabelsTextAlignment
|
subTitleLabel.textAlignment = allLabelsTextAlignment
|
||||||
subTitleLabel.textStyle = otherStandardStyle.value.regular
|
subTitleLabel.textStyle = otherStandardStyle.value.regular
|
||||||
subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration
|
subTitleLabel.textColorConfiguration = subTitleModel.textColor.configuration
|
||||||
subTitleLabel.text = subTitleModel.text
|
subTitleLabel.text = subTitleModel.text
|
||||||
subTitleLabel.attributes = subTitleModel.textAttributes
|
subTitleLabel.attributes = subTitleModel.textAttributes
|
||||||
subTitleLabel.numberOfLines = subTitleModel.numberOfLines
|
subTitleLabel.numberOfLines = subTitleModel.numberOfLines
|
||||||
|
|||||||
@ -13,6 +13,9 @@ extension TitleLockup {
|
|||||||
/// Text that will be used for the eyebrow label.
|
/// Text that will be used for the eyebrow label.
|
||||||
public var text: String
|
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.
|
/// Used in combination with standardStyle to set the textStyle that will be used for the eyebrow label.
|
||||||
public var isBold: Bool
|
public var isBold: Bool
|
||||||
|
|
||||||
@ -26,11 +29,13 @@ extension TitleLockup {
|
|||||||
public var numberOfLines: Int
|
public var numberOfLines: Int
|
||||||
|
|
||||||
public init(text: String,
|
public init(text: String,
|
||||||
|
textColor: TextColor = .primary,
|
||||||
isBold: Bool = true,
|
isBold: Bool = true,
|
||||||
standardStyle: OtherStandardStyle = .bodyLarge,
|
standardStyle: OtherStandardStyle = .bodyLarge,
|
||||||
textAttributes: [any LabelAttributeModel]? = nil,
|
textAttributes: [any LabelAttributeModel]? = nil,
|
||||||
numberOfLines: Int = 0) {
|
numberOfLines: Int = 0) {
|
||||||
self.text = text
|
self.text = text
|
||||||
|
self.textColor = textColor
|
||||||
self.isBold = isBold
|
self.isBold = isBold
|
||||||
self.standardStyle = standardStyle
|
self.standardStyle = standardStyle
|
||||||
self.textAttributes = textAttributes
|
self.textAttributes = textAttributes
|
||||||
@ -41,3 +46,4 @@ extension TitleLockup {
|
|||||||
public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular }
|
public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ extension TitleLockup {
|
|||||||
public var otherStandardStyle: OtherStandardStyle
|
public var otherStandardStyle: OtherStandardStyle
|
||||||
|
|
||||||
/// Text color used in the subtitle label.
|
/// 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.
|
/// Array of LabelAttributeModel objects used in rendering the text in the subtitle label.
|
||||||
public var textAttributes: [any LabelAttributeModel]?
|
public var textAttributes: [any LabelAttributeModel]?
|
||||||
@ -31,7 +31,7 @@ extension TitleLockup {
|
|||||||
|
|
||||||
public init(text: String,
|
public init(text: String,
|
||||||
otherStandardStyle: OtherStandardStyle = .bodyLarge,
|
otherStandardStyle: OtherStandardStyle = .bodyLarge,
|
||||||
textColor: Use = .primary,
|
textColor: TextColor = .primary,
|
||||||
textAttributes: [any LabelAttributeModel]? = nil,
|
textAttributes: [any LabelAttributeModel]? = nil,
|
||||||
numberOfLines: Int = 0,
|
numberOfLines: Int = 0,
|
||||||
lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
||||||
|
|||||||
@ -14,7 +14,10 @@ extension TitleLockup {
|
|||||||
/// Text that will be used for the title label.
|
/// Text that will be used for the title label.
|
||||||
public var text: String
|
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]?
|
public var textAttributes: [any LabelAttributeModel]?
|
||||||
|
|
||||||
/// Used in combination with standardStyle to set the textStyle that will be used for the title label.
|
/// 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 var lineBreakMode: NSLineBreakMode
|
||||||
|
|
||||||
public init(text: String,
|
public init(text: String,
|
||||||
|
textColor: TitleTextColor = .primary,
|
||||||
textAttributes: [any LabelAttributeModel]? = nil,
|
textAttributes: [any LabelAttributeModel]? = nil,
|
||||||
isBold: Bool = true,
|
isBold: Bool = true,
|
||||||
standardStyle: TitleStandardStyle = .featureXSmall,
|
standardStyle: TitleStandardStyle = .featureXSmall,
|
||||||
numberOfLines: Int = 0,
|
numberOfLines: Int = 0,
|
||||||
lineBreakMode: NSLineBreakMode = .byTruncatingTail) {
|
lineBreakMode: NSLineBreakMode = .byTruncatingTail) {
|
||||||
self.text = text
|
self.text = text
|
||||||
|
self.textColor = textColor
|
||||||
self.isBold = isBold
|
self.isBold = isBold
|
||||||
self.textAttributes = textAttributes
|
self.textAttributes = textAttributes
|
||||||
self.standardStyle = standardStyle
|
self.standardStyle = standardStyle
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user