diff --git a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift index dc0f9638..cb3453ef 100644 --- a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift @@ -33,7 +33,7 @@ public struct ActionLabelAttribute: ActionLabelAttributeModel { public var shouldUnderline: Bool public var accessibleText: String? public var action = PassthroughSubject() - + public var subscriber: AnyCancellable? //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -51,7 +51,7 @@ public struct ActionLabelAttribute: ActionLabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { if(shouldUnderline){ - attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single, range: range) + UnderlineLabelAttribute(location: location, length: length).setAttribute(on: attributedString) } } } diff --git a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift index de40e02c..94947472 100644 --- a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift @@ -27,14 +27,14 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { public var location: Int public var length: Int public var textStyle: TextStyle - public var textColor: UIColor + public var textColor: UIColor? public var textPosition: TextPosition public var lineBreakMode: NSLineBreakMode //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor = .black, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { + public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { self.location = location self.length = length self.textStyle = textStyle @@ -45,9 +45,11 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { attributedString.removeAttribute(.font, range: range) - attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttribute(.font, value: textStyle.font, range: range) - attributedString.addAttribute(.foregroundColor, value: textColor, range: range) + if let textColor { + attributedString.removeAttribute(.foregroundColor, range: range) + attributedString.addAttribute(.foregroundColor, value: textColor, range: range) + } setStyleAttributes(attributedString) } diff --git a/VDS/Components/Label/Attributes/ToolTipLabelAttribute.swift b/VDS/Components/Label/Attributes/ToolTipLabelAttribute.swift index 39e6277c..f42ac630 100644 --- a/VDS/Components/Label/Attributes/ToolTipLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ToolTipLabelAttribute.swift @@ -12,7 +12,7 @@ import Combine public struct ToolTipLabelAttribute: ActionLabelAttributeModel { public var id = UUID() public var accessibleText: String? = "Tool Tip" - public var action = PassthroughSubject() + public var action: PassthroughSubject public var location: Int public var length: Int public var tintColor: UIColor @@ -28,6 +28,14 @@ public struct ToolTipLabelAttribute: ActionLabelAttributeModel { } + public init(action: PassthroughSubject = .init(), location: Int, length: Int, tintColor: UIColor = .black, accessibleText: String? = nil){ + self.action = action + self.location = location + self.length = length + self.tintColor = tintColor + self.accessibleText = accessibleText + } + public static func == (lhs: ToolTipLabelAttribute, rhs: ToolTipLabelAttribute) -> Bool { lhs.isEqual(rhs) } diff --git a/VDS/Components/Tilelet/TileletSubTitleModel.swift b/VDS/Components/Tilelet/TileletSubTitleModel.swift index 43ce158c..5c91cdb8 100644 --- a/VDS/Components/Tilelet/TileletSubTitleModel.swift +++ b/VDS/Components/Tilelet/TileletSubTitleModel.swift @@ -49,7 +49,7 @@ extension Tilelet { public func toTitleLockupSubTitleModel() -> TitleLockup.SubTitleModel { TitleLockup.SubTitleModel(text: text, textColor: textColor, - textAttributes: nil) + textAttributes: textAttributes) } } } diff --git a/VDS/Components/Tilelet/TileletTitleModel.swift b/VDS/Components/Tilelet/TileletTitleModel.swift index 7170021d..9802273c 100644 --- a/VDS/Components/Tilelet/TileletTitleModel.swift +++ b/VDS/Components/Tilelet/TileletTitleModel.swift @@ -48,7 +48,7 @@ extension Tilelet { //-------------------------------------------------- public func toTitleLockupTitleModel() -> TitleLockup.TitleModel { TitleLockup.TitleModel(text: text, - textAttributes: nil, + textAttributes: textAttributes, textStyle: textStyle.value) } } diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 1853c1f0..a680ebc0 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -65,10 +65,10 @@ public enum TextStyle: String, CaseIterable { //MARK: FontCategory extension TextStyle { public enum FontCategory: String, CaseIterable { - case feature = "Feature" - case title = "Title" - case body = "Body" - case micro = "micro" + case feature + case title + case body + case micro public var sizes: [FontSize] { switch self { @@ -84,7 +84,13 @@ extension TextStyle { } public func style(for fontSize: FontSize?, isBold: Bool = false) -> TextStyle? { - let styleName = "\(isBold ? "Bold" : "")\(self.rawValue)\(fontSize?.rawValue ?? "")" + var styleName = "" + if isBold { + let newRaw = rawValue.prefix(1).description.uppercased() + rawValue.dropFirst() + styleName = "\(isBold ? "bold" : "")\(newRaw)\(fontSize?.rawValue ?? "")" + } else { + styleName = "\(rawValue)\(fontSize?.rawValue ?? "")" + } guard let style = TextStyle(rawValue: styleName) else { return nil }