added eyebrowModel
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
4cd43dcfbe
commit
d7fd6f4465
@ -45,6 +45,7 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{
|
||||
} else if let percentage = viewModel.textPercentage {
|
||||
textWidth = .percentage(percentage)
|
||||
}
|
||||
eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
badgeModel = viewModel.badge
|
||||
|
||||
@ -19,6 +19,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
public var backgroundColor: Color?
|
||||
|
||||
public var badge: Tilelet.BadgeModel?
|
||||
public var eyebrow: LabelModel?
|
||||
public var title: LabelModel?
|
||||
public var subTitle: LabelModel?
|
||||
public var descriptiveIcon: Tilelet.DescriptiveIcon?
|
||||
@ -30,6 +31,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
case id
|
||||
case moleculeName
|
||||
case badge
|
||||
case eyebrow
|
||||
case title
|
||||
case subTitle
|
||||
case descriptiveIcon
|
||||
@ -41,6 +43,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||
badge = try container.decodeIfPresent(Tilelet.BadgeModel.self, forKey: .badge)
|
||||
eyebrow = try container.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||
title = try container.decodeIfPresent(LabelModel.self, forKey: .title)
|
||||
subTitle = try container.decodeIfPresent(LabelModel.self, forKey: .subTitle)
|
||||
descriptiveIcon = try container.decodeIfPresent(Tilelet.DescriptiveIcon.self, forKey: .descriptiveIcon)
|
||||
@ -50,13 +53,43 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.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,
|
||||
textAttributes: attrs, isBold: style.isBold(),
|
||||
standardStyle: try style.vdsSubsetStyle())
|
||||
}
|
||||
} catch MVMCoreError.errorObject(let object) {
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||
} catch { }
|
||||
|
||||
return .init(text: eyebrow.text, textColor: eyebrowColor, textAttributes: attrs)
|
||||
}
|
||||
|
||||
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.TitleModel? {
|
||||
guard let title else { return nil }
|
||||
|
||||
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,
|
||||
standardStyle: try style.vdsSubsetStyle())
|
||||
}
|
||||
@ -65,23 +98,30 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||
} catch { }
|
||||
|
||||
return .init(text: title.text, textAttributes: attrs)
|
||||
return .init(text: title.text, textColor: titleColor, textAttributes: attrs)
|
||||
}
|
||||
|
||||
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.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 {
|
||||
if let style = subTitle.fontStyle {
|
||||
return .init(text: subTitle.text,
|
||||
otherStandardStyle: try style.vdsSubsetStyle(),
|
||||
otherStandardStyle: try style.vdsSubsetStyle(),
|
||||
textColor: subTitleColor,
|
||||
textAttributes: attrs)
|
||||
}
|
||||
} catch MVMCoreError.errorObject(let object) {
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||
} catch { }
|
||||
|
||||
return .init(text: subTitle.text, textAttributes: attrs)
|
||||
return .init(text: subTitle.text, textColor: subTitleColor, textAttributes: attrs)
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
@ -89,8 +129,9 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
||||
try container.encode(id, forKey: .id)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(badge, forKey: .badge)
|
||||
try container.encodeIfPresent(title, forKey: .title)
|
||||
try container.encodeIfPresent(subTitle, forKey: .subTitle)
|
||||
try container.encodeModelIfPresent(eyebrow, forKey: .eyebrow)
|
||||
try container.encodeModelIfPresent(title, forKey: .title)
|
||||
try container.encodeModelIfPresent(subTitle, forKey: .subTitle)
|
||||
try container.encodeIfPresent(descriptiveIcon, forKey: .descriptiveIcon)
|
||||
try container.encodeIfPresent(directionalIcon, forKey: .directionalIcon)
|
||||
try container.encodeIfPresent(textWidth, forKey: .textWidth)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user