Code refactor.
This commit is contained in:
parent
78fbadb1e1
commit
f2b5c53f3a
@ -14,19 +14,23 @@ import Foundation
|
||||
//--------------------------------------------------
|
||||
let headlineBody = HeadlineBody(frame: .zero)
|
||||
let button = PrimaryButton.button()
|
||||
let stack = UIStackView()
|
||||
var stack = Stack<StackModel>(frame: .zero)
|
||||
var spacingBetwenHeadlineBodyAndButton: CGFloat = 72.0
|
||||
|
||||
//-------------------------------------------------------
|
||||
// MARK: - View Lifecycle
|
||||
//-------------------------------------------------------
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||
stack.addArrangedSubview(headlineBody)
|
||||
stack.setCustomSpacing(72.0, after: headlineBody)
|
||||
stack.addArrangedSubview(button)
|
||||
stack.axis = .vertical
|
||||
stack.alignment = .leading
|
||||
stack = Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)),
|
||||
(view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], axis: .vertical)
|
||||
addSubview(stack)
|
||||
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
||||
}
|
||||
|
||||
open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
stack.updateView(size)
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -37,6 +41,7 @@ import Foundation
|
||||
guard let model = model as? HeadersH1ButtonModel else { return }
|
||||
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
|
||||
button.set(with: model.button, delegateObject, additionalData)
|
||||
stack.restack()
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user