carousel to container

This commit is contained in:
Pfeil, Scott Robert 2019-12-17 09:51:49 -05:00
parent 03f64b0875
commit cd9e63b992

View File

@ -11,6 +11,7 @@ import UIKit
open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol { open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol {
open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)?
open var json: [AnyHashable: Any]? open var json: [AnyHashable: Any]?
public let containerHelper = ContainerHelper()
// In updateView, will set padding to default. // In updateView, will set padding to default.
open var updateViewHorizontalDefaults = true open var updateViewHorizontalDefaults = true
@ -91,21 +92,19 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
return return
} }
if molecule == nil { if molecule == nil {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) { if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) {
contentView.insertSubview(moleculeView, at: 0) contentView.insertSubview(moleculeView, at: 0)
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: true).values)) containerHelper.constrainView(moleculeView)
molecule = moleculeView molecule = moleculeView
} }
} else { } else {
molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
} }
// This molecule will handle spacing by default.
if let castView = molecule as? MVMCoreUIViewConstrainingProtocol {
castView.shouldSetHorizontalMargins?(false)
castView.shouldSetVerticalMargins?(false)
}
accessibilityElements = molecule?.subviews guard let molecule = molecule else { return }
containerHelper.set(with: json, for: molecule)
accessibilityElements = molecule.subviews
} }
public func reset() { public func reset() {