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