Code commit - changes has to be done to model.
This commit is contained in:
parent
21fc9c1802
commit
273b131714
@ -18,4 +18,8 @@ import Foundation
|
||||
public var imageFormat: String?
|
||||
public var width: CGFloat?
|
||||
public var height: CGFloat?
|
||||
|
||||
public init(image: String) {
|
||||
self.image = image
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import Foundation
|
||||
stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: rightImage)]
|
||||
contentView.addSubview(stack)
|
||||
containerHelper.constrainView(stack)
|
||||
|
||||
}
|
||||
//----------------------------------------------------
|
||||
// MARK: - Molecule
|
||||
@ -52,9 +53,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(percent: 70)
|
||||
let leftLabel = StackItemModel()
|
||||
leftLabel.horizontalAlignment = .leading
|
||||
let rightImage = StackItemModel(percent: 30)
|
||||
let rightImage = StackItemModel()
|
||||
rightImage.horizontalAlignment = .trailing
|
||||
let stackModel = StackModel(molecules: [leftLabel,rightImage])
|
||||
stackModel.axis = .horizontal
|
||||
|
||||
@ -15,11 +15,17 @@ public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtoco
|
||||
public var leftLabel: LabelModel
|
||||
|
||||
public init(image: ImageViewModel, leftLabel: LabelModel) {
|
||||
self.image = image
|
||||
self.leftLabel = leftLabel
|
||||
self.image = image
|
||||
super.init()
|
||||
}
|
||||
|
||||
func createPayPalImage() -> ImageViewModel {
|
||||
let image = ImageViewModel(image: "imagename_paypal")
|
||||
image.width = 30.0
|
||||
return image
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case leftLabel
|
||||
@ -29,7 +35,7 @@ public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtoco
|
||||
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)
|
||||
image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image) ?? createPayPalImage()
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user