added the borderline as a view to be repositioned based on orientation + indicator position
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
571b41b54e
commit
ae4d0f5287
@ -101,12 +101,21 @@ open class Tabs: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
private var tabStackView: UIStackView!
|
||||
private var scrollView: UIScrollView!
|
||||
private var contentView: View!
|
||||
private var tabStackView = UIStackView()
|
||||
private var scrollView = UIScrollView()
|
||||
private var contentView = View()
|
||||
private var borderlineView = View()
|
||||
private let borderlineSize = 1.0
|
||||
private var borderlineColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark)
|
||||
private var contentViewWidthConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewLeadingConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewTrailingConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewTopConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewBottomConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewHeightConstraint: NSLayoutConstraint?
|
||||
private var borderlineViewWidthConstraint: NSLayoutConstraint?
|
||||
|
||||
private var contentViewWidthConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
@ -141,12 +150,22 @@ open class Tabs: View {
|
||||
tabStackView.axis = .horizontal
|
||||
tabStackView.distribution = .fill
|
||||
tabStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(borderlineView)
|
||||
contentView.addSubview(tabStackView)
|
||||
|
||||
|
||||
scrollView.pinToSuperView()
|
||||
contentView.pinToSuperView()
|
||||
tabStackView.pinToSuperView()
|
||||
contentView.heightAnchor.constraint(equalTo: scrollView.heightAnchor).isActive = true
|
||||
|
||||
borderlineViewWidthConstraint = borderlineView.widthAnchor.constraint(equalToConstant: 0)
|
||||
borderlineViewHeightConstraint = borderlineView.heightAnchor.constraint(equalToConstant: 0)
|
||||
|
||||
borderlineViewLeadingConstraint = borderlineView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor)
|
||||
borderlineViewTrailingConstraint = borderlineView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor)
|
||||
borderlineViewTopConstraint = borderlineView.topAnchor.constraint(equalTo: contentView.topAnchor)
|
||||
borderlineViewBottomConstraint = borderlineView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
|
||||
|
||||
}
|
||||
|
||||
private func updateTabItems() {
|
||||
@ -256,7 +275,6 @@ open class Tabs: View {
|
||||
}
|
||||
|
||||
//borderLine
|
||||
removeBorders()
|
||||
if borderLine {
|
||||
var edge: UIRectEdge = .bottom
|
||||
if orientation == .vertical {
|
||||
@ -264,7 +282,39 @@ open class Tabs: View {
|
||||
} else if indicatorPosition == .top {
|
||||
edge = .top
|
||||
}
|
||||
addBorder(side: edge, width: 1, color: borderlineColorConfiguration.getColor(self))
|
||||
|
||||
borderlineViewLeadingConstraint?.isActive = false
|
||||
borderlineViewTrailingConstraint?.isActive = false
|
||||
borderlineViewTopConstraint?.isActive = false
|
||||
borderlineViewBottomConstraint?.isActive = false
|
||||
borderlineViewHeightConstraint?.isActive = false
|
||||
borderlineViewWidthConstraint?.isActive = false
|
||||
|
||||
if edge == .left {
|
||||
borderlineViewWidthConstraint?.constant = borderlineSize
|
||||
borderlineViewWidthConstraint?.isActive = true
|
||||
borderlineViewTopConstraint?.isActive = true
|
||||
borderlineViewLeadingConstraint?.isActive = true
|
||||
borderlineViewBottomConstraint?.isActive = true
|
||||
|
||||
} else if edge == .top {
|
||||
borderlineViewHeightConstraint?.constant = borderlineSize
|
||||
borderlineViewHeightConstraint?.isActive = true
|
||||
borderlineViewTopConstraint?.isActive = true
|
||||
borderlineViewLeadingConstraint?.isActive = true
|
||||
borderlineViewTrailingConstraint?.isActive = true
|
||||
|
||||
} else {
|
||||
borderlineViewHeightConstraint?.constant = borderlineSize
|
||||
borderlineViewHeightConstraint?.isActive = true
|
||||
borderlineViewLeadingConstraint?.isActive = true
|
||||
borderlineViewTrailingConstraint?.isActive = true
|
||||
borderlineViewBottomConstraint?.isActive = true
|
||||
}
|
||||
borderlineView.backgroundColor = borderlineColorConfiguration.getColor(self)
|
||||
borderlineView.isHidden = false
|
||||
} else {
|
||||
borderlineView.isHidden = true
|
||||
}
|
||||
|
||||
scrollToSelectedIndex(animated: true)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user