From 0fc6d78d3c6dad19be38cb0fd7bb859c707a1ec8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 13:44:19 -0500 Subject: [PATCH 1/2] added static var Signed-off-by: Matt Bruce --- VDS/Components/Line/Line.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 17bf92c1..4100c63a 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -45,7 +45,7 @@ open class Line: View { // MARK: - Configuration //-------------------------------------------------- /// Width of the line. - public let lineWidth: CGFloat = 1.0 + public static let lineWidth: CGFloat = 1.0 //-------------------------------------------------- // MARK: - Public Properties @@ -59,9 +59,9 @@ open class Line: View { /// The natural size for the receiving view, considering only properties of the view itself. open override var intrinsicContentSize: CGSize { if orientation == .vertical { - return .init(width: 1, height: bounds.height) + return .init(width: Self.lineWidth, height: bounds.height) } else { - return .init(width: bounds.width, height: 1) + return .init(width: bounds.width, height: Self.lineWidth) } } @@ -103,7 +103,7 @@ open class Line: View { guard let context = UIGraphicsGetCurrentContext() else { return } context.setStrokeColor(lineViewColorConfiguration.getColor(self).cgColor) - context.setLineWidth(lineWidth) + context.setLineWidth(Self.lineWidth) if orientation == .horizontal { context.move(to: CGPoint(x: 0, y: rect.height / 2)) From a3d239779dd21085fb7e13a2a09e49d848671ef7 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 20 Sep 2023 14:02:18 -0500 Subject: [PATCH 2/2] updated property getter for lineColor Signed-off-by: Matt Bruce --- VDS/Components/Line/Line.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 4100c63a..78ffd545 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -45,7 +45,7 @@ open class Line: View { // MARK: - Configuration //-------------------------------------------------- /// Width of the line. - public static let lineWidth: CGFloat = 1.0 + public let lineWidth: CGFloat = 1.0 //-------------------------------------------------- // MARK: - Public Properties @@ -56,12 +56,15 @@ open class Line: View { /// Allows to render the line vertically. open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } } + /// Line Color for current Style and Surface. + open var lineColor: UIColor { lineViewColorConfiguration.getColor(self) } + /// The natural size for the receiving view, considering only properties of the view itself. open override var intrinsicContentSize: CGSize { if orientation == .vertical { - return .init(width: Self.lineWidth, height: bounds.height) + return .init(width: lineWidth, height: bounds.height) } else { - return .init(width: bounds.width, height: Self.lineWidth) + return .init(width: bounds.width, height: lineWidth) } } @@ -76,7 +79,7 @@ open class Line: View { config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary) return config.eraseToAnyColorable() }() - + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- @@ -102,8 +105,8 @@ open class Line: View { open override func draw(_ rect: CGRect) { guard let context = UIGraphicsGetCurrentContext() else { return } - context.setStrokeColor(lineViewColorConfiguration.getColor(self).cgColor) - context.setLineWidth(Self.lineWidth) + context.setStrokeColor(lineColor.cgColor) + context.setLineWidth(lineWidth) if orientation == .horizontal { context.move(to: CGPoint(x: 0, y: rect.height / 2))