titleLockup update for Janet release

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-02 09:27:16 -05:00
parent e3e5ed68fb
commit 19f0744cc1
2 changed files with 85 additions and 9 deletions

View File

@ -46,20 +46,57 @@ open class TitleLockup: View {
$0.distribution = .fill $0.distribution = .fill
} }
///This logic applies when the type style and size used for the title and subtitle/eyebrow is exactly the same (not including the type weight). This should be automatically detected.
private var isUniformSize: Bool {
otherStandardStyle.value == titleModel?.standardStyle.value
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Configuration Properties // MARK: - Configuration Properties
//-------------------------------------------------- //--------------------------------------------------
// Sizes are from InVision design specs. // Sizes are from InVision design specs.
open var standardStyleConfiguration: StandardStyleConfigurationProvider = StandardStyleConfigurationProvider(styleConfigurations: [ open var standardStyleConfiguration: StandardStyleConfigurationProvider = StandardStyleConfigurationProvider(styleConfigurations: [
.init(deviceType: .iPad, .init(deviceType: .iPad,
titleStandardStyles: [.titleSmall, .titleMedium], titleStandardStyles: [.bodySmall],
spacingConfigurations: [ spacingConfigurations: [
.init(otherStandardStyles: [.bodySmall, .bodyMedium, .bodyLarge], .init(otherStandardStyles: [.bodySmall],
topSpacing: VDSLayout.Spacing.space2X.value, topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space2X.value) bottomSpacing: VDSLayout.Spacing.space1X.value)
]), ]),
.init(deviceType: .iPad,
titleStandardStyles: [.bodyMedium],
spacingConfigurations: [
.init(otherStandardStyles: [.bodyMedium],
topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space1X.value)
]),
.init(deviceType: .iPad,
titleStandardStyles: [.bodyLarge],
spacingConfigurations: [
.init(otherStandardStyles: [.bodyLarge],
topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space1X.value)
]),
.init(deviceType: .iPad,
titleStandardStyles: [.titleSmall],
spacingConfigurations: [
.init(otherStandardStyles: [.bodySmall, .bodyMedium, .bodyLarge, .titleSmall],
topSpacing: VDSLayout.Spacing.space2X.value,
bottomSpacing: VDSLayout.Spacing.space2X.value)
]),
.init(deviceType: .iPad,
titleStandardStyles: [.titleMedium],
spacingConfigurations: [
.init(otherStandardStyles: [.bodySmall, .bodyMedium, .bodyLarge],
topSpacing: VDSLayout.Spacing.space2X.value,
bottomSpacing: VDSLayout.Spacing.space2X.value)
]),
.init(deviceType: .iPad, .init(deviceType: .iPad,
titleStandardStyles: [.titleLarge], titleStandardStyles: [.titleLarge],
spacingConfigurations: [ spacingConfigurations: [
@ -100,6 +137,30 @@ open class TitleLockup: View {
bottomSpacing: VDSLayout.Spacing.space6X.value), bottomSpacing: VDSLayout.Spacing.space6X.value),
]), ]),
.init(deviceType: .iPhone,
titleStandardStyles: [.bodySmall],
spacingConfigurations: [
.init(otherStandardStyles: [.bodySmall],
topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space1X.value)
]),
.init(deviceType: .iPhone,
titleStandardStyles: [.bodyMedium],
spacingConfigurations: [
.init(otherStandardStyles: [.bodyMedium],
topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space1X.value)
]),
.init(deviceType: .iPhone,
titleStandardStyles: [.bodyLarge],
spacingConfigurations: [
.init(otherStandardStyles: [.bodyLarge],
topSpacing: VDSLayout.Spacing.space1X.value,
bottomSpacing: VDSLayout.Spacing.space1X.value)
]),
.init(deviceType: .iPhone, .init(deviceType: .iPhone,
titleStandardStyles: [.titleSmall], titleStandardStyles: [.titleSmall],
spacingConfigurations: [ spacingConfigurations: [
@ -153,6 +214,10 @@ open class TitleLockup: View {
]), ]),
]) ])
private var textColorSecondaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight , VDSColor.elementsSecondaryOnlight).eraseToAnyColorable()
private var textColorPrimaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark).eraseToAnyColorable()
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
@ -182,6 +247,8 @@ open class TitleLockup: View {
open override func setup() { open override func setup() {
super.setup() super.setup()
titleLabel.textColorConfiguration = textColorPrimaryConfiguration
accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel] accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel]
addSubview(stackView) addSubview(stackView)
@ -247,6 +314,11 @@ open class TitleLockup: View {
eyebrowLabel.attributes = eyebrowModel.textAttributes eyebrowLabel.attributes = eyebrowModel.textAttributes
eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines
eyebrowLabel.surface = surface eyebrowLabel.surface = surface
if let titleModel, isUniformSize && titleModel.isBold {
eyebrowLabel.textColorConfiguration = textColorSecondaryConfiguration
} else {
eyebrowLabel.textColorConfiguration = textColorPrimaryConfiguration
}
} else { } else {
eyebrowLabel.reset() eyebrowLabel.reset()
} }
@ -267,11 +339,11 @@ open class TitleLockup: View {
subTitleTextIsEmpty = false subTitleTextIsEmpty = false
subTitleLabel.textPosition = allLabelsTextPosition subTitleLabel.textPosition = allLabelsTextPosition
subTitleLabel.textStyle = otherStandardStyle.value.regular subTitleLabel.textStyle = otherStandardStyle.value.regular
subTitleLabel.textColorConfiguration = subTitleModel.textColor == .secondary ? textColorSecondaryConfiguration : textColorPrimaryConfiguration
subTitleLabel.text = subTitleModel.text subTitleLabel.text = subTitleModel.text
subTitleLabel.attributes = subTitleModel.textAttributes subTitleLabel.attributes = subTitleModel.textAttributes
subTitleLabel.numberOfLines = subTitleModel.numberOfLines subTitleLabel.numberOfLines = subTitleModel.numberOfLines
subTitleLabel.surface = surface subTitleLabel.surface = surface
subTitleLabel.disabled = subTitleModel.textColor == .secondary
} else { } else {
subTitleLabel.reset() subTitleLabel.reset()
} }

View File

@ -23,6 +23,10 @@ extension TitleLockup {
case titleMedium case titleMedium
case titleSmall case titleSmall
case bodyLarge
case bodyMedium
case bodySmall
public var defaultValue: TextStyle.StandardStyle {.featureXSmall } public var defaultValue: TextStyle.StandardStyle {.featureXSmall }
public var value: TextStyle.StandardStyle { public var value: TextStyle.StandardStyle {