// // MoleculeHeaderView.swift // MVMCoreUI // // Created by Scott Pfeil on 2/12/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import UIKit public class MoleculeHeaderView: MoleculeContainer { var line = Line() var headerModel: MoleculeHeaderModel? { get { return model as? MoleculeHeaderModel } } // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) line.updateView(size) } public override func setupView() { super.setupView() line.setStyle(.heavy) addSubview(line) NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true } // MARK: - MVMCoreUIMoleculeViewProtocol open override func reset() { super.reset() line.setStyle(.heavy) } // MARK: - ModelMoleculeViewProtocol open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let headerModel = headerModel else { return } if let lineModel = headerModel.line { line.set(with: lineModel, delegateObject, additionalData) } } public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) { return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing } return 121 } }