From 99340c616e51d386a303291221147c3c9118d06d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 30 Aug 2023 13:38:16 -0500 Subject: [PATCH] refactore first step of TextPosition -> TextAlignment Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 8 ++++---- .../Label/Attributes/TextStyleLabelAttribute.swift | 8 ++++---- VDS/Components/Label/Label.swift | 4 ++-- VDS/Components/Tabs/Tab.swift | 2 +- VDS/Components/Tabs/Tabs.swift | 2 +- VDS/Components/TitleLockup/TitleLockup.swift | 2 +- VDS/Components/Tooltip/TrailingTooltipLabel.swift | 2 +- VDS/Typography/Typography+Additional.swift | 2 +- .../{Typography.swift => Typography+Base.swift} | 0 VDS/Typography/Typography+Enums.swift | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) rename VDS/Typography/{Typography.swift => Typography+Base.swift} (100%) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 28bf12a8..7495635c 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; }; EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; }; EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; }; - EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */; }; + EAB1D2CF28ABEF2B00DAE764 /* Typography+Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography+Base.swift */; }; EAB1D2EA28AE84AA00DAE764 /* UIControlPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2E928AE84AA00DAE764 /* UIControlPublisher.swift */; }; EAB2375D29E8789100AABE9A /* Tooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2375C29E8789100AABE9A /* Tooltip.swift */; }; EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */; }; @@ -240,7 +240,7 @@ EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = ""; }; EAB1D2CC28ABE76000DAE764 /* Withable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Withable.swift; sourceTree = ""; }; - EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typography.swift; sourceTree = ""; }; + EAB1D2CE28ABEF2B00DAE764 /* Typography+Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+Base.swift"; sourceTree = ""; }; EAB1D2E928AE84AA00DAE764 /* UIControlPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIControlPublisher.swift; sourceTree = ""; }; EAB2375C29E8789100AABE9A /* Tooltip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tooltip.swift; sourceTree = ""; }; EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrailingTooltipLabel.swift; sourceTree = ""; }; @@ -663,7 +663,7 @@ EAB1D2D028ABEF3100DAE764 /* Typography */ = { isa = PBXGroup; children = ( - EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */, + EAB1D2CE28ABEF2B00DAE764 /* Typography+Base.swift */, EA0D1C402A6AD61C00E5C127 /* Typography+Additional.swift */, EA0D1C3E2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift */, EA0D1C3C2A6AD57600E5C127 /* Typography+Enums.swift */, @@ -965,7 +965,7 @@ EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */, EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */, EA471F3A2A95587500CE9E58 /* LayoutConstraintable.swift in Sources */, - EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */, + EAB1D2CF28ABEF2B00DAE764 /* Typography+Base.swift in Sources */, EA0D1C3B2A6AD51B00E5C127 /* Typogprahy+Styles.swift in Sources */, EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, EA0D1C3D2A6AD57600E5C127 /* Typography+Enums.swift in Sources */, diff --git a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift index 94947472..ae3ea1e5 100644 --- a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift @@ -28,13 +28,13 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { public var length: Int public var textStyle: TextStyle public var textColor: UIColor? - public var textPosition: TextPosition + public var textPosition: TextAlignment public var lineBreakMode: NSLineBreakMode //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { + public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextAlignment = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { self.location = location self.length = length self.textStyle = textStyle @@ -68,7 +68,7 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { let paragraph = NSMutableParagraphStyle().with { $0.maximumLineHeight = lineHeight $0.minimumLineHeight = lineHeight - $0.alignment = textPosition.textAlignment + $0.alignment = textPosition.value $0.lineBreakMode = lineBreakMode } attributedString.removeAttribute(.baselineOffset, range: range) @@ -78,7 +78,7 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { } else if textPosition != .left { let paragraph = NSMutableParagraphStyle().with { - $0.alignment = textPosition.textAlignment + $0.alignment = textPosition.value $0.lineBreakMode = lineBreakMode } attributedString.removeAttribute(.paragraphStyle, range: range) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 0a95bee6..0a1fa776 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -119,7 +119,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable { open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }} /// The alignment of the text within the label. - open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} + open var textPosition: TextAlignment = .left { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() @@ -201,7 +201,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable { textStyle: textStyle, useScaledFont: useScaledFont, textColor: textColorConfiguration.getColor(self), - alignment: textPosition.textAlignment, + alignment: textPosition.value, lineBreakMode: lineBreakMode) applyAttributes(mutableText) diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index e7c01849..1e1f6d1b 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -69,7 +69,7 @@ extension Tabs { open var size: Tabs.Size = .medium { didSet { setNeedsUpdate() } } ///Text position left or center - open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() } } + open var textPosition: TextAlignment = .left { didSet { setNeedsUpdate() } } ///Sets the Position of the Selected/Hover Border Accent for All Tabs. open var indicatorPosition: Tabs.IndicatorPosition = .bottom { didSet { setNeedsUpdate() } } diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 218ae582..200f0d96 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -154,7 +154,7 @@ open class Tabs: View { orientation == .horizontal && overflow == .scroll } - private var textPosition: TextPosition { + private var textPosition: TextAlignment { orientation == .horizontal && fillContainer ? .center : .left } diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index fc0ae176..358f63ca 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -37,7 +37,7 @@ open class TitleLockup: View { public enum TextPosition: String, EnumSubset { case left, center - public var defaultValue: VDS.TextPosition { .left } + public var defaultValue: VDS.TextAlignment { .left } } //-------------------------------------------------- diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index a53d59cd..6545f9ba 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -50,7 +50,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { open var labelTextStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() } } /// Text position used to render the label. - open var labelTextPosition: TextPosition = .left { didSet { setNeedsUpdate() } } + open var labelTextPosition: TextAlignment = .left { didSet { setNeedsUpdate() } } /// Color configuration set for the label. public lazy var textColorConfiguration: AnyColorable = { diff --git a/VDS/Typography/Typography+Additional.swift b/VDS/Typography/Typography+Additional.swift index 1e998b89..8dc9a1e4 100644 --- a/VDS/Typography/Typography+Additional.swift +++ b/VDS/Typography/Typography+Additional.swift @@ -13,7 +13,7 @@ import VDSTypographyTokens extension TextStyle { /// Alignments Available for the TextStyle - public var aligments: [TextPosition] { + public var aligments: [TextAlignment] { return [.left, .center] } } diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography+Base.swift similarity index 100% rename from VDS/Typography/Typography.swift rename to VDS/Typography/Typography+Base.swift diff --git a/VDS/Typography/Typography+Enums.swift b/VDS/Typography/Typography+Enums.swift index 902cdff1..8c2b03e2 100644 --- a/VDS/Typography/Typography+Enums.swift +++ b/VDS/Typography/Typography+Enums.swift @@ -77,10 +77,10 @@ extension TextStyle { } /// Enum used to describe the alignment of text. -public enum TextPosition: String, CaseIterable { +public enum TextAlignment: String, CaseIterable { case left, right, center - var textAlignment: NSTextAlignment { + var value: NSTextAlignment { switch self { case .left: return NSTextAlignment.left