Removed container and added stackmodel code changes.
This commit is contained in:
parent
cadf70ce70
commit
5b1b29c10d
@ -16,17 +16,7 @@ import Foundation
|
|||||||
|
|
||||||
let checkbox = Checkbox(frame: .zero)
|
let checkbox = Checkbox(frame: .zero)
|
||||||
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
|
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
|
||||||
let containerView = Container()
|
let stack = Stack<StackModel>(frame: .zero)
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Properties
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
let cellHeight: CGFloat = 125.0
|
|
||||||
let leftPadding: CGFloat = 35.0
|
|
||||||
let rightPadding: CGFloat = 35.0
|
|
||||||
let spaceBetweenCheckBoxAndEyebrowHedline: CGFloat = 16.0
|
|
||||||
let checkBoxSize: CGFloat = 18.0
|
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
@ -34,9 +24,7 @@ import Foundation
|
|||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
containerView.updateView(size)
|
stack.updateView(size)
|
||||||
checkbox.updateView(size)
|
|
||||||
eyebrowHeadlineBodyLink.updateView(size)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func setupView() {
|
override open func setupView() {
|
||||||
@ -44,28 +32,10 @@ import Foundation
|
|||||||
guard checkbox.superview == nil else {
|
guard checkbox.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
containerView.translatesAutoresizingMaskIntoConstraints = false
|
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||||
contentView.heightAnchor.constraint(equalToConstant: cellHeight).isActive = true
|
stack.stackItems = [StackItem(andContain: checkbox),StackItem(andContain: eyebrowHeadlineBodyLink)]
|
||||||
contentView.addSubview(containerView)
|
contentView.addSubview(stack)
|
||||||
|
containerHelper.constrainView(stack)
|
||||||
//containerView constraints
|
|
||||||
containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
|
||||||
containerView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
|
||||||
containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
||||||
containerView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
||||||
|
|
||||||
containerView.addSubview(checkbox)
|
|
||||||
containerView.addSubview(eyebrowHeadlineBodyLink)
|
|
||||||
|
|
||||||
//checkBox constraints
|
|
||||||
checkbox.centerYAnchor.constraint(equalTo: eyebrowHeadlineBodyLink.centerYAnchor).isActive = true
|
|
||||||
checkbox.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: leftPadding).isActive = true
|
|
||||||
|
|
||||||
//eyebrowHeadlineBodyLink constraints
|
|
||||||
eyebrowHeadlineBodyLink.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
|
|
||||||
eyebrowHeadlineBodyLink.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
|
|
||||||
eyebrowHeadlineBodyLink.leadingAnchor.constraint(equalTo: checkbox.trailingAnchor, constant: spaceBetweenCheckBoxAndEyebrowHedline).isActive = true
|
|
||||||
eyebrowHeadlineBodyLink.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
@ -74,8 +44,7 @@ import Foundation
|
|||||||
|
|
||||||
override open func reset() {
|
override open func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
checkbox.reset()
|
stack.reset()
|
||||||
eyebrowHeadlineBodyLink.reset()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
@ -83,5 +52,16 @@ import Foundation
|
|||||||
guard let model = model as? ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel else { return}
|
guard let model = model as? ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel else { return}
|
||||||
checkbox.setWithModel(model.checkbox, delegateObject, additionalData)
|
checkbox.setWithModel(model.checkbox, delegateObject, additionalData)
|
||||||
eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
|
eyebrowHeadlineBodyLink.setWithModel(model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
|
||||||
|
|
||||||
|
// Create a stack model to use for the internal stack and set the alignment of labels
|
||||||
|
let checkbox = StackItemModel()
|
||||||
|
checkbox.horizontalAlignment = .leading
|
||||||
|
let eyebrowHeadlineBodyLink = StackItemModel()
|
||||||
|
eyebrowHeadlineBodyLink.horizontalAlignment = .leading
|
||||||
|
eyebrowHeadlineBodyLink.spacing = 20
|
||||||
|
let stackModel = StackModel(molecules: [checkbox,eyebrowHeadlineBodyLink])
|
||||||
|
stackModel.axis = .horizontal
|
||||||
|
stack.model = stackModel
|
||||||
|
stack.restack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,10 +11,13 @@ import Foundation
|
|||||||
public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ContainerModel, ListItemModelProtocol {
|
public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: ContainerModel, ListItemModelProtocol {
|
||||||
|
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
public var hideArrow: Bool?
|
public var style: String? = "standard"
|
||||||
|
public var hideArrow: Bool? = false
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
public var action: ActionModelProtocol?
|
||||||
public static var identifier: String = "listLVCB"
|
public static var identifier: String = "listLVCB"
|
||||||
public var checkbox: CheckboxModel
|
public var checkbox: CheckboxModel
|
||||||
|
public var spacing: CGFloat = 16.0
|
||||||
var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
|
||||||
|
|
||||||
func setDefaults() {
|
func setDefaults() {
|
||||||
@ -43,6 +46,8 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain
|
|||||||
case backgroundColor
|
case backgroundColor
|
||||||
case eyebrowHeadlineBodyLink
|
case eyebrowHeadlineBodyLink
|
||||||
case checkbox
|
case checkbox
|
||||||
|
case action
|
||||||
|
case spacing
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
@ -50,6 +55,10 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink)
|
eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink)
|
||||||
checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox)
|
checkbox = try typeContainer.decode(CheckboxModel.self, forKey: .checkbox)
|
||||||
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||||
|
if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) {
|
||||||
|
self.spacing = spacing
|
||||||
|
}
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
setDefaults()
|
setDefaults()
|
||||||
}
|
}
|
||||||
@ -57,10 +66,12 @@ public class ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel: Contain
|
|||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(ListLeftVariableCheckboxWithRightCaretAllTextAndLinksModel.identifier, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink)
|
try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink)
|
||||||
try container.encode(checkbox, forKey: .checkbox)
|
try container.encode(checkbox, forKey: .checkbox)
|
||||||
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
|
try container.encodeIfPresent(spacing, forKey: .spacing)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user