72 lines
2.8 KiB
Swift
72 lines
2.8 KiB
Swift
//
|
|
// StandardHeaderView.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Scott Pfeil on 2/12/19.
|
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
public class StandardHeaderView: ViewConstrainingView {
|
|
var separatorView: SeparatorView?
|
|
|
|
// MARK: - MVMCoreViewProtocol
|
|
open override func updateView(_ size: CGFloat) {
|
|
super.updateView(size)
|
|
separatorView?.updateView(size)
|
|
}
|
|
|
|
public override func setupView() {
|
|
super.setupView()
|
|
shouldSetupMoleculeFromJSON = true
|
|
updateViewVerticalDefaults = true
|
|
updateViewHorizontalDefaults = true
|
|
topMarginPadding = PaddingDefaultVerticalSpacing
|
|
bottomMarginPadding = PaddingDefaultVerticalSpacing
|
|
if separatorView == nil, let separatorView = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot, withHorizontalPadding: 0) {
|
|
separatorView.setAsHeavy()
|
|
addSubview(separatorView)
|
|
self.separatorView = separatorView
|
|
}
|
|
}
|
|
|
|
public override func setLeftPinConstant(_ constant: CGFloat) {
|
|
super.setLeftPinConstant(constant)
|
|
separatorView?.leftPin?.constant = constant
|
|
}
|
|
|
|
public override func setRightPinConstant(_ constant: CGFloat) {
|
|
super.setRightPinConstant(constant)
|
|
separatorView?.rightPin?.constant = constant
|
|
}
|
|
|
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
|
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
|
|
// This molecule will by default handle margins.
|
|
(molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false)
|
|
(molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false)
|
|
|
|
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
|
|
separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
|
|
}
|
|
}
|
|
|
|
open override func reset() {
|
|
super.reset()
|
|
topMarginPadding = PaddingDefaultVerticalSpacing
|
|
bottomMarginPadding = PaddingDefaultVerticalSpacing
|
|
separatorView?.setAsHeavy()
|
|
separatorView?.show()
|
|
}
|
|
|
|
public override 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
|
|
}
|
|
}
|