Code commit - Conforming to ListItemModel and MoleculeModelProtocol based on review comments.
This commit is contained in:
parent
f5b537084f
commit
23b2df3c82
@ -54,9 +54,9 @@ import Foundation
|
||||
rightImage.setWithModel(model.image, delegateObject, additionalData)
|
||||
|
||||
// Create a stack model to use for the internal stack and set the alignment of label and image
|
||||
let leftLabel = StackItemModel()
|
||||
let leftLabel = StackItemModel(percent: 60)
|
||||
leftLabel.horizontalAlignment = .leading
|
||||
let rightImage = StackItemModel()
|
||||
let rightImage = StackItemModel(percent: 40)
|
||||
rightImage.horizontalAlignment = .trailing
|
||||
let stackModel = StackModel(molecules: [leftLabel,rightImage])
|
||||
stackModel.axis = .horizontal
|
||||
|
||||
@ -8,49 +8,29 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public class ListRightVariablePaymentsModel: ContainerModel, ListItemModelProtocol {
|
||||
public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtocol {
|
||||
|
||||
public var line: LineModel?
|
||||
public var style: String? = "standard"
|
||||
public var hideArrow: Bool? = false
|
||||
public var backgroundColor: Color?
|
||||
public var action: ActionModelProtocol?
|
||||
public static var identifier: String = "listRVImg"
|
||||
public var image: ImageViewModel
|
||||
public var leftLabel: LabelModel
|
||||
|
||||
func setDefaults() {
|
||||
if useHorizontalMargins == nil {
|
||||
useHorizontalMargins = true
|
||||
}
|
||||
if useVerticalMargins == nil {
|
||||
useVerticalMargins = true
|
||||
}
|
||||
}
|
||||
|
||||
public init(image: ImageViewModel, leftLabel: LabelModel) {
|
||||
self.image = image
|
||||
self.leftLabel = leftLabel
|
||||
super.init()
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case leftLabel
|
||||
case image
|
||||
case action
|
||||
case backgroundColor
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
||||
image = try typeContainer.decode(ImageViewModel.self, forKey: .image)
|
||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
try super.init(from: decoder)
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
@ -59,8 +39,5 @@ public class ListRightVariablePaymentsModel: ContainerModel, ListItemModelProtoc
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(leftLabel, forKey: .leftLabel)
|
||||
try container.encode(image, forKey: .image)
|
||||
try container.encodeModelIfPresent(action, forKey: .action)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user