From 7643b86b51cbd3f030e815c8f6a25a62de7e94e8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 5 Oct 2020 18:03:35 -0400 Subject: [PATCH] allow for textColor first. --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 +++- .../Atoms/Views/Label/LabelAttributeUnderlineModel.swift | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index eab432b2..c03d9a84 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -324,7 +324,9 @@ public typealias ActionBlock = () -> () switch attribute { case let underlineAtt as LabelAttributeUnderlineModel: attributedString.addAttribute(.underlineStyle, value: underlineAtt.underlineValue.rawValue, range: range) - attributedString.addAttribute(.underlineColor, value: underlineAtt.color.uiColor, range: range) + if let underlineColor = underlineAtt.color?.uiColor { + attributedString.addAttribute(.underlineColor, value: underlineColor, range: range) + } case _ as LabelAttributeStrikeThroughModel: attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift index 381f4eff..a3adbe00 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift @@ -29,7 +29,7 @@ import UIKit } } - var color: Color = Color(uiColor: .mvmBlack) + var color: Color? var style: UnderlineStyle = .single var pattern: UnderlineStyle.Pattern? @@ -64,7 +64,7 @@ import UIKit public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(color, forKey: .color) + try container.encodeIfPresent(color, forKey: .color) try container.encode(style, forKey: .style) try container.encodeIfPresent(pattern, forKey: .pattern) }