diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift index eeacb98d..874868e5 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/NumberedListModel.swift @@ -12,21 +12,24 @@ import Foundation public override class var identifier: String { return "numberedList" } + public var numberColor: Color private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list + case numberColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] public required init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - + + numberColor = try typeContainer.decodeIfPresent(Color.self, forKey: .numberColor) ?? Color(uiColor: .mvmBlack) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for (index, molecule) in list.enumerated() { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: "\(index+1).", molecule: molecule, stringColor: numberColor))) } super.init(molecules: models, spacing: 0) } @@ -41,6 +44,7 @@ import Foundation models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) + try container.encode(numberColor, forKey: .numberColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 3adb0bb3..6556796b 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -13,10 +13,12 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol - - public init(string: String, molecule: MoleculeModelProtocol) { + public var stringColor: Color + + public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color = Color(uiColor: .mvmBlack)) { self.string = string self.molecule = molecule + self.stringColor = stringColor } private enum CodingKeys: String, CodingKey { @@ -24,6 +26,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { case backgroundColor case string case molecule + case stringColor } public required init(from decoder: Decoder) throws { @@ -31,6 +34,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) + stringColor = try typeContainer.decodeIfPresent(Color.self, forKey: .stringColor) ?? Color(uiColor: .mvmBlack) } public func encode(to encoder: Encoder) throws { @@ -39,5 +43,6 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(stringColor, forKey: .stringColor) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index a2a76f68..a9fd5da8 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -84,6 +84,7 @@ open class StringAndMoleculeView: View { super.set(with: model, delegateObject, additionalData) guard let model = model as? StringAndMoleculeModel else { return } label.text = model.string + label.textColor = model.stringColor.uiColor molecule.set(with: model.molecule, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift index 3866e918..4013f3aa 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/UnOrderedListModel.swift @@ -13,12 +13,14 @@ import Foundation return "unOrderedList" } public var bulletChar = "•" - + public var bulletColor: Color + private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor case list case bulletChar + case bulletColor } // Numbered list model comes in the from of list = [MoleculeModelProtocol] @@ -28,10 +30,11 @@ import Foundation self.bulletChar = bulletChar } + bulletColor = try typeContainer.decodeIfPresent(Color.self, forKey: .bulletColor) ?? Color(uiColor: .mvmBlack) let list: [MoleculeModelProtocol] = try typeContainer.decodeModels(codingKey: .list) var models: [MoleculeStackItemModel] = [] for molecule in list { - models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule))) + models.append(MoleculeStackItemModel(with: StringAndMoleculeModel(string: bulletChar, molecule: molecule, stringColor: bulletColor))) } super.init(molecules: models, spacing: 0) } @@ -47,5 +50,6 @@ import Foundation models.append(((molecule as! MoleculeStackItemModel).molecule as! StringAndMoleculeModel).molecule) } try container.encodeModels(models, forKey: .list) + try container.encode(bulletColor, forKey: .bulletColor) } }