used intrinsicSize for line
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
efc15eabdf
commit
28db6509cc
@ -29,12 +29,6 @@ open class Line: View {
|
|||||||
open var style: Style = .primary { didSet { setNeedsUpdate() } }
|
open var style: Style = .primary { didSet { setNeedsUpdate() } }
|
||||||
open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - Private Properties
|
|
||||||
//--------------------------------------------------
|
|
||||||
private var heightConstraint: NSLayoutConstraint?
|
|
||||||
private var widthConstraint: NSLayoutConstraint?
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -44,10 +38,19 @@ open class Line: View {
|
|||||||
config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary)
|
config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary)
|
||||||
return config.eraseToAnyColorable()
|
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.
|
/// Resets to default settings.
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
@ -57,23 +60,15 @@ open class Line: View {
|
|||||||
|
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.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.
|
/// Function used to make changes to the View based off a change events or from local properties.
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
if orientation == .vertical {
|
|
||||||
heightConstraint?.isActive = false
|
|
||||||
widthConstraint?.isActive = true
|
|
||||||
} else {
|
|
||||||
widthConstraint?.isActive = false
|
|
||||||
heightConstraint?.isActive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
backgroundColor = lineViewColorConfiguration.getColor(self)
|
backgroundColor = lineViewColorConfiguration.getColor(self)
|
||||||
|
|
||||||
|
invalidateIntrinsicContentSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user