From a03b50865f1c6af3400f29e2de3aa7be687caabd Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 19 Jun 2020 10:58:59 -0400 Subject: [PATCH] default dimension --- .../Atomic/Atoms/Views/LoadingSpinner.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift index b3224f68..7f7007b2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift @@ -26,7 +26,7 @@ open class LoadingSpinner: View { public var heightConstraint: NSLayoutConstraint? public var widthConstraint: NSLayoutConstraint? - + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -39,6 +39,13 @@ open class LoadingSpinner: View { return CAShapeLayer.self } + open override func setupView() { + super.setupView() + + heightConstraint = heightAnchor.constraint(equalToConstant: 0) + widthConstraint = widthAnchor.constraint(equalToConstant: 0) + } + override open func layoutSubviews() { super.layoutSubviews() layer.fillColor = nil @@ -172,8 +179,9 @@ open class LoadingSpinner: View { func pinWidthAndHeight(diameter: CGFloat) { - heightConstraint = heightAnchor.constraint(equalToConstant: diameter + lineWidth) - widthConstraint = widthAnchor.constraint(equalToConstant: diameter + lineWidth) + let dimension = diameter + lineWidth + heightConstraint?.constant = dimension + widthConstraint?.constant = dimension heightConstraint?.isActive = true widthConstraint?.isActive = true } @@ -188,10 +196,7 @@ open class LoadingSpinner: View { strokeColor = model.strokeColor.uiColor lineWidth = model.lineWidth - - if let diameter = model.diameter { - pinWidthAndHeight(diameter: diameter) - } + pinWidthAndHeight(diameter: model.diameter ?? 40) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {