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.
This commit is contained in:
Khan, Arshad 2020-02-05 20:26:34 +05:30
parent 5c890818aa
commit fa1c8bad92
2 changed files with 5 additions and 7 deletions

View File

@ -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)

View File

@ -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)