diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index be43c783..4661e23d 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1171,7 +1171,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1208,7 +1208,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 5ba6e04a..2219ae82 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -129,12 +129,18 @@ open class Label: UILabel, ViewProtocol, UserInfoable { /// Line break mode for the label, default is set to word wrapping. open override var lineBreakMode: NSLineBreakMode { didSet { if oldValue != lineBreakMode { setNeedsUpdate() } } } + private var _text: String? + /// Text that will be used in the label. override open var text: String? { - didSet { - useAttributedText = false - attributes = nil - setNeedsUpdate() + get { _text } + set { + if _text != newValue { + _text = newValue + useAttributedText = false + attributes = nil + setNeedsUpdate() + } } } @@ -194,7 +200,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable { open func updateView() { if !useAttributedText { - if let text = text { + if let text { accessibilityCustomActions = [] //create the primary string diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index 3cad1d98..2efac98b 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -68,6 +68,9 @@ extension Tabs { ///Size for tab open var size: Tabs.Size = .medium { didSet { if oldValue != size { setNeedsUpdate() } } } + ///Number of lines in the Label. + open var numberOfLines: Int = 0 { didSet { setNeedsUpdate() } } + ///Text position left or center open var textAlignment: TextAlignment = .left { didSet { if oldValue != textAlignment { setNeedsUpdate() } } } @@ -162,15 +165,14 @@ extension Tabs { labelBottomConstraint?.constant = -otherSpace //label properties + label.textStyle = textStyle label.text = text label.surface = surface - label.textStyle = textStyle label.textAlignment = textAlignment.value label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() setNeedsLayout() layoutIfNeeded() - - } + } /// Used to update any Accessibility properties. open override func updateAccessibility() { diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 51691b10..59b955ad 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -269,7 +269,7 @@ open class Tabs: View { private func updateTabs() { let numberOfLines = applyOverflow ? 1 : 0 for (index, tabItem) in tabViews.enumerated() { - tabItem.label.numberOfLines = numberOfLines + tabItem.numberOfLines = numberOfLines tabItem.size = size tabItem.isSelected = selectedIndex == index tabItem.index = index diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 14f65764..90e0c39e 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -29,7 +29,7 @@ open class TitleLockup: View { public required init?(coder: NSCoder) { super.init(coder: coder) } - + //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -43,12 +43,6 @@ open class TitleLockup: View { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - private var stackView = UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.axis = .vertical - $0.distribution = .fillProportionally - } - private var otherStandardStyle: OtherStandardStyle { if let subTitleModel, !subTitleModel.text.isEmpty { return subTitleModel.standardStyle @@ -75,7 +69,7 @@ open class TitleLockup: View { open var eyebrowLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) } - + /// Model used in rendering the eyebrow label. open var eyebrowModel: EyebrowModel? { didSet { if oldValue != eyebrowModel { setNeedsUpdate() } } } @@ -84,7 +78,7 @@ open class TitleLockup: View { open var titleLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) } - + /// Model used in rendering the title label. open var titleModel: TitleModel? { didSet { if oldValue != titleModel { setNeedsUpdate() } } } @@ -93,7 +87,7 @@ open class TitleLockup: View { open var subTitleLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) } - + /// Model used in rendering the subtitle label. open var subTitleModel: SubTitleModel? { didSet { if oldValue != subTitleModel { setNeedsUpdate() } } } @@ -273,22 +267,8 @@ open class TitleLockup: View { super.setup() titleLabel.textColorConfiguration = textColorPrimaryConfiguration - + accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel] - addSubview(stackView) - - stackView.spacing = 0.0 - - stackView.addArrangedSubview(eyebrowLabel) - stackView.addArrangedSubview(titleLabel) - stackView.addArrangedSubview(subTitleLabel) - - //pin stackview to edges - stackView - .pinTop() - .pinLeading() - .pinTrailing() - .pinBottom(0, .defaultHigh) } /// Resets to default settings. @@ -302,15 +282,18 @@ open class TitleLockup: View { setNeedsUpdate() } + var labelViews = [UIView]() /// Used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() - let allLabelsTextAlignment = textAlignment.value.value - var eyebrowTextIsEmpty = true - var titleTextIsEmpty = true - var subTitleTextIsEmpty = true + //remove all labels + eyebrowLabel.removeFromSuperview() + titleLabel.removeFromSuperview() + subTitleLabel.removeFromSuperview() + //set local vars + let allLabelsTextAlignment = textAlignment.value.value var topSpacing: CGFloat = 0.0 var bottomSpacing: CGFloat = 0.0 @@ -321,8 +304,12 @@ open class TitleLockup: View { bottomSpacing = config.bottomSpacing } + //set a previousView to keep track of the stack + //to deal with anchoring/spacing + var previousView: UIView? + + //see if the eyebrow should exist if let eyebrowModel, !eyebrowModel.text.isEmpty { - eyebrowTextIsEmpty = false eyebrowLabel.textAlignment = allLabelsTextAlignment eyebrowLabel.text = eyebrowModel.text eyebrowLabel.attributes = eyebrowModel.textAttributes @@ -345,20 +332,35 @@ open class TitleLockup: View { eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration eyebrowLabel.textStyle = eyebrowModel.isBold ? otherStandardStyle.value.bold : otherStandardStyle.value.regular } + addSubview(eyebrowLabel) + eyebrowLabel + .pinTop() + .pinLeading() + .pinTrailing() + + previousView = eyebrowLabel } + //see if the title should exist if let titleModel, !titleModel.text.isEmpty { - titleTextIsEmpty = false titleLabel.textAlignment = allLabelsTextAlignment titleLabel.textStyle = titleModel.textStyle titleLabel.text = titleModel.text titleLabel.attributes = titleModel.textAttributes titleLabel.numberOfLines = titleModel.numberOfLines titleLabel.surface = surface + + addSubview(titleLabel) + titleLabel + .pinTop(previousView?.bottomAnchor ?? self.topAnchor, eyebrowLabel == previousView ? topSpacing : 0) + .pinLeading() + .pinTrailing() + + previousView = titleLabel } + //see if the subtitle should exist if let subTitleModel, !subTitleModel.text.isEmpty { - subTitleTextIsEmpty = false subTitleLabel.textAlignment = allLabelsTextAlignment subTitleLabel.textStyle = otherStandardStyle.value.regular subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration @@ -366,25 +368,23 @@ open class TitleLockup: View { subTitleLabel.attributes = subTitleModel.textAttributes subTitleLabel.numberOfLines = subTitleModel.numberOfLines subTitleLabel.surface = surface + + addSubview(subTitleLabel) + subTitleLabel + .pinTop(previousView?.bottomAnchor ?? self.topAnchor, (eyebrowLabel == previousView || titleLabel == previousView) ? bottomSpacing : 0) + .pinLeading() + .pinTrailing() + + previousView = subTitleLabel } - //if both first 2 rows not empty set spacing - if !eyebrowTextIsEmpty && !titleTextIsEmpty { - stackView.spacing = topSpacing - } else { - stackView.spacing = 0.0 - } + //pin the last view to the bottom of this view + previousView?.pinBottom() - //if either first 2 rows not empty and subtile not empty, create space else collapse - if (!eyebrowTextIsEmpty || !titleTextIsEmpty) && !subTitleTextIsEmpty { - stackView.setCustomSpacing(bottomSpacing, after: titleLabel) - } else if (!eyebrowTextIsEmpty || !titleTextIsEmpty) && subTitleTextIsEmpty { - stackView.setCustomSpacing(0.0, after: titleLabel) - } - - //hide/show - eyebrowLabel.isHidden = eyebrowTextIsEmpty - titleLabel.isHidden = titleTextIsEmpty - subTitleLabel.isHidden = subTitleTextIsEmpty + //debugging for borders + eyebrowLabel.debugBorder(show: hasDebugBorder, color: .green) + titleLabel.debugBorder(show: hasDebugBorder, color: .green) + subTitleLabel .debugBorder(show: hasDebugBorder, color: .green) } + } diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 08d647cb..6dae1502 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,7 +1,12 @@ +1.0.42 +======= +- CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs +- CXTDT-427328 - Title Lockup text style combinations do not match spec + 1.0.41 ======= -- CXTDT-457899 - Tabs - Incorrect nonselected color on Dark surface -- ONEAPP-4652 - TextLinkCaret - Caret anouncement removed +- CXTDT-457899 - Tabs - Incorrect non-selected color on Dark surface +- ONEAPP-4652 - TextLinkCaret - Caret announcement removed - Fixed ToggleView Disabled Shadow Color - Fixed several component layout issues - Fixed bug in label for ActionLabelAttribute