CXTDT-427328 - Title Lockup text style combinations do not match spec
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
6039836dda
commit
4adb378ce5
@ -29,7 +29,7 @@ open class TitleLockup: View {
|
|||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -43,12 +43,6 @@ open class TitleLockup: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var stackView = UIStackView().with {
|
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
$0.axis = .vertical
|
|
||||||
$0.distribution = .fillProportionally
|
|
||||||
}
|
|
||||||
|
|
||||||
private var otherStandardStyle: OtherStandardStyle {
|
private var otherStandardStyle: OtherStandardStyle {
|
||||||
if let subTitleModel, !subTitleModel.text.isEmpty {
|
if let subTitleModel, !subTitleModel.text.isEmpty {
|
||||||
return subTitleModel.standardStyle
|
return subTitleModel.standardStyle
|
||||||
@ -75,7 +69,7 @@ open class TitleLockup: View {
|
|||||||
open var eyebrowLabel = Label().with {
|
open var eyebrowLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Model used in rendering the eyebrow label.
|
/// Model used in rendering the eyebrow label.
|
||||||
open var eyebrowModel: EyebrowModel? { didSet { setNeedsUpdate() } }
|
open var eyebrowModel: EyebrowModel? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -84,7 +78,7 @@ open class TitleLockup: View {
|
|||||||
open var titleLabel = Label().with {
|
open var titleLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Model used in rendering the title label.
|
/// Model used in rendering the title label.
|
||||||
open var titleModel: TitleModel? { didSet { setNeedsUpdate() } }
|
open var titleModel: TitleModel? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -93,7 +87,7 @@ open class TitleLockup: View {
|
|||||||
open var subTitleLabel = Label().with {
|
open var subTitleLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Model used in rendering the subtitle label.
|
/// Model used in rendering the subtitle label.
|
||||||
open var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() } }
|
open var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -273,22 +267,8 @@ open class TitleLockup: View {
|
|||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
titleLabel.textColorConfiguration = textColorPrimaryConfiguration
|
titleLabel.textColorConfiguration = textColorPrimaryConfiguration
|
||||||
|
|
||||||
accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel]
|
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.
|
/// Resets to default settings.
|
||||||
@ -302,15 +282,18 @@ open class TitleLockup: View {
|
|||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var labelViews = [UIView]()
|
||||||
/// Used to make changes to the View based off a change events or from local properties.
|
/// 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()
|
||||||
|
|
||||||
let allLabelsTextAlignment = textAlignment.value.value
|
//remove all labels
|
||||||
var eyebrowTextIsEmpty = true
|
eyebrowLabel.removeFromSuperview()
|
||||||
var titleTextIsEmpty = true
|
titleLabel.removeFromSuperview()
|
||||||
var subTitleTextIsEmpty = true
|
subTitleLabel.removeFromSuperview()
|
||||||
|
|
||||||
|
//set local vars
|
||||||
|
let allLabelsTextAlignment = textAlignment.value.value
|
||||||
var topSpacing: CGFloat = 0.0
|
var topSpacing: CGFloat = 0.0
|
||||||
var bottomSpacing: CGFloat = 0.0
|
var bottomSpacing: CGFloat = 0.0
|
||||||
|
|
||||||
@ -321,8 +304,12 @@ open class TitleLockup: View {
|
|||||||
bottomSpacing = config.bottomSpacing
|
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 {
|
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
||||||
eyebrowTextIsEmpty = false
|
|
||||||
eyebrowLabel.textAlignment = allLabelsTextAlignment
|
eyebrowLabel.textAlignment = allLabelsTextAlignment
|
||||||
eyebrowLabel.text = eyebrowModel.text
|
eyebrowLabel.text = eyebrowModel.text
|
||||||
eyebrowLabel.attributes = eyebrowModel.textAttributes
|
eyebrowLabel.attributes = eyebrowModel.textAttributes
|
||||||
@ -345,20 +332,35 @@ open class TitleLockup: View {
|
|||||||
eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration
|
eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration
|
||||||
eyebrowLabel.textStyle = eyebrowModel.isBold ? otherStandardStyle.value.bold : otherStandardStyle.value.regular
|
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 {
|
if let titleModel, !titleModel.text.isEmpty {
|
||||||
titleTextIsEmpty = false
|
|
||||||
titleLabel.textAlignment = allLabelsTextAlignment
|
titleLabel.textAlignment = allLabelsTextAlignment
|
||||||
titleLabel.textStyle = titleModel.textStyle
|
titleLabel.textStyle = titleModel.textStyle
|
||||||
titleLabel.text = titleModel.text
|
titleLabel.text = titleModel.text
|
||||||
titleLabel.attributes = titleModel.textAttributes
|
titleLabel.attributes = titleModel.textAttributes
|
||||||
titleLabel.numberOfLines = titleModel.numberOfLines
|
titleLabel.numberOfLines = titleModel.numberOfLines
|
||||||
titleLabel.surface = surface
|
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 {
|
if let subTitleModel, !subTitleModel.text.isEmpty {
|
||||||
subTitleTextIsEmpty = false
|
|
||||||
subTitleLabel.textAlignment = allLabelsTextAlignment
|
subTitleLabel.textAlignment = allLabelsTextAlignment
|
||||||
subTitleLabel.textStyle = otherStandardStyle.value.regular
|
subTitleLabel.textStyle = otherStandardStyle.value.regular
|
||||||
subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration
|
subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration
|
||||||
@ -366,25 +368,23 @@ open class TitleLockup: View {
|
|||||||
subTitleLabel.attributes = subTitleModel.textAttributes
|
subTitleLabel.attributes = subTitleModel.textAttributes
|
||||||
subTitleLabel.numberOfLines = subTitleModel.numberOfLines
|
subTitleLabel.numberOfLines = subTitleModel.numberOfLines
|
||||||
subTitleLabel.surface = surface
|
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
|
//pin the last view to the bottom of this view
|
||||||
if !eyebrowTextIsEmpty && !titleTextIsEmpty {
|
previousView?.pinBottom()
|
||||||
stackView.spacing = topSpacing
|
|
||||||
} else {
|
|
||||||
stackView.spacing = 0.0
|
|
||||||
}
|
|
||||||
|
|
||||||
//if either first 2 rows not empty and subtile not empty, create space else collapse
|
//debugging for borders
|
||||||
if (!eyebrowTextIsEmpty || !titleTextIsEmpty) && !subTitleTextIsEmpty {
|
eyebrowLabel.debugBorder(show: hasDebugBorder, color: .green)
|
||||||
stackView.setCustomSpacing(bottomSpacing, after: titleLabel)
|
titleLabel.debugBorder(show: hasDebugBorder, color: .green)
|
||||||
} else if (!eyebrowTextIsEmpty || !titleTextIsEmpty) && subTitleTextIsEmpty {
|
subTitleLabel .debugBorder(show: hasDebugBorder, color: .green)
|
||||||
stackView.setCustomSpacing(0.0, after: titleLabel)
|
|
||||||
}
|
|
||||||
|
|
||||||
//hide/show
|
|
||||||
eyebrowLabel.isHidden = eyebrowTextIsEmpty
|
|
||||||
titleLabel.isHidden = titleTextIsEmpty
|
|
||||||
subTitleLabel.isHidden = subTitleTextIsEmpty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
1.0.42
|
1.0.42
|
||||||
=======
|
=======
|
||||||
- CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs
|
- CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs
|
||||||
|
- CXTDT-427328 - Title Lockup text style combinations do not match spec
|
||||||
|
|
||||||
1.0.41
|
1.0.41
|
||||||
=======
|
=======
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user