From 8daf1a2b728b47b0b3797feeee0e4933eaa4c51f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 15 Feb 2024 17:56:50 -0600 Subject: [PATCH] updated more model properties Signed-off-by: Matt Bruce --- .../DesignedComponents/LockUps/TitleLockup.swift | 1 + .../LockUps/TitleLockupModel.swift | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift index b0fd7fea..6339b8e2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockup.swift @@ -21,6 +21,7 @@ import VDS //-------------------------------------------------- open func viewModelDidUpdate() { surface = viewModel.surface + textAlignment = viewModel.textAlignment eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData) titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData) subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift index e11aea0f..034420cd 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift @@ -19,9 +19,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco public var moleculeName: String = TitleLockupModel.identifier public var id: String = UUID().uuidString + public var textAlignment: TitleLockup.TextAlignment = .left 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 @@ -49,9 +51,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco private enum CodingKeys: String, CodingKey { case id case moleculeName + case textAlignment case eyebrow case title case subTitle + case subTitleColor case inverted case alignment } @@ -63,10 +67,12 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) 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) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) 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) { alignment = newAlignment } @@ -80,9 +86,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(textAlignment, forKey: .textAlignment) 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) } @@ -131,6 +139,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco if let style = subTitle.fontStyle { return .init(text: subTitle.text, standardStyle: try style.vdsSubsetStyle(), + textColor: subTitleColor, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0) } @@ -138,7 +147,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco MVMCoreLoggingHandler.shared()?.addError(toLog: object) } 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) } }