From fa1c8bad92cd10298803d99ff2c6e93650a3e6ea Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Wed, 5 Feb 2020 20:26:34 +0530 Subject: [PATCH] corner label bug fixes: CXTDT-54851 & CXTDT-4571(see comments) making molecule optional as per one confluence document. Same has been implemented in Android and Server. --- MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift | 6 ++---- MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index 680e7089..2de9deca 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -171,10 +171,8 @@ import UIKit guard let model = model as? CornerLabelsModel else { return } if middleView != nil { (middleView as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData) - } else { - if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject) { - addMiddleView(molecule) - } + } else if let moleculeModel = model.molecule, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject) { + addMiddleView(molecule) } topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData) diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift index ce3796bf..f4b67216 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -15,9 +15,9 @@ public class CornerLabelsModel: MoleculeModelProtocol { public var topRightLabel: LabelModel? public var bottomLeftLabel: LabelModel? public var bottomRightLabel: LabelModel? - public var molecule: MoleculeModelProtocol + public var molecule: MoleculeModelProtocol? - init(with molecule: MoleculeModelProtocol) { + init(with molecule: MoleculeModelProtocol?) { self.molecule = molecule } @@ -33,7 +33,7 @@ public class CornerLabelsModel: MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - molecule = try typeContainer.decodeMolecule(codingKey: .molecule) + molecule = try typeContainer.decodeMoleculeIfPresent(codingKey: .molecule) topLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topLeftLabel) topRightLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .topRightLabel) bottomLeftLabel = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .bottomLeftLabel)