update others

This commit is contained in:
Pfeil, Scott Robert 2020-04-23 12:30:07 -04:00
parent be0c9b8742
commit 4b23a63823
2 changed files with 13 additions and 25 deletions

View File

@ -40,24 +40,18 @@ import Foundation
override open func setupView() {
super.setupView()
addMolecule(stack)
stack.restack()
}
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){
super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListOneColumnFullWidthTextAllTextAndLinksModel else { return }
eyebrow.setOptional(with: model.eyebrow, delegateObject, additionalData)
headline.setOptional(with: model.headline, delegateObject, additionalData)
subHeadline.setOptional(with: model.subHeadline, delegateObject, additionalData)
body.setOptional(with: model.body, delegateObject, additionalData)
link.setOptional(with: model.link, delegateObject, additionalData)
// Hide labels if neeeded.
stack.stackModel?.molecules[0].gone = !eyebrow.hasText
stack.stackModel?.molecules[1].gone = !headline.hasText
stack.stackModel?.molecules[2].gone = !subHeadline.hasText
stack.stackModel?.molecules[3].gone = !body.hasText
stack.stackModel?.molecules[4].gone = (link.titleLabel?.text?.count ?? 0) == 0
stack.restack()
stack.updateContainedMolecules(with: [model.eyebrow,
model.headline,
model.subHeadline,
model.body,
model.link],
delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {

View File

@ -33,6 +33,7 @@ import UIKit
stack.stackModel?.spacing = 0
addSubview(stack)
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
stack.restack()
}
open override func updateView(_ size: CGFloat) {
@ -58,18 +59,11 @@ import UIKit
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
eyebrow.setOptional(with: castModel?.eyebrow, delegateObject, additionalData)
headline.setOptional(with: castModel?.headline, delegateObject, additionalData)
body.setOptional(with: castModel?.body, delegateObject, additionalData)
link.setOptional(with: castModel?.link, delegateObject, additionalData)
// Hide labels if neeeded.
stack.stackModel?.molecules[0].gone = !eyebrow.hasText
stack.stackModel?.molecules[1].gone = !headline.hasText
stack.stackModel?.molecules[2].gone = !body.hasText
stack.stackModel?.molecules[3].gone = (link.titleLabel?.text?.count ?? 0) == 0
stack.restack()
stack.updateContainedMolecules(with: [castModel?.eyebrow,
castModel?.headline,
castModel?.body,
castModel?.link],
delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {