diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index ffef28b5..e64e7406 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -29,12 +29,6 @@ open class Line: View { open var style: Style = .primary { didSet { setNeedsUpdate() } } open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } } - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var heightConstraint: NSLayoutConstraint? - private var widthConstraint: NSLayoutConstraint? - //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- @@ -44,10 +38,19 @@ open class Line: View { config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary) return config.eraseToAnyColorable() }() - + //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Overrides //-------------------------------------------------- + + open override var intrinsicContentSize: CGSize { + if orientation == .vertical { + return .init(width: 1, height: bounds.height) + } else { + return .init(width: bounds.width, height: 1) + } + } + /// Resets to default settings. open override func reset() { super.reset() @@ -57,23 +60,15 @@ open class Line: View { open override func setup() { super.setup() - - heightConstraint = heightAnchor.constraint(equalToConstant: 1) - widthConstraint = widthAnchor.constraint(equalToConstant: 1) } /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() - - if orientation == .vertical { - heightConstraint?.isActive = false - widthConstraint?.isActive = true - } else { - widthConstraint?.isActive = false - heightConstraint?.isActive = true - } backgroundColor = lineViewColorConfiguration.getColor(self) + + invalidateIntrinsicContentSize() } + }