Added model and molecule class files.
This commit is contained in:
parent
124a46f8d6
commit
92ca8f2326
@ -151,6 +151,7 @@ import Foundation
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListDeviceComplexLinkMedium.self, viewModelClass: ListDeviceComplexLinkMediumModel.self)
|
||||
|
||||
// Designed Section Dividers
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self)
|
||||
|
||||
@ -7,3 +7,69 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@objcMembers open class ListDeviceComplexLinkMedium: TableViewCell {
|
||||
|
||||
//-----------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//-----------------------------------------------------
|
||||
private let stack: Stack<StackModel>
|
||||
public let eyebrow = Label.createLabelRegularMicro(true)
|
||||
public let headline = Label.createLabelBoldTitleMedium(true)
|
||||
public let body = Label.createLabelRegularBodySmall(true)
|
||||
public let body2 = Label.createLabelRegularBodySmall(true)
|
||||
public let link = Link()
|
||||
public let rightImage = MFLoadImageView(pinnedEdges: .all)
|
||||
let leftStack: Stack<StackModel>
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//------------------------------------------------------
|
||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
leftStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body2, model: StackItemModel(horizontalAlignment: .leading)), (view: link, model: StackItemModel(horizontalAlignment: .leading))], axis: .vertical, spacing: 0)
|
||||
leftStack.stackModel?.molecules[4].spacing = 16
|
||||
rightImage.addSizeConstraintsForAspectRatio = true
|
||||
stack = Stack<StackModel>.createStack(with: [(view: leftStack, model: StackItemModel(horizontalAlignment: .leading)), (view: rightImage, model: StackItemModel(verticalAlignment: .center))], axis: .horizontal)
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// MARK: - View Lifecycle
|
||||
//-----------------------------------------------------
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
leftStack.restack()
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Molecule
|
||||
//------------------------------------------------------
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? ListDeviceComplexLinkMediumModel else { return }
|
||||
eyebrow.setOptional(with: model.eyebrow, delegateObject, additionalData)
|
||||
headline.setOptional(with: model.headline, delegateObject, additionalData)
|
||||
body.setOptional(with: model.body, delegateObject, additionalData)
|
||||
body2.setOptional(with: model.body2, delegateObject, additionalData)
|
||||
link.set(with: model.link, delegateObject, additionalData)
|
||||
rightImage.set(with: model.image, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
return 120
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
eyebrow.styleRegularMicro(true)
|
||||
headline.styleBoldTitleMedium(true)
|
||||
body.styleRegularBodySmall(true)
|
||||
body2.styleRegularBodySmall(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,3 +7,74 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol {
|
||||
|
||||
public static var identifier: String = "listDvcLnkM"
|
||||
public var eyebrow: LabelModel?
|
||||
public var headline: LabelModel?
|
||||
public var body: LabelModel?
|
||||
public var body2: LabelModel?
|
||||
public var link: LinkModel
|
||||
public var image: ImageViewModel
|
||||
|
||||
public init(eyebrow: LabelModel, headline: LabelModel, body: LabelModel, body2: LabelModel, link: LinkModel, image: ImageViewModel) {
|
||||
self.eyebrow = eyebrow
|
||||
self.headline = headline
|
||||
self.body = body
|
||||
self.body2 = body2
|
||||
self.link = link
|
||||
self.image = image
|
||||
super.init()
|
||||
}
|
||||
|
||||
/// Defaults to set
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
eyebrow?.textColor = Color(uiColor: .mvmCoolGray6)
|
||||
if image.width == nil, image.height == nil {
|
||||
image.width = 116
|
||||
image.height = 116
|
||||
}
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case eyebrow
|
||||
case headline
|
||||
case body
|
||||
case body2
|
||||
case link
|
||||
case image
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
if let eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) {
|
||||
self.eyebrow = eyebrow
|
||||
}
|
||||
if let headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline) {
|
||||
self.headline = headline
|
||||
}
|
||||
if let body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) {
|
||||
self.body = body
|
||||
}
|
||||
if let body2 = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body2) {
|
||||
self.body2 = body2
|
||||
}
|
||||
link = try typeContainer.decode(LinkModel.self, forKey: .link)
|
||||
image = try typeContainer.decode(ImageViewModel.self, forKey: .image)
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
try super.encode(to: encoder)
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
||||
try container.encodeIfPresent(headline, forKey: .headline)
|
||||
try container.encodeIfPresent(body, forKey: .body)
|
||||
try container.encodeIfPresent(body2, forKey: .body2)
|
||||
try container.encode(link, forKey: .link)
|
||||
try container.encode(image, forKey: .image)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user