removed subtitleColor since this is now textColor for the label

added textColor into the API for the model to read textColor of label

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-07 13:29:26 -05:00
parent 3e8c53ecdf
commit ddc1d5002c

View File

@ -23,7 +23,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
public var eyebrow: LabelModel?
public var title: LabelModel
public var subTitle: LabelModel?
public var subTitleColor: Use = .primary
public var alignment: VDS.TitleLockup.TextAlignment = .left
public var inverted: Bool = false
@ -61,7 +60,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
case eyebrow
case title
case subTitle
case subTitleColor
case inverted
case alignment
}
@ -78,17 +76,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
/// look for color hex code
if let color = try? typeContainer.decodeIfPresent(Color.self, forKey: .subTitleColor) {
self.subTitleColor = color.uiColor.isDark() ? .primary : .secondary
} else if let subTitleColor = try? typeContainer.decodeIfPresent(Use.self, forKey: .subTitleColor) {
self.subTitleColor = subTitleColor
} else {
subTitleColor = .primary
}
if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) {
alignment = newAlignment
}
@ -109,17 +96,23 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
try container.encodeModel(title, forKey: .title)
try container.encodeIfPresent(subTitle, forKey: .subTitle)
try container.encode(subTitleColor, forKey: .subTitleColor)
try container.encode(alignment, forKey: .alignment)
try container.encode(inverted, forKey: .inverted)
}
public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.EyebrowModel? {
guard let eyebrow else { return nil }
var eyebrowColor: TitleLockup.TextColor = .primary
if let color = eyebrow.textColor?.uiColor {
eyebrowColor = .custom(color, color)
}
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
do {
if let style = eyebrow.fontStyle {
return .init(text: eyebrow.text,
textColor: eyebrowColor,
isBold: style.isBold(),
standardStyle: try style.vdsSubsetStyle(),
textAttributes: attrs,
@ -129,14 +122,21 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
} catch { }
return .init(text: eyebrow.text, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
return .init(text: eyebrow.text, textColor: eyebrowColor, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
}
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.TitleModel {
var titleColor: TitleLockup.TitleTextColor = .primary
if let color = title.textColor?.uiColor {
titleColor = .custom(color, color)
}
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
do {
if let style = title.fontStyle {
return .init(text: title.text,
textColor: titleColor,
textAttributes: attrs,
isBold: style.isBold(),
standardStyle: try style.vdsSubsetStyle(),
@ -147,11 +147,17 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
} catch { }
return .init(text: title.text, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
return .init(text: title.text, textColor: titleColor, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
}
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.SubTitleModel? {
guard let subTitle else { return nil }
var subTitleColor: TitleLockup.TextColor = .primary
if let color = subTitle.textColor?.uiColor {
subTitleColor = .custom(color, color)
}
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
do {