open view up!

This commit is contained in:
Pfeil, Scott Robert 2019-10-29 13:56:19 -04:00
parent 59be22c0e0
commit d901ded4c1

View File

@ -8,47 +8,46 @@
import UIKit
public class View: UIView {
var json: [AnyHashable: Any]?
open class View: UIView {
open var json: [AnyHashable: Any]?
private var initialSetupPerformed = false
public override init(frame: CGRect) {
super.init(frame: .zero)
initialSetup()
}
super.init(frame: .zero)
initialSetup()
}
init() {
super.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
initialSetup()
}
public func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
init() {
super.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
initialSetup()
}
public func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
}
}
extension View: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) {
}
open func updateView(_ size: CGFloat) {}
/// Will be called only once.
public func setupView() {
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
}
}
extension View: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
self.json = json
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
@ -56,7 +55,7 @@ extension View: MVMCoreUIMoleculeViewProtocol {
}
}
public func reset() {
open func reset() {
backgroundColor = .clear
}
}