updated more model properties

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-15 17:56:50 -06:00
parent 908c3bddc3
commit 8daf1a2b72
2 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import VDS
//-------------------------------------------------- //--------------------------------------------------
open func viewModelDidUpdate() { open func viewModelDidUpdate() {
surface = viewModel.surface surface = viewModel.surface
textAlignment = viewModel.textAlignment
eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData) eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData)
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData) titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData) subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)

View File

@ -19,9 +19,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
public var moleculeName: String = TitleLockupModel.identifier public var moleculeName: String = TitleLockupModel.identifier
public var id: String = UUID().uuidString public var id: String = UUID().uuidString
public var textAlignment: TitleLockup.TextAlignment = .left
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var title: LabelModel public var title: LabelModel
public var subTitle: LabelModel? public var subTitle: LabelModel?
public var subTitleColor: Use = .primary
public var alignment: VDS.TitleLockup.TextAlignment = .left public var alignment: VDS.TitleLockup.TextAlignment = .left
public var inverted: Bool = false public var inverted: Bool = false
@ -49,9 +51,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case id case id
case moleculeName case moleculeName
case textAlignment
case eyebrow case eyebrow
case title case title
case subTitle case subTitle
case subTitleColor
case inverted case inverted
case alignment case alignment
} }
@ -63,10 +67,12 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
textAlignment = try typeContainer.decodeIfPresent(TitleLockup.TextAlignment.self, forKey: .textAlignment) ?? .left
title = try typeContainer.decode(LabelModel.self, forKey: .title) title = try typeContainer.decode(LabelModel.self, forKey: .title)
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
subTitle = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subTitle) subTitle = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subTitle)
subTitleColor = try typeContainer.decodeIfPresent(Use.self, forKey: .subTitleColor) ?? .primary
if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) { if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) {
alignment = newAlignment alignment = newAlignment
} }
@ -80,9 +86,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id) try container.encode(id, forKey: .id)
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(textAlignment, forKey: .textAlignment)
try container.encodeIfPresent(eyebrow, forKey: .eyebrow) try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
try container.encodeModel(title, forKey: .title) try container.encodeModel(title, forKey: .title)
try container.encodeIfPresent(subTitle, forKey: .subTitle) try container.encodeIfPresent(subTitle, forKey: .subTitle)
try container.encode(subTitleColor, forKey: .subTitleColor)
try container.encode(alignment, forKey: .alignment) try container.encode(alignment, forKey: .alignment)
try container.encode(inverted, forKey: .inverted) try container.encode(inverted, forKey: .inverted)
} }
@ -131,6 +139,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
if let style = subTitle.fontStyle { if let style = subTitle.fontStyle {
return .init(text: subTitle.text, return .init(text: subTitle.text,
standardStyle: try style.vdsSubsetStyle(), standardStyle: try style.vdsSubsetStyle(),
textColor: subTitleColor,
textAttributes: attrs, textAttributes: attrs,
numberOfLines: subTitle.numberOfLines ?? 0) numberOfLines: subTitle.numberOfLines ?? 0)
} }
@ -138,7 +147,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
MVMCoreLoggingHandler.shared()?.addError(toLog: object) MVMCoreLoggingHandler.shared()?.addError(toLog: object)
} catch { } } catch { }
return .init(text: subTitle.text, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0) return .init(text: subTitle.text, textColor: subTitleColor, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
} }
} }