refactored to for orientation
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
970ea12bc2
commit
3e3baac609
@ -19,14 +19,21 @@ open class Line: View {
|
|||||||
case primary, secondary
|
case primary, secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Orientation: String, CaseIterable {
|
||||||
|
case horizontal, vertical
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var lineView = UIView().with {
|
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
}
|
|
||||||
|
|
||||||
open var style: Style = .primary { didSet { setNeedsUpdate() } }
|
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
|
// MARK: - Configuration
|
||||||
@ -41,25 +48,32 @@ open class Line: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func setup() {
|
|
||||||
super.setup()
|
|
||||||
|
|
||||||
addSubview(lineView)
|
|
||||||
lineView.height(1)
|
|
||||||
lineView.pinToSuperView()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// Resets to default settings.
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
style = .primary
|
style = .primary
|
||||||
|
orientation = .horizontal
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
/// 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()
|
||||||
|
|
||||||
lineView.backgroundColor = lineViewColorConfiguration.getColor(self)
|
if orientation == .vertical {
|
||||||
|
heightConstraint?.isActive = false
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
} else {
|
||||||
|
widthConstraint?.isActive = false
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
backgroundColor = lineViewColorConfiguration.getColor(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user