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