updated tab

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-07-13 16:27:41 -05:00
parent 87ecc1e28a
commit a9b39c0fbf

View File

@ -44,7 +44,7 @@ extension Tabs {
open var selected: Bool = false { didSet { setNeedsUpdate() } } open var selected: Bool = false { didSet { setNeedsUpdate() } }
///The text label of the tab. ///The text label of the tab.
open var text: String = "Tab" { didSet { setNeedsUpdate() } } open var text: String = "" { didSet { setNeedsUpdate() } }
///Minimum width for the tab ///Minimum width for the tab
open var minWidth: CGFloat = 44.0 { didSet { setNeedsUpdate() } } open var minWidth: CGFloat = 44.0 { didSet { setNeedsUpdate() } }
@ -52,6 +52,17 @@ extension Tabs {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
private var textStyle: TextStyle {
if size == .medium {
return .boldBodyLarge
} else {
//specs show that the font size shouldn't change however boldTitleSmall does
//change point size between iPad/iPhone. This is a "fix" so each device will
//load the correct pointSize
return UIDevice.isIPad ? .boldTitleSmall : .boldTitleMedium
}
}
private var labelWidthConstraint: NSLayoutConstraint? private var labelWidthConstraint: NSLayoutConstraint?
private var labelLeadingConstraint: NSLayoutConstraint? private var labelLeadingConstraint: NSLayoutConstraint?
private var labelTopConstraint: NSLayoutConstraint? private var labelTopConstraint: NSLayoutConstraint?
@ -148,10 +159,12 @@ extension Tabs {
} }
open override func updateView() { open override func updateView() {
guard !text.isEmpty else { return }
//label properties //label properties
label.text = text label.text = text
label.textStyle = textStyle
label.textPosition = textPosition label.textPosition = textPosition
label.textStyle = size.textStyle
label.textColor = textColorConfiguration.getColor(self) label.textColor = textColorConfiguration.getColor(self)
//constaints //constaints