67 lines
2.8 KiB
Swift
67 lines
2.8 KiB
Swift
//
|
|
// Scroller.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Scott Pfeil on 7/23/19.
|
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
@objcMembers open class Scroller: ViewConstrainingView {
|
|
public let scrollView = UIScrollView(frame: .zero)
|
|
public let contentView = MVMCoreUICommonViewsUtility.commonView()
|
|
|
|
override open func setupView() {
|
|
super.setupView()
|
|
guard scrollView.superview == nil else {
|
|
return
|
|
}
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
|
addSubview(scrollView)
|
|
pinView(toSuperView: scrollView)
|
|
scrollView.addSubview(contentView)
|
|
NSLayoutConstraint.constraintPinSubview(toSuperview: contentView)
|
|
let constraint = contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, multiplier: 1.0)
|
|
constraint.priority = UILayoutPriority(rawValue: 999)
|
|
constraint.isActive = true
|
|
}
|
|
|
|
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
|
#warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
|
|
//TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
|
|
setUpDefaultWithModel(model, delegateObject, additionalData)
|
|
|
|
guard let model = model,
|
|
let moleculeModel = (model as? ContainerMoleculeProtocol)?.molecule else {
|
|
return
|
|
}
|
|
|
|
if molecule == nil {
|
|
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) {
|
|
contentView.addSubview(moleculeView)
|
|
pinView(toSuperView: moleculeView)
|
|
molecule = moleculeView
|
|
}
|
|
} else {
|
|
(molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData)
|
|
}
|
|
}
|
|
|
|
// open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
|
// guard let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else {
|
|
// return
|
|
// }
|
|
// if molecule == nil {
|
|
// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) {
|
|
// contentView.addSubview(moleculeView)
|
|
// pinView(toSuperView: moleculeView)
|
|
// molecule = moleculeView
|
|
// }
|
|
// } else {
|
|
// molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
|
// }
|
|
// }
|
|
}
|