From f25fd36e783a8f0968a30e1b8e0c83c658ae8d0b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 25 Jan 2023 16:10:09 -0600 Subject: [PATCH 1/7] updated for attributes Signed-off-by: Matt Bruce --- VDS/Components/Tilelet/TileletSubTitleModel.swift | 2 +- VDS/Components/Tilelet/TileletTitleModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) } } From 72f5edb92c936ee47ff9726d733bf92a15c306c8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 25 Jan 2023 18:19:53 -0600 Subject: [PATCH 2/7] fixed bug with underline Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/ActionLabelAttribute.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift index dc0f9638..81f4981f 100644 --- a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift @@ -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) } } } From eacee20fe97d5a2f2733849a696efc089d40ab08 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 25 Jan 2023 18:20:11 -0600 Subject: [PATCH 3/7] added init Signed-off-by: Matt Bruce --- .../Label/Attributes/ToolTipLabelAttribute.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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) } From 5c8ef10eed56a4ccaed41f7da9078f37fa6f7da3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 25 Jan 2023 18:22:10 -0600 Subject: [PATCH 4/7] updated to fix label issue Signed-off-by: Matt Bruce --- VDS/Typography/Typography.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 1853c1f0..70f0601b 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 = "\(newRaw)\(fontSize?.rawValue ?? "")" + } guard let style = TextStyle(rawValue: styleName) else { return nil } From 18e56dcfe7d30f5841ea2fccdbcda85ab4408d2e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 26 Jan 2023 09:29:58 -0600 Subject: [PATCH 5/7] updated var Signed-off-by: Matt Bruce --- VDS/Typography/Typography.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 70f0601b..a680ebc0 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -89,7 +89,7 @@ extension TextStyle { let newRaw = rawValue.prefix(1).description.uppercased() + rawValue.dropFirst() styleName = "\(isBold ? "bold" : "")\(newRaw)\(fontSize?.rawValue ?? "")" } else { - styleName = "\(newRaw)\(fontSize?.rawValue ?? "")" + styleName = "\(rawValue)\(fontSize?.rawValue ?? "")" } guard let style = TextStyle(rawValue: styleName) else { return nil From 9aad50fb0b5b7b929af27008301b97fd7a8865f4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 26 Jan 2023 15:16:56 -0600 Subject: [PATCH 6/7] updated for textcolor Signed-off-by: Matt Bruce --- .../Label/Attributes/TextStyleLabelAttribute.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) } From 2fa47a5404916e0a32ce68c35577f384c67c0b6e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 26 Jan 2023 15:17:14 -0600 Subject: [PATCH 7/7] added cancellable Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/ActionLabelAttribute.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Label/Attributes/ActionLabelAttribute.swift b/VDS/Components/Label/Attributes/ActionLabelAttribute.swift index 81f4981f..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 //--------------------------------------------------