review comments updated
models updated
This commit is contained in:
parent
36a469ab6b
commit
7e38657b63
@ -11,9 +11,23 @@ import Foundation
|
||||
@objcMembers public class NumberedListModel: OrderListProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "numberedList"
|
||||
public var list: [LabelModel]
|
||||
public var list: [MoleculeProtocol]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case list
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeModels(list, forKey: .list)
|
||||
}
|
||||
}
|
||||
|
||||
public protocol OrderListProtocol: MoleculeProtocol {
|
||||
var list: [LabelModel] {get}
|
||||
var list: [MoleculeProtocol] {get}
|
||||
}
|
||||
|
||||
@ -12,5 +12,22 @@ import Foundation
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "unOrderedList"
|
||||
public var bulletChar: String?
|
||||
public var list: [LabelModel]
|
||||
public var list: [MoleculeProtocol]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case bulletChar
|
||||
case list
|
||||
}
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
bulletChar = try typeContainer.decodeIfPresent(String.self, forKey: .bulletChar)
|
||||
list = try typeContainer.decodeMolecules(codingKey: .list)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(bulletChar, forKey: .bulletChar)
|
||||
try container.encodeModels(list, forKey: .list)
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,10 +110,6 @@ class LeftLabelRightMoleculeContainer: View {
|
||||
|
||||
setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
|
||||
rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
||||
leftContainer.setContentHuggingPriority(.required, for: .horizontal)
|
||||
leftContainer.setContentHuggingPriority(.required, for: .vertical)
|
||||
updateLeftViewWidthConstraint(percentage)
|
||||
|
||||
}
|
||||
@ -132,21 +128,20 @@ class LeftLabelRightMoleculeContainer: View {
|
||||
}
|
||||
|
||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
let previousMoleculeName = model?.moleculeName
|
||||
let previousMoleculeName = self.rightMoleculeName
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
removeSubviewsInRightContainer()
|
||||
guard let labelModel = model as? LabelModel else {
|
||||
label.text = leftText
|
||||
rightMoleculeName = model?.moleculeName
|
||||
guard let validModel = model else {
|
||||
return
|
||||
}
|
||||
|
||||
label.text = leftText
|
||||
rightMoleculeName = labelModel.moleculeName
|
||||
//For reuse purpose check that allready added molecule is same
|
||||
if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName {
|
||||
rightMolecule.setWithModel(labelModel, delegateObject, additionalData)
|
||||
rightMolecule.setWithModel(validModel, delegateObject, additionalData)
|
||||
addView(rightMolecule)
|
||||
} else {
|
||||
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(labelModel, delegateObject, false) {
|
||||
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(validModel, delegateObject, false) {
|
||||
addView(molecule)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user