Changed TableViewCell to Container in Molecule class and ListItemModelProtocol to MoleculeModelProtocol
This commit is contained in:
parent
8ca15468f4
commit
5f2abffba0
@ -9,42 +9,25 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers public class LeftVariableIconRightCaretList : TableViewCell {
|
@objcMembers public class LeftVariableIconRightCaretList : Container {
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
let leftImage = MFLoadImageView()
|
let leftImage = MFLoadImageView()
|
||||||
let leftLabel = Label.commonLabelB2(true)
|
let leftLabel = Label(frame: .zero)
|
||||||
let rightLabel = Label.commonLabelB2(true)
|
let rightLabel = Label(frame: .zero)
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
let spaceBetweenLabels : CGFloat = 40
|
let spaceBetweenLabels : CGFloat = 180
|
||||||
let horizontalPadding : CGFloat = 12
|
let horizontalPadding : CGFloat = 14
|
||||||
let rightLabelTrailing : CGFloat = 20
|
|
||||||
let cellHeight : CGFloat = 60
|
|
||||||
let imageSize : CGFloat = 30
|
let imageSize : CGFloat = 30
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Initialization
|
|
||||||
//--------------------------------------------------------
|
|
||||||
|
|
||||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
|
|
||||||
required public init?(coder aDecoder: NSCoder) {
|
|
||||||
super.init(coder: aDecoder)
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
@ -63,28 +46,29 @@ import UIKit
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
addSubview(leftImage)
|
let container = MVMCoreUICommonViewsUtility.commonView()
|
||||||
addSubview(leftLabel)
|
|
||||||
addSubview(rightLabel)
|
|
||||||
|
|
||||||
|
addAndContain(container)
|
||||||
|
container.addSubview(leftImage)
|
||||||
|
container.addSubview(leftLabel)
|
||||||
|
container.addSubview(rightLabel)
|
||||||
|
|
||||||
contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true
|
self.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
leftImage.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
|
leftImage.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true
|
||||||
leftImage.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
|
leftImage.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
|
||||||
leftImage.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
|
leftImage.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
|
||||||
leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true
|
leftImage.widthAnchor.constraint(equalToConstant: imageSize).isActive = true
|
||||||
leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true
|
leftImage.heightAnchor.constraint(equalToConstant: imageSize).isActive = true
|
||||||
|
|
||||||
leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: horizontalPadding).isActive = true
|
leftLabel.leadingAnchor.constraint(equalTo: leftImage.trailingAnchor, constant: horizontalPadding).isActive = true
|
||||||
leftLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
|
leftLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
|
||||||
leftLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
|
leftLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
|
||||||
rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leftLabel.trailingAnchor, constant: spaceBetweenLabels).isActive = true
|
rightLabel.leadingAnchor.constraint(equalTo: leftLabel.trailingAnchor,constant: spaceBetweenLabels).isActive = true
|
||||||
rightLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
|
rightLabel.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
|
||||||
rightLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
|
rightLabel.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
|
||||||
layoutMarginsGuide.trailingAnchor.constraint(equalTo: rightLabel.trailingAnchor, constant: rightLabelTrailing).isActive = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
@ -99,10 +83,6 @@ import UIKit
|
|||||||
rightLabel.reset()
|
rightLabel.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
open func setAsMolecule() {
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
|
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class LeftVariableIconRightCaretListModel: ListItemModelProtocol {
|
public class LeftVariableIconRightCaretListModel: MoleculeModelProtocol {
|
||||||
|
|
||||||
public var horizontalAlignment: UIStackView.Alignment?
|
public var horizontalAlignment: UIStackView.Alignment?
|
||||||
public var verticalAlignment: UIStackView.Alignment?
|
public var verticalAlignment: UIStackView.Alignment?
|
||||||
@ -19,7 +19,7 @@ public class LeftVariableIconRightCaretListModel: ListItemModelProtocol {
|
|||||||
|
|
||||||
|
|
||||||
public var line: LineModel? = LineModel(type: .standard)
|
public var line: LineModel? = LineModel(type: .standard)
|
||||||
public var hideArrow: Bool? = false
|
public var hideArrow: Bool?
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public static var identifier: String = "listLVImg"
|
public static var identifier: String = "listLVImg"
|
||||||
@ -35,5 +35,28 @@ public class LeftVariableIconRightCaretListModel: ListItemModelProtocol {
|
|||||||
self.rightLabel = rightLabel
|
self.rightLabel = rightLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case moleculeName
|
||||||
|
case leftLabel
|
||||||
|
case rightLabel
|
||||||
|
case image
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
||||||
|
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||||
|
image = try typeContainer.decode(ImageViewModel.self, forKey: .image)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(LeftVariableIconRightCaretListModel.identifier, forKey: .moleculeName)
|
||||||
|
try container.encode(leftLabel, forKey: .leftLabel)
|
||||||
|
try container.encode(rightLabel, forKey: .rightLabel)
|
||||||
|
try container.encodeIfPresent(image, forKey: .image)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user