reverted back to develop tab
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
ac1e6f692d
commit
c2998ee0bf
@ -20,7 +20,7 @@ extension Tabs {
|
|||||||
open var index: Int = 0
|
open var index: Int = 0
|
||||||
|
|
||||||
///label to write out the text
|
///label to write out the text
|
||||||
open var label: Label = Label().with { $0.updateStrategy = .alwaysImmediate }
|
open var label: Label = Label()
|
||||||
|
|
||||||
///orientation of the tabs
|
///orientation of the tabs
|
||||||
open var orientation: Tabs.Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
open var orientation: Tabs.Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
||||||
@ -95,15 +95,11 @@ extension Tabs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var widthConstraint: NSLayoutConstraint? {
|
private var widthConstraint: NSLayoutConstraint {
|
||||||
if let width, orientation == .vertical {
|
if let width, orientation == .vertical {
|
||||||
return label.widthAnchor.constraint(equalToConstant: width)
|
return label.widthAnchor.constraint(equalToConstant: width)
|
||||||
} else {
|
} else {
|
||||||
if label.intrinsicContentSize.width <= minWidth {
|
return label.widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth)
|
||||||
return label.widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth)
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +123,6 @@ extension Tabs {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
label.updateStrategy = .alwaysImmediate
|
|
||||||
|
|
||||||
addSubview(label)
|
addSubview(label)
|
||||||
accessibilityTraits = .button
|
accessibilityTraits = .button
|
||||||
|
|
||||||
@ -143,19 +137,7 @@ extension Tabs {
|
|||||||
|
|
||||||
labelLeadingConstraint = label.leadingAnchor.constraint(equalTo: leadingAnchor)
|
labelLeadingConstraint = label.leadingAnchor.constraint(equalTo: leadingAnchor)
|
||||||
labelLeadingConstraint?.isActive = true
|
labelLeadingConstraint?.isActive = true
|
||||||
|
|
||||||
let layoutGuide = UILayoutGuide()
|
|
||||||
addLayoutGuide(layoutGuide)
|
|
||||||
|
|
||||||
labelWidthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth)
|
|
||||||
labelWidthConstraint?.isActive = true
|
|
||||||
|
|
||||||
//activate the constraints
|
|
||||||
NSLayoutConstraint.activate([layoutGuide.topAnchor.constraint(equalTo: topAnchor),
|
|
||||||
layoutGuide.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
||||||
layoutGuide.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
||||||
layoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)])
|
|
||||||
|
|
||||||
publisher(for: UITapGestureRecognizer())
|
publisher(for: UITapGestureRecognizer())
|
||||||
.sink { [weak self] _ in
|
.sink { [weak self] _ in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
@ -171,26 +153,17 @@ extension Tabs {
|
|||||||
label.text = text
|
label.text = text
|
||||||
label.textStyle = textStyle
|
label.textStyle = textStyle
|
||||||
label.textPosition = textPosition
|
label.textPosition = textPosition
|
||||||
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
label.textColor = textColorConfiguration.getColor(self)
|
||||||
label.sizeToFit()
|
|
||||||
|
|
||||||
//constaints
|
//constaints
|
||||||
labelWidthConstraint?.deactivate()
|
labelWidthConstraint?.isActive = false
|
||||||
labelLeadingConstraint?.deactivate()
|
|
||||||
labelTopConstraint?.deactivate()
|
|
||||||
labelBottomConstraint?.deactivate()
|
|
||||||
|
|
||||||
labelWidthConstraint = widthConstraint
|
labelWidthConstraint = widthConstraint
|
||||||
|
labelWidthConstraint?.isActive = true
|
||||||
labelLeadingConstraint?.constant = leadingSpace
|
labelLeadingConstraint?.constant = leadingSpace
|
||||||
labelTopConstraint?.constant = otherSpace
|
labelTopConstraint?.constant = otherSpace
|
||||||
labelBottomConstraint?.constant = -otherSpace
|
labelBottomConstraint?.constant = -otherSpace
|
||||||
|
|
||||||
labelWidthConstraint?.activate()
|
|
||||||
labelLeadingConstraint?.activate()
|
|
||||||
labelTopConstraint?.activate()
|
|
||||||
labelBottomConstraint?.activate()
|
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
layoutIfNeeded()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user