default dimension

This commit is contained in:
Kevin G Christiano 2020-06-19 10:58:59 -04:00
parent 76f39b3f22
commit a03b50865f

View File

@ -26,7 +26,7 @@ open class LoadingSpinner: View {
public var heightConstraint: NSLayoutConstraint? public var heightConstraint: NSLayoutConstraint?
public var widthConstraint: NSLayoutConstraint? public var widthConstraint: NSLayoutConstraint?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Lifecycle // MARK: - Lifecycle
//-------------------------------------------------- //--------------------------------------------------
@ -39,6 +39,13 @@ open class LoadingSpinner: View {
return CAShapeLayer.self return CAShapeLayer.self
} }
open override func setupView() {
super.setupView()
heightConstraint = heightAnchor.constraint(equalToConstant: 0)
widthConstraint = widthAnchor.constraint(equalToConstant: 0)
}
override open func layoutSubviews() { override open func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
layer.fillColor = nil layer.fillColor = nil
@ -172,8 +179,9 @@ open class LoadingSpinner: View {
func pinWidthAndHeight(diameter: CGFloat) { func pinWidthAndHeight(diameter: CGFloat) {
heightConstraint = heightAnchor.constraint(equalToConstant: diameter + lineWidth) let dimension = diameter + lineWidth
widthConstraint = widthAnchor.constraint(equalToConstant: diameter + lineWidth) heightConstraint?.constant = dimension
widthConstraint?.constant = dimension
heightConstraint?.isActive = true heightConstraint?.isActive = true
widthConstraint?.isActive = true widthConstraint?.isActive = true
} }
@ -188,10 +196,7 @@ open class LoadingSpinner: View {
strokeColor = model.strokeColor.uiColor strokeColor = model.strokeColor.uiColor
lineWidth = model.lineWidth lineWidth = model.lineWidth
pinWidthAndHeight(diameter: model.diameter ?? 40)
if let diameter = model.diameter {
pinWidthAndHeight(diameter: diameter)
}
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {