Code changes using the StackModel
This commit is contained in:
parent
d5ac7e3e6d
commit
d92c5b5679
@ -13,14 +13,13 @@ import Foundation
|
||||
let leftHeadlineBody = HeadlineBody(frame: .zero)
|
||||
let centerHeadLineBody = HeadlineBody(frame: .zero)
|
||||
let rightHeadLineBody = HeadlineBody(frame: .zero)
|
||||
private var stack = UIStackView()
|
||||
let stack = Stack<StackModel>(frame: .zero)
|
||||
|
||||
// MARK: - MFViewProtocol
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
leftHeadlineBody.updateView(size)
|
||||
centerHeadLineBody.updateView(size)
|
||||
rightHeadLineBody.updateView(size)
|
||||
styleTallDivider()
|
||||
stack.updateView(size)
|
||||
}
|
||||
|
||||
open override func setupView() {
|
||||
@ -28,18 +27,11 @@ import Foundation
|
||||
guard leftHeadlineBody.superview == nil else {
|
||||
return
|
||||
}
|
||||
//using stackView to align the three headlineBody
|
||||
//using stackItems to align the three headlineBody
|
||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||
stack.stackItems = [StackItem(andContain: leftHeadlineBody),StackItem(andContain: centerHeadLineBody),StackItem(andContain: rightHeadLineBody)]
|
||||
contentView.addSubview(stack)
|
||||
stack.addArrangedSubview(leftHeadlineBody)
|
||||
stack.addArrangedSubview(centerHeadLineBody)
|
||||
stack.addArrangedSubview(rightHeadLineBody)
|
||||
NSLayoutConstraint.constraintPinSubview(stack, pinTop: true, topConstant: 0, pinBottom: false, bottomConstant: 0, pinLeft: true, leftConstant: PaddingDefaultHorizontalSpacing, pinRight: true, rightConstant: PaddingDefaultHorizontalSpacing)
|
||||
stack.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 0).isActive = true
|
||||
stack.axis = .horizontal
|
||||
stack.spacing = 35
|
||||
stack.distribution = .fillProportionally
|
||||
styleTallDivider()
|
||||
containerHelper.constrainView(stack)
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
@ -49,14 +41,18 @@ import Foundation
|
||||
leftHeadlineBody.setWithModel(model.leftHeadlineBody, delegateObject, additionalData)
|
||||
centerHeadLineBody.setWithModel(model.centerHeadlineBody, delegateObject, additionalData)
|
||||
rightHeadLineBody.setWithModel(model.rightHeadlineBody, delegateObject, additionalData)
|
||||
|
||||
// Create a stack model to use for the internal stack.
|
||||
let stackModel = StackModel(molecules: [StackItemModel(percent: 33),StackItemModel(percent: 33),StackItemModel(percent: 33)])
|
||||
stackModel.spacing = 0
|
||||
stackModel.axis = .horizontal
|
||||
stack.model = stackModel
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
styleTallDivider()
|
||||
leftHeadlineBody.reset()
|
||||
centerHeadLineBody.reset()
|
||||
rightHeadLineBody.reset()
|
||||
stack.reset()
|
||||
}
|
||||
|
||||
public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
|
||||
@ -19,4 +19,9 @@ import Foundation
|
||||
self.init()
|
||||
self.gone = gone
|
||||
}
|
||||
|
||||
public convenience init(percent: Int) {
|
||||
self.init()
|
||||
self.percent = percent
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user