added linebreakMode to paragraph style

made textColorConfiguration a public property and set it

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-09-22 16:59:30 -05:00
parent d99b8ecd2e
commit 5694095aa4

View File

@ -67,14 +67,12 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
//--------------------------------------------------
// MARK: - Configuration Properties
//--------------------------------------------------
private var textColorConfiguration: DisabledSurfaceColorConfiguration<ModelType> = {
return DisabledSurfaceColorConfiguration<ModelType>().with {
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
}
} ()
public var textColorConfiguration = DisabledSurfaceColorConfiguration<ModelType>().with {
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
}
//--------------------------------------------------
// MARK: - Initializers
@ -100,7 +98,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
super.init(coder: coder)
initialSetup()
}
//--------------------------------------------------
// MARK: - Public Functions
//--------------------------------------------------
@ -127,14 +125,14 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
accessibilityTraits = .staticText
numberOfLines = 0
}
//--------------------------------------------------
// MARK: - Overrides
//--------------------------------------------------
open func updateView(viewModel: ModelType) {
textAlignment = viewModel.textPosition.textAlignment
textColor = textColorConfiguration.getColor(viewModel)
if let vdsFont = viewModel.font {
font = vdsFont
} else {
@ -200,6 +198,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
$0.maximumLineHeight = lineHeight
$0.minimumLineHeight = lineHeight
$0.alignment = viewModel.textPosition.textAlignment
$0.lineBreakMode = lineBreakMode
}
attributedString.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange)
attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
@ -207,6 +206,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
} else if viewModel.textPosition != .left {
let paragraph = NSMutableParagraphStyle().with {
$0.alignment = viewModel.textPosition.textAlignment
$0.lineBreakMode = lineBreakMode
}
attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
}