From 0460e10b89e26732b961c69fc45b46401afcc7ce Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Jul 2023 12:54:03 -0500 Subject: [PATCH 01/20] added edgeInsets Signed-off-by: Matt Bruce --- VDS/Components/Label/Label.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 7cd75b47..5b0b6ffb 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -33,10 +33,12 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }} + open var edgeInsets: UIEdgeInsets { textStyle.edgeInsets } + open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() - + override open var text: String? { didSet { attributes = nil @@ -114,6 +116,13 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { shouldUpdateView = true setNeedsUpdate() } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func drawText(in rect: CGRect) { + super.drawText(in: rect.inset(by: edgeInsets)) + } //-------------------------------------------------- // MARK: - Overrides @@ -134,7 +143,12 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //set the attributed text attributedText = mutableText + + //get accessibility updateAccessibilityLabel() + + //force a drawText + setNeedsDisplay() } } } From e12de0c1082128ae6ee149936c00c93de0b5fccc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Jul 2023 12:55:23 -0500 Subject: [PATCH 02/20] refactor TextStyle for edgeInsets and removed testing vars refactor the string helper to remove these tests Signed-off-by: Matt Bruce --- VDS/Extensions/NSAttributedString.swift | 40 +++++++++---------------- VDS/Typography/Typography.swift | 11 +++---- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index ec36fe67..814f3c98 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -20,40 +20,28 @@ extension NSAttributedString { extension NSMutableAttributedString { public static func mutableText(for text: String, textStyle: TextStyle, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { - let font = textStyle.font - let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] - let attributedString = NSMutableAttributedString(string: text, attributes: startingAttributes) - //get the range - let entireRange = NSRange(location: 0, length: attributedString.length) - - //set letterSpacing - if textStyle.letterSpacing > 0.0 { - attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange) - } - + //create the paragraph for specific properties let paragraph = NSMutableParagraphStyle() paragraph.alignment = alignment paragraph.lineBreakMode = lineBreakMode - - if textStyle.lineSpacing > 0 { - paragraph.lineSpacing = textStyle.lineSpacing - } //set lineHeight if textStyle.lineHeight > 0.0 { - let lineHeight = textStyle.lineHeight -// if textStyle.lineHeight > textStyle.pointSize { - paragraph.maximumLineHeight = lineHeight - paragraph.minimumLineHeight = lineHeight -// paragraph.lineHeightMultiple = lineHeight / textStyle.pointSize -// } else { -// paragraph.lineHeightMultiple = lineHeight / font.pointSize -// } + paragraph.maximumLineHeight = textStyle.lineHeight } - attributedString.addAttribute( .baselineOffset, value: textStyle.baselineOffset, range: entireRange) - attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - return attributedString + //create the attributeArray + var attributes: [NSAttributedString.Key : Any] = [.font: textStyle.font, + .foregroundColor: textColor, + .paragraphStyle: paragraph] + + //set letterSpacing + if textStyle.letterSpacing > 0.0 { + attributes[.kern] = textStyle.letterSpacing + } + + return NSMutableAttributedString(string: text, attributes: attributes) + } } diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 902eb09e..de0a9289 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -29,8 +29,7 @@ public struct TextStyle: Equatable, RawRepresentable { public let lineHeight: CGFloat public let letterSpacing: CGFloat public let fontFace: Font - public let lineSpacing: CGFloat - public let baselineOffset: CGFloat + public let edgeInsets: UIEdgeInsets public init?(rawValue: String) { guard let style = TextStyle.textStyle(for: rawValue) else { return nil } @@ -39,18 +38,16 @@ public struct TextStyle: Equatable, RawRepresentable { self.lineHeight = style.lineHeight self.letterSpacing = style.letterSpacing self.fontFace = style.fontFace - self.lineSpacing = style.lineSpacing - self.baselineOffset = style.baselineOffset + self.edgeInsets = style.edgeInsets } - public init(rawValue: String, fontFace: Font, pointSize: CGFloat = 0.0, lineHeight: CGFloat = 0.0, letterSpacing: CGFloat = 0.0, lineSpacing: CGFloat = 0.0, baselineOffset: CGFloat = 0.0) { + public init(rawValue: String, fontFace: Font, pointSize: CGFloat = 0.0, lineHeight: CGFloat = 0.0, letterSpacing: CGFloat = 0.0, edgeInsets: UIEdgeInsets = .zero) { self.rawValue = rawValue self.fontFace = fontFace self.pointSize = pointSize self.lineHeight = lineHeight self.letterSpacing = letterSpacing - self.lineSpacing = lineSpacing - self.baselineOffset = baselineOffset + self.edgeInsets = edgeInsets } public var isBold: Bool { From a09d77760d22bd080f04305c8e7115d72fe4d3ee Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Jul 2023 13:06:02 -0500 Subject: [PATCH 03/20] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index db7de433..dadd0df1 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1135,7 +1135,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 28; + CURRENT_PROJECT_VERSION = 29; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1172,7 +1172,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 28; + CURRENT_PROJECT_VERSION = 29; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 057162db..663f2ae5 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.29 +======= +- Upated TextStyle and Label for dealing with Top/Bottom insets +- Refactored Code for Checkbox/RadioButton/Toggle + 1.0.28 ======= - CXTDT-423141- Tabs - Incorrect spacing on top-aligned Fill container From 61e843f8f806fca028c176485b09f9a70f3a9614 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 10:43:36 -0500 Subject: [PATCH 04/20] added check for change of scaledFonts Signed-off-by: Matt Bruce --- VDS/Components/Buttons/Button/ButtonBase.swift | 3 +++ VDS/Components/Label/Label.swift | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index c27a4a06..a3bd1941 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -53,6 +53,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open var attributes: [any LabelAttributeModel]? { nil } + open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }} + open var surface: Surface = .light { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() @@ -177,6 +179,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //create the primary string let mutableText = NSMutableAttributedString.mutableText(for: text ?? "No Text", textStyle: textStyle, + useScaledFont: useScaledFont, textColor: textColor, alignment: titleLabel?.textAlignment ?? .center, lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 5b0b6ffb..203e669d 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -27,6 +27,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open var useAttributedText: Bool = false + open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }} + open var surface: Surface = .light { didSet { setNeedsUpdate() }} open var attributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() }} @@ -89,6 +91,13 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- open func initialSetup() { if !initialSetupPerformed { + //register for ContentSizeChanges + NotificationCenter + .Publisher(center: .default, name: UIContentSizeCategory.didChangeNotification) + .sink { [weak self] notification in + self?.setNeedsUpdate() + }.store(in: &subscribers) + backgroundColor = .clear numberOfLines = 0 lineBreakMode = .byWordWrapping @@ -135,6 +144,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //create the primary string let mutableText = NSMutableAttributedString.mutableText(for: text, textStyle: textStyle, + useScaledFont: useScaledFont, textColor: textColorConfiguration.getColor(self), alignment: textPosition.textAlignment, lineBreakMode: lineBreakMode) From 02150f8e8cf6c730f958bbab03001ea098a83eaa Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 10:43:55 -0500 Subject: [PATCH 05/20] added helper for scaledFonts Signed-off-by: Matt Bruce --- VDS/Fonts/FontProtocol.swift | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/VDS/Fonts/FontProtocol.swift b/VDS/Fonts/FontProtocol.swift index 9524f2a4..74ad8701 100644 --- a/VDS/Fonts/FontProtocol.swift +++ b/VDS/Fonts/FontProtocol.swift @@ -39,13 +39,16 @@ extension FontProtocol { throw error!.takeUnretainedValue() } } - - public func font(ofSize size: CGFloat) -> UIFont{ + + public func font(ofSize size: CGFloat, isScaled: Bool = true) -> UIFont{ DispatchQueue.once(block: { self.register() }) - if let font = UIFont(name: self.fontName, size: size){ - return UIFontMetrics.default.scaledFont(for: font) - } else { - return UIFontMetrics.default.scaledFont(for: UIFont.systemFont(ofSize: size)) - } + guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) } + return found + } +} + +extension UIFont { + public var scaledFont: UIFont { + UIFontMetrics.default.scaledFont(for: self) } } From 2d0252311a872c61f8159a8af143d9cdc60edd52 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 10:44:06 -0500 Subject: [PATCH 06/20] updated attributedString Signed-off-by: Matt Bruce --- VDS/Extensions/NSAttributedString.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index 814f3c98..871f6b18 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -19,20 +19,28 @@ extension NSAttributedString { } extension NSMutableAttributedString { - public static func mutableText(for text: String, textStyle: TextStyle, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { + public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { //create the paragraph for specific properties let paragraph = NSMutableParagraphStyle() paragraph.alignment = alignment paragraph.lineBreakMode = lineBreakMode + var defaultFont = textStyle.font + var lineHeight = textStyle.lineHeight + + if useScaledFont { + lineHeight = textStyle.scaledLineHeight + defaultFont = defaultFont.scaledFont + } + //set lineHeight if textStyle.lineHeight > 0.0 { - paragraph.maximumLineHeight = textStyle.lineHeight + paragraph.maximumLineHeight = lineHeight } //create the attributeArray - var attributes: [NSAttributedString.Key : Any] = [.font: textStyle.font, + var attributes: [NSAttributedString.Key : Any] = [.font: defaultFont, .foregroundColor: textColor, .paragraphStyle: paragraph] From dffede13500acb7994b4eba69598f810ad5ee96c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 10:44:24 -0500 Subject: [PATCH 07/20] refactored Typography into new files Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 28 ++ VDS/Extensions/RawRepresentable.swift | 15 + VDS/Extensions/VDSTypography.swift | 14 + VDS/Typography/Typogprahy+Styles.swift | 251 +++++++++++ VDS/Typography/Typography+Additional.swift | 76 ++++ .../Typography+ContentSizeCategory.swift | 30 ++ VDS/Typography/Typography+Enums.swift | 92 ++++ VDS/Typography/Typography+SpacingConfig.swift | 44 ++ VDS/Typography/Typography.swift | 402 +----------------- 9 files changed, 551 insertions(+), 401 deletions(-) create mode 100644 VDS/Extensions/RawRepresentable.swift create mode 100644 VDS/Extensions/VDSTypography.swift create mode 100644 VDS/Typography/Typogprahy+Styles.swift create mode 100644 VDS/Typography/Typography+Additional.swift create mode 100644 VDS/Typography/Typography+ContentSizeCategory.swift create mode 100644 VDS/Typography/Typography+Enums.swift create mode 100644 VDS/Typography/Typography+SpacingConfig.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index dadd0df1..491b4bda 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -13,6 +13,13 @@ 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */; }; 5FC35BE328D51405004EBEAC /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE228D51405004EBEAC /* Button.swift */; }; EA0D1C372A681CCE00E5C127 /* ToggleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C362A681CCE00E5C127 /* ToggleView.swift */; }; + EA0D1C392A6AD4DF00E5C127 /* Typography+SpacingConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C382A6AD4DF00E5C127 /* Typography+SpacingConfig.swift */; }; + EA0D1C3B2A6AD51B00E5C127 /* Typogprahy+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C3A2A6AD51B00E5C127 /* Typogprahy+Styles.swift */; }; + EA0D1C3D2A6AD57600E5C127 /* Typography+Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C3C2A6AD57600E5C127 /* Typography+Enums.swift */; }; + EA0D1C3F2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C3E2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift */; }; + EA0D1C412A6AD61C00E5C127 /* Typography+Additional.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C402A6AD61C00E5C127 /* Typography+Additional.swift */; }; + EA0D1C432A6AD70900E5C127 /* VDSTypography.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C422A6AD70900E5C127 /* VDSTypography.swift */; }; + EA0D1C452A6AD73000E5C127 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C442A6AD73000E5C127 /* RawRepresentable.swift */; }; EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */; }; EA1DA1CB2A2E36DC001C51D2 /* SelectorBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1DA1CA2A2E36DC001C51D2 /* SelectorBase.swift */; }; EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266128B945070033E859 /* RadioSwatch.swift */; }; @@ -150,6 +157,13 @@ 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; EA0D1C362A681CCE00E5C127 /* ToggleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleView.swift; sourceTree = ""; }; + EA0D1C382A6AD4DF00E5C127 /* Typography+SpacingConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+SpacingConfig.swift"; sourceTree = ""; }; + EA0D1C3A2A6AD51B00E5C127 /* Typogprahy+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typogprahy+Styles.swift"; sourceTree = ""; }; + EA0D1C3C2A6AD57600E5C127 /* Typography+Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+Enums.swift"; sourceTree = ""; }; + EA0D1C3E2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+ContentSizeCategory.swift"; sourceTree = ""; }; + EA0D1C402A6AD61C00E5C127 /* Typography+Additional.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Typography+Additional.swift"; sourceTree = ""; }; + EA0D1C422A6AD70900E5C127 /* VDSTypography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSTypography.swift; sourceTree = ""; }; + EA0D1C442A6AD73000E5C127 /* RawRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawRepresentable.swift; sourceTree = ""; }; EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroup.swift; sourceTree = ""; }; EA1DA1CA2A2E36DC001C51D2 /* SelectorBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorBase.swift; sourceTree = ""; }; EA1F266128B945070033E859 /* RadioSwatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; @@ -446,6 +460,7 @@ EAF7F0992899B17200B287F5 /* CATransaction.swift */, EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */, EABFEB632A26473700C4C106 /* NSAttributedString.swift */, + EA0D1C442A6AD73000E5C127 /* RawRepresentable.swift */, EAB2376529E9952D00AABE9A /* UIApplication.swift */, EA3361A7288B23300071C351 /* UIColor.swift */, EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */, @@ -455,6 +470,7 @@ EAD062A62A3B67770015965D /* UIView+CALayer.swift */, EAB5FF0029424ACB00998C17 /* UIControl.swift */, EA985C662970C21600F2FF2E /* VDSLayout.swift */, + EA0D1C422A6AD70900E5C127 /* VDSTypography.swift */, ); path = Extensions; sourceTree = ""; @@ -638,6 +654,11 @@ isa = PBXGroup; children = ( EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */, + EA0D1C402A6AD61C00E5C127 /* Typography+Additional.swift */, + EA0D1C3E2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift */, + EA0D1C3C2A6AD57600E5C127 /* Typography+Enums.swift */, + EA0D1C382A6AD4DF00E5C127 /* Typography+SpacingConfig.swift */, + EA0D1C3A2A6AD51B00E5C127 /* Typogprahy+Styles.swift */, ); path = Typography; sourceTree = ""; @@ -881,7 +902,9 @@ EAF7F0A6289B0CE000B287F5 /* Resetable.swift in Sources */, EA985C2D296F03FE00F2FF2E /* TileletIconModels.swift in Sources */, EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */, + EA0D1C3F2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift in Sources */, EA5F86C82A1BD99100BC83E4 /* TabModel.swift in Sources */, + EA0D1C432A6AD70900E5C127 /* VDSTypography.swift in Sources */, EA297A5729FB0A360031ED56 /* AppleGuidlinesTouchable.swift in Sources */, EA3361C328902D960071C351 /* Toggle.swift in Sources */, EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */, @@ -891,6 +914,7 @@ EAB2376229E9880400AABE9A /* TrailingTooltipLabel.swift in Sources */, EAB2376A29E9E59100AABE9A /* TooltipLaunchable.swift in Sources */, EAB2375D29E8789100AABE9A /* Tooltip.swift in Sources */, + EA0D1C452A6AD73000E5C127 /* RawRepresentable.swift in Sources */, EA985C23296E033A00F2FF2E /* TextArea.swift in Sources */, EAF7F0B3289B1ADC00B287F5 /* ActionLabelAttribute.swift in Sources */, EAC925832911B35400091998 /* TextLinkCaret.swift in Sources */, @@ -900,6 +924,7 @@ EA985BF7296C665E00F2FF2E /* IconName.swift in Sources */, EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */, EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */, + EA0D1C412A6AD61C00E5C127 /* Typography+Additional.swift in Sources */, EAC925842911C63100091998 /* Colorable.swift in Sources */, EAB5FEF5292D371F00998C17 /* ButtonBase.swift in Sources */, EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */, @@ -935,7 +960,9 @@ EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */, EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */, EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */, + EA0D1C3B2A6AD51B00E5C127 /* Typogprahy+Styles.swift in Sources */, EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, + EA0D1C3D2A6AD57600E5C127 /* Typography+Enums.swift in Sources */, EAF1FE9B29DB1A6000101452 /* Changeable.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, EA985C7D297DAED300F2FF2E /* Primitive.swift in Sources */, @@ -966,6 +993,7 @@ EA3361B6288B2A410071C351 /* Control.swift in Sources */, 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */, EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */, + EA0D1C392A6AD4DF00E5C127 /* Typography+SpacingConfig.swift in Sources */, EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */, EAB5FED429267EB300998C17 /* UIView.swift in Sources */, EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */, diff --git a/VDS/Extensions/RawRepresentable.swift b/VDS/Extensions/RawRepresentable.swift new file mode 100644 index 00000000..7b1f0bca --- /dev/null +++ b/VDS/Extensions/RawRepresentable.swift @@ -0,0 +1,15 @@ +// +// RawRepresentable.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation + +/// Helper method to check to see if you exist in a collection +extension RawRepresentable where Self.RawValue: Equatable { + public func isWithin(_ collection: [Self]) -> Bool { + (collection.first(where: {$0 == self}) != nil) + } +} diff --git a/VDS/Extensions/VDSTypography.swift b/VDS/Extensions/VDSTypography.swift new file mode 100644 index 00000000..f8e29c44 --- /dev/null +++ b/VDS/Extensions/VDSTypography.swift @@ -0,0 +1,14 @@ +// +// VDSTypography.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import VDSTypographyTokens + +extension VDSTypography { + public static let letterSpacingSemiWide: CGFloat = 0.25 +} + diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift new file mode 100644 index 00000000..3894b3f7 --- /dev/null +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -0,0 +1,251 @@ +// +// Typogprahy+Styles.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import VDSTypographyTokens + +//MARK: Definitions +extension TextStyle { + + // Static properties for different text styles + public static let featureXLarge = TextStyle(rawValue: "featureXLarge", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, + letterSpacing: 0) + + public static let featureLarge = TextStyle(rawValue: "featureLarge", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, + letterSpacing: 0) + + public static let featureMedium = TextStyle(rawValue: "featureMedium", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, + letterSpacing: 0) + + public static let featureSmall = TextStyle(rawValue: "featureSmall", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, + letterSpacing: 0) + + public static let featureXSmall = TextStyle(rawValue: "featureXSmall", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, + letterSpacing: 0) + + public static let title2XLarge = TextStyle(rawValue: "title2XLarge", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, + letterSpacing: 0) + + public static let titleXLarge = TextStyle(rawValue: "titleXLarge", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, + letterSpacing: 0) + + public static let titleLarge = TextStyle(rawValue: "titleLarge", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, + letterSpacing: VDSTypography.letterSpacingSemiWide) + + public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, + letterSpacing: 0) + + public static let titleMedium = TextStyle(rawValue: "titleMedium", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, + letterSpacing: 0) + + public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, + letterSpacing: 0) + + public static let titleSmall = TextStyle(rawValue: "titleSmall", + fontFace: .dsLight, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, + letterSpacing: 0) + + public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall", + fontFace: .dsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, + letterSpacing: 0) + + public static let bodyLarge = TextStyle(rawValue: "bodyLarge", + fontFace: .dsRegular, + pointSize: VDSTypography.fontSizeBody16, + lineHeight: VDSTypography.lineHeightBody20, + letterSpacing:VDSTypography.letterSpacingWide) + + public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge", + fontFace: .dsBold, + pointSize: VDSTypography.fontSizeBody16, + lineHeight: VDSTypography.lineHeightBody20, + letterSpacing: VDSTypography.letterSpacingWide) + + public static let bodyMedium = TextStyle(rawValue: "bodyMedium", + fontFace: .dsRegular, + pointSize: VDSTypography.fontSizeBody14, + lineHeight: VDSTypography.lineHeightBody18, + letterSpacing: VDSTypography.letterSpacingWide) + + public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium", + fontFace: .dsBold, + pointSize: VDSTypography.fontSizeBody14, + lineHeight: VDSTypography.lineHeightBody18, + letterSpacing: VDSTypography.letterSpacingWide) + + public static let bodySmall = TextStyle(rawValue: "bodySmall", + fontFace: .dsRegular, + pointSize: VDSTypography.fontSizeBody12, + lineHeight: VDSTypography.lineHeightBody16, + letterSpacing: 0) + + public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall", + fontFace: .dsBold, + pointSize: VDSTypography.fontSizeBody12, + lineHeight: VDSTypography.lineHeightBody16, + letterSpacing: 0) + + public static let micro = TextStyle(rawValue: "micro", + fontFace: .dsRegular, + pointSize: VDSTypography.fontSizeMicro11, + lineHeight: VDSTypography.lineHeightMicro16, + letterSpacing: 0) + + public static let boldMicro = TextStyle(rawValue: "boldMicro", + fontFace: .dsBold, + pointSize: VDSTypography.fontSizeMicro11, + lineHeight: VDSTypography.lineHeightMicro16, + letterSpacing: 0) + + public static var allCases: [TextStyle] { + return [ + featureXLarge, + boldFeatureXLarge, + featureLarge, + boldFeatureLarge, + featureMedium, + boldFeatureMedium, + featureSmall, + boldFeatureSmall, + featureXSmall, + boldFeatureXSmall, + title2XLarge, + boldTitle2XLarge, + titleXLarge, + boldTitleXLarge, + titleLarge, + boldTitleLarge, + titleMedium, + boldTitleMedium, + titleSmall, + boldTitleSmall, + bodyLarge, + boldBodyLarge, + bodyMedium, + boldBodyMedium, + bodySmall, + boldBodySmall, + micro, + boldMicro + ] + } +} + +extension TextStyle { + public enum StandardStyle: String, CaseIterable { + case featureXLarge, + featureLarge, + featureMedium, + featureSmall, + featureXSmall, + title2XLarge, + titleXLarge, + titleLarge, + titleMedium, + titleSmall, + bodyLarge, + bodyMedium, + bodySmall, + micro + + public var bold: TextStyle { + return TextStyle(rawValue: "bold\(rawValue.prefix(1).uppercased())\(rawValue.dropFirst())")! + } + + public var regular: TextStyle { + TextStyle(rawValue: rawValue)! + } + } + + public func toStandardStyle() -> StandardStyle { + var rawName = rawValue + if rawName.hasPrefix("bold") { + let updatedRaw = rawName.replacingOccurrences(of: "bold", with: "") + rawName = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst() + } + return StandardStyle(rawValue: rawName)! + } +} diff --git a/VDS/Typography/Typography+Additional.swift b/VDS/Typography/Typography+Additional.swift new file mode 100644 index 00000000..1e998b89 --- /dev/null +++ b/VDS/Typography/Typography+Additional.swift @@ -0,0 +1,76 @@ +// +// Typography+Additional.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import UIKit +import VDSTypographyTokens + +//MARK: Alignments +extension TextStyle { + + /// Alignments Available for the TextStyle + public var aligments: [TextPosition] { + return [.left, .center] + } +} + +//MARK: Fonts +extension TextStyle { + + /// Font for the TextStyle. + public var font: UIFont { + return fontFace.font(ofSize: pointSize) + } +} + +//MARK: Style Helper +extension TextStyle { + + /// Default style used if no style is given. + public static var defaultStyle: TextStyle { return bodyLarge } + + + /// Find a TextStyle based off a Name. + /// - Parameter name: Name of the TextStyle you want to find. + /// - Returns: TextStyle for the given name. + public static func textStyle(for name: String) -> TextStyle? { + guard let style = TextStyle.allCases.first(where: {$0.rawValue == name }) else { return nil } + return style + } + + /// Returns a TextStyle based off a Font-Name and Size + /// - Parameters: + /// - fontName: Name of the font you want to find. + /// - size: PointSize of the Font you want to find. + /// - Returns: The exact TextStyle based on the FontName and Point Size. + public static func style(for fontName: String, size: CGFloat) -> TextStyle? { + //filter all styles by fontName + let styles = allCases.filter{$0.fontFace.fontName == fontName }.sorted { lhs, rhs in lhs.pointSize < rhs.pointSize } + + //if there are no styles then return nil + guard styles.count > 0 else { return nil } + + //if there is an exact match on a style with this pointSize then return it + if let style = styles.first(where: {$0.pointSize == size }) { + return style + + } else if let largerIndex = styles.firstIndex(where: { $0.pointSize > size}) { //find the closet one to pointSize + return styles[max(largerIndex - 1, 0)] + + } else { //return the last style + return styles.last! + } + } +} + +extension TextStyle: CustomDebugStringConvertible { + + /// Used for showing the TextStyle Properties. + public var debugDescription: String { + "Name: \(self.rawValue) FontFace: \(font.fontName) FontWeight: \(self.rawValue.hasPrefix("bold") ? "bold" : "normal") PointSize: \(font.pointSize) LetterSpacing: \(letterSpacing) LineHeight: \(lineHeight)" + } +} diff --git a/VDS/Typography/Typography+ContentSizeCategory.swift b/VDS/Typography/Typography+ContentSizeCategory.swift new file mode 100644 index 00000000..a28b0c48 --- /dev/null +++ b/VDS/Typography/Typography+ContentSizeCategory.swift @@ -0,0 +1,30 @@ +// +// Typography+ContentSizeCategory.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import UIKit + +extension TextStyle { + /// Determines if the Framework can use scaled fonts for preferredContentSizeCategory + public static var allowScaledFonts: Bool = true + + /// Determines is the User has changed their default preferredContentSizeCategory + public static var canScaleFonts: Bool { + UIApplication.shared.preferredContentSizeCategory != .large && allowScaledFonts + } + + /// The scaled version of the hardcode value 'lineHeight' within a TextStyle. This will only be different + /// from the original if the preferredContentSizeCategory has changed. + public var scaledLineHeight: CGFloat { + let defaultFont = font + let scaledFont = defaultFont.scaledFont + let ratio = scaledFont.pointSize / defaultFont.pointSize + let newLineHeight = (lineHeight * ratio).rounded() + return newLineHeight + } +} + diff --git a/VDS/Typography/Typography+Enums.swift b/VDS/Typography/Typography+Enums.swift new file mode 100644 index 00000000..104515f7 --- /dev/null +++ b/VDS/Typography/Typography+Enums.swift @@ -0,0 +1,92 @@ +// +// Typography+Enums.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import UIKit + +//MARK: FontCategory +extension TextStyle { + + /// Used in the Sample App but could be used elsewhere to allow selection of TextStyles + public enum FontCategory: String, CaseIterable { + case feature + case title + case body + case micro + + public var sizes: [FontSize] { + switch self { + case .feature: + return [.xlarge, .large, .medium, .small, .xsmall] + case .title: + return [.xxlarge, .xlarge, .large, .medium, .small] + case .body: + return [.large, .medium, .small] + case .micro: + return [] + } + } + + /// Find the TextStyle for the FontSize. + /// - Parameters: + /// - fontSize: FontSize you are looking for using this FontCategory. + /// - isBold: Whether or not the Font is bold. + /// - Returns: A TextStyle will be returned if all criteria is met, otherwise nil will be returned. + public func style(for fontSize: FontSize?, isBold: Bool = false) -> TextStyle? { + 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.textStyle(for: styleName) else { + return nil + } + return style + } + } + + /// Find the TextStyle for the specific FontCategory and FontSize. + /// - Parameters: + /// - category: FontCategory you are looking for in the TextStyle + /// - fontSize: FontSize you are looking for using the given FontCategory. + /// - isBold: Whether or not the Font is bold. + /// - Returns: A TextStyle will be returned if all criteria is met, otherwise nil will be returned. + public func style(for category: FontCategory, with size: FontSize, isBold: Bool) -> TextStyle? { + category.style(for: size, isBold: isBold) + } +} + +//MARK: FontSize +extension TextStyle { + public enum FontSize: String, CaseIterable { + case xxlarge = "2XLarge" + case xlarge = "XLarge" + case large = "Large" + case medium = "Medium" + case small = "Small" + case xsmall = "XSmall" + } +} + + +public enum TextPosition: String, CaseIterable { + case left, right, center + + var textAlignment: NSTextAlignment { + switch self { + case .left: + return NSTextAlignment.left + case .right: + return NSTextAlignment.right + case .center: + return NSTextAlignment.center + } + } +} diff --git a/VDS/Typography/Typography+SpacingConfig.swift b/VDS/Typography/Typography+SpacingConfig.swift new file mode 100644 index 00000000..84b61e20 --- /dev/null +++ b/VDS/Typography/Typography+SpacingConfig.swift @@ -0,0 +1,44 @@ +// +// Typography+Spacing.swift +// VDS +// +// Created by Matt Bruce on 7/21/23. +// + +import Foundation +import UIKit + +extension TextStyle { + public struct SpacingConfig { + public var defaultSpacing: CGFloat = 8.0 + public var configs: [TextStyle.DeviceSpacingConfig] + + public func spacing(for style: TextStyle, neighboring: TextStyle) -> CGFloat { + let deviceType: TextStyle.DeviceSpacingConfig.DeviceType = UIDevice.isIPad ? .iPad : .iPhone + if let config = configs.first(where: + { style.isWithin($0.primaryStyles) && neighboring.isWithin($0.neighboringStyles) && + ($0.deviceType == deviceType || $0.deviceType == .all )}) + { + return config.spacing + } + return defaultSpacing + } + } + + public struct DeviceSpacingConfig { + public enum DeviceType { + case iPhone, iPad, all + } + public var spacing: CGFloat + public var deviceType: DeviceType = .iPhone + public var primaryStyles: [TextStyle] + public var neighboringStyles: [TextStyle] + + public init(_ primaryStyles: [TextStyle], neighboring: [TextStyle], spacing: CGFloat, deviceType: DeviceType = .iPhone) { + self.spacing = spacing + self.primaryStyles = primaryStyles + self.neighboringStyles = neighboring + self.deviceType = deviceType + } + } +} diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index de0a9289..00cf598d 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -8,21 +8,8 @@ import Foundation import VDSTypographyTokens -public enum TextPosition: String, CaseIterable { - case left, right, center - - var textAlignment: NSTextAlignment { - switch self { - case .left: - return NSTextAlignment.left - case .right: - return NSTextAlignment.right - case .center: - return NSTextAlignment.center - } - } -} +/// This is the Definition that will determine how the Text is drawn public struct TextStyle: Equatable, RawRepresentable { public let rawValue: String public let pointSize: CGFloat @@ -54,390 +41,3 @@ public struct TextStyle: Equatable, RawRepresentable { rawValue.hasPrefix("bold") } } - -extension VDSTypography { - public static let letterSpacingSemiWide: CGFloat = 0.25 -} -//MARK: Definitions -extension TextStyle { - - // Static properties for different text styles - public static let featureXLarge = TextStyle(rawValue: "featureXLarge", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: 0) - - public static let featureLarge = TextStyle(rawValue: "featureLarge", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - letterSpacing: 0) - - public static let featureMedium = TextStyle(rawValue: "featureMedium", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - letterSpacing: 0) - - public static let featureSmall = TextStyle(rawValue: "featureSmall", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - letterSpacing: 0) - - public static let featureXSmall = TextStyle(rawValue: "featureXSmall", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - letterSpacing: 0) - - public static let title2XLarge = TextStyle(rawValue: "title2XLarge", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - letterSpacing: 0) - - public static let titleXLarge = TextStyle(rawValue: "titleXLarge", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, - letterSpacing: 0) - - public static let titleLarge = TextStyle(rawValue: "titleLarge", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, - letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, - letterSpacing: 0) - - public static let titleMedium = TextStyle(rawValue: "titleMedium", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, - letterSpacing: 0) - - public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, - letterSpacing: 0) - - public static let titleSmall = TextStyle(rawValue: "titleSmall", - fontFace: .dsLight, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, - letterSpacing: 0) - - public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, - letterSpacing: 0) - - public static let bodyLarge = TextStyle(rawValue: "bodyLarge", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeBody16, - lineHeight: VDSTypography.lineHeightBody20, - letterSpacing:VDSTypography.letterSpacingWide) - - public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge", - fontFace: .dsBold, - pointSize: VDSTypography.fontSizeBody16, - lineHeight: VDSTypography.lineHeightBody20, - letterSpacing: VDSTypography.letterSpacingWide) - - public static let bodyMedium = TextStyle(rawValue: "bodyMedium", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeBody14, - lineHeight: VDSTypography.lineHeightBody18, - letterSpacing: VDSTypography.letterSpacingWide) - - public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium", - fontFace: .dsBold, - pointSize: VDSTypography.fontSizeBody14, - lineHeight: VDSTypography.lineHeightBody18, - letterSpacing: VDSTypography.letterSpacingWide) - - public static let bodySmall = TextStyle(rawValue: "bodySmall", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeBody12, - lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0) - - public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall", - fontFace: .dsBold, - pointSize: VDSTypography.fontSizeBody12, - lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0) - - public static let micro = TextStyle(rawValue: "micro", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeMicro11, - lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0) - - public static let boldMicro = TextStyle(rawValue: "boldMicro", - fontFace: .dsBold, - pointSize: VDSTypography.fontSizeMicro11, - lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0) - - public static var allCases: [TextStyle] { - return [ - featureXLarge, - boldFeatureXLarge, - featureLarge, - boldFeatureLarge, - featureMedium, - boldFeatureMedium, - featureSmall, - boldFeatureSmall, - featureXSmall, - boldFeatureXSmall, - title2XLarge, - boldTitle2XLarge, - titleXLarge, - boldTitleXLarge, - titleLarge, - boldTitleLarge, - titleMedium, - boldTitleMedium, - titleSmall, - boldTitleSmall, - bodyLarge, - boldBodyLarge, - bodyMedium, - boldBodyMedium, - bodySmall, - boldBodySmall, - micro, - boldMicro - ] - } -} - -extension TextStyle { - public enum StandardStyle: String, CaseIterable { - case featureXLarge, - featureLarge, - featureMedium, - featureSmall, - featureXSmall, - title2XLarge, - titleXLarge, - titleLarge, - titleMedium, - titleSmall, - bodyLarge, - bodyMedium, - bodySmall, - micro - - public var bold: TextStyle { - return TextStyle(rawValue: "bold\(rawValue.prefix(1).uppercased())\(rawValue.dropFirst())")! - } - - public var regular: TextStyle { - TextStyle(rawValue: rawValue)! - } - } - - public func toStandardStyle() -> StandardStyle { - var rawName = rawValue - if rawName.hasPrefix("bold") { - let updatedRaw = rawName.replacingOccurrences(of: "bold", with: "") - rawName = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst() - } - return StandardStyle(rawValue: rawName)! - } -} - -//MARK: FontCategory -extension TextStyle { - public enum FontCategory: String, CaseIterable { - case feature - case title - case body - case micro - - public var sizes: [FontSize] { - switch self { - case .feature: - return [.xlarge, .large, .medium, .small, .xsmall] - case .title: - return [.xxlarge, .xlarge, .large, .medium, .small] - case .body: - return [.large, .medium, .small] - case .micro: - return [] - } - } - - public func style(for fontSize: FontSize?, isBold: Bool = false) -> TextStyle? { - 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.textStyle(for: styleName) else { - return nil - } - return style - } - } -} - -//MARK: FontSize -extension TextStyle { - public enum FontSize: String, CaseIterable { - case xxlarge = "2XLarge" - case xlarge = "XLarge" - case large = "Large" - case medium = "Medium" - case small = "Small" - case xsmall = "XSmall" - } -} - -//MARK: Alignments -extension TextStyle { - public var aligments: [TextPosition] { - return [.left, .center] - } -} - -//MARK: Fonts -extension TextStyle { - public var font: UIFont { - return fontFace.font(ofSize: pointSize) - } -} - -extension TextStyle { - public static func style(for fontName: String, size: CGFloat) -> TextStyle? { - //filter all styles by fontName - let styles = allCases.filter{$0.fontFace.fontName == fontName }.sorted { lhs, rhs in lhs.pointSize < rhs.pointSize } - - //if there are no styles then return nil - guard styles.count > 0 else { return nil } - - //if there is an exact match on a style with this pointSize then return it - if let style = styles.first(where: {$0.pointSize == size }) { - return style - - } else if let largerIndex = styles.firstIndex(where: { $0.pointSize > size}) { //find the closet one to pointSize - return styles[max(largerIndex - 1, 0)] - - } else { //return the last style - return styles.last! - } - } -} - -extension RawRepresentable where Self.RawValue: Equatable { - public func isWithin(_ collection: [Self]) -> Bool { - (collection.first(where: {$0 == self}) != nil) - } -} - -extension TextStyle { - public struct SpacingConfig { - public var defaultSpacing: CGFloat = 8.0 - public var configs: [TextStyle.DeviceSpacingConfig] - - public func spacing(for style: TextStyle, neighboring: TextStyle) -> CGFloat { - let deviceType: TextStyle.DeviceSpacingConfig.DeviceType = UIDevice.isIPad ? .iPad : .iPhone - if let config = configs.first(where: - { style.isWithin($0.primaryStyles) && neighboring.isWithin($0.neighboringStyles) && - ($0.deviceType == deviceType || $0.deviceType == .all )}) - { - return config.spacing - } - return defaultSpacing - } - } - - public struct DeviceSpacingConfig { - public enum DeviceType { - case iPhone, iPad, all - } - public var spacing: CGFloat - public var deviceType: DeviceType = .iPhone - public var primaryStyles: [TextStyle] - public var neighboringStyles: [TextStyle] - - public init(_ primaryStyles: [TextStyle], neighboring: [TextStyle], spacing: CGFloat, deviceType: DeviceType = .iPhone) { - self.spacing = spacing - self.primaryStyles = primaryStyles - self.neighboringStyles = neighboring - self.deviceType = deviceType - } - } - -} - -extension TextStyle: CustomDebugStringConvertible { - public var debugDescription: String { - "Name: \(self.rawValue) FontFace: \(font.fontName) FontWeight: \(self.rawValue.hasPrefix("bold") ? "bold" : "normal") PointSize: \(font.pointSize) LetterSpacing: \(letterSpacing) LineHeight: \(lineHeight)" - } -} - -extension TextStyle { - public static var defaultStyle: TextStyle { return bodyLarge } - - public static func textStyle(for name: String) -> TextStyle? { - guard let style = TextStyle.allCases.first(where: {$0.rawValue == name }) else { return nil } - return style - } -} From 55641beccf3b5036c3ea0d76bed5c19f652262e7 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 16:08:37 -0500 Subject: [PATCH 08/20] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/Publishers/UITextField+Publisher.swift | 9 +++++++++ VDS/SupportingFiles/ReleaseNotes.txt | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 491b4bda..b2add536 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 29; + CURRENT_PROJECT_VERSION = 30; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 29; + CURRENT_PROJECT_VERSION = 30; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Publishers/UITextField+Publisher.swift b/VDS/Publishers/UITextField+Publisher.swift index 2e2a4ebc..4cc582d4 100644 --- a/VDS/Publishers/UITextField+Publisher.swift +++ b/VDS/Publishers/UITextField+Publisher.swift @@ -15,4 +15,13 @@ extension UITextField { .map { _ in self.text ?? "" } .eraseToAnyPublisher() } + + public var numberPublisher: AnyPublisher { + publisher(for: .editingChanged) + .map { textField in + guard let text = textField.text, let foundNumber = NumberFormatter().number(from: text) else { return nil } + return foundNumber + } + .eraseToAnyPublisher() + } } diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 663f2ae5..e457386d 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.30 +======= +- Upated Label to allow Scaled Fonts +- Refactored Code TextStyle + 1.0.29 ======= - Upated TextStyle and Label for dealing with Top/Bottom insets From b9082ac1d28b9e12eb69469368d7b86e686206b9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 16:55:20 -0500 Subject: [PATCH 09/20] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index b2add536..77fc4990 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index e457386d..0401f37d 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,4 +1,4 @@ -1.0.30 +1.0.31 ======= - Upated Label to allow Scaled Fonts - Refactored Code TextStyle From d00b1d0a0ec35b3f62d9c225c0ab6bac52756879 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 22 Jul 2023 09:17:42 -0500 Subject: [PATCH 10/20] updated makeAttributedString to use min lineHeight as well as read a var to help determine if this is really needed or not Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/Extensions/NSAttributedString.swift | 10 +++++++++- VDS/SupportingFiles/ReleaseNotes.txt | 13 +++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 77fc4990..e320cb6c 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index 871f6b18..49f39f45 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -19,8 +19,13 @@ extension NSAttributedString { } extension NSMutableAttributedString { + + public static var useMinimumLineHeight: Bool = true public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { + //var for if you can scale or not + let scaledMode = useScaledFont && TextStyle.canScaleFonts + //create the paragraph for specific properties let paragraph = NSMutableParagraphStyle() paragraph.alignment = alignment @@ -29,13 +34,16 @@ extension NSMutableAttributedString { var defaultFont = textStyle.font var lineHeight = textStyle.lineHeight - if useScaledFont { + if scaledMode { lineHeight = textStyle.scaledLineHeight defaultFont = defaultFont.scaledFont } //set lineHeight if textStyle.lineHeight > 0.0 { + if useMinimumLineHeight { + paragraph.minimumLineHeight = lineHeight + } paragraph.maximumLineHeight = lineHeight } diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 0401f37d..f587beb6 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,11 +1,20 @@ +1.0.32 +======= +- Fixed bug dealing with Scaled +- Added ability to use minimumLineheight in Paragraph for AttributedString creation + 1.0.31 ======= -- Upated Label to allow Scaled Fonts +- updated version only + +1.0.30 +======= +- Updated Label to allow Scaled Fonts - Refactored Code TextStyle 1.0.29 ======= -- Upated TextStyle and Label for dealing with Top/Bottom insets +- Updated TextStyle and Label for dealing with Top/Bottom insets - Refactored Code for Checkbox/RadioButton/Toggle 1.0.28 From 090a65e998bb255baaf7fa7b45c73a6a8135f61d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 22 Jul 2023 12:14:52 -0500 Subject: [PATCH 11/20] added another test property useScaledLineHeight Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/Extensions/NSAttributedString.swift | 7 +++++-- VDS/SupportingFiles/ReleaseNotes.txt | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index e320cb6c..aea11af8 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index 49f39f45..ed6f08b8 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -21,6 +21,7 @@ extension NSAttributedString { extension NSMutableAttributedString { public static var useMinimumLineHeight: Bool = true + public static var useScaledLineHeight: Bool = false public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { //var for if you can scale or not @@ -35,10 +36,12 @@ extension NSMutableAttributedString { var lineHeight = textStyle.lineHeight if scaledMode { - lineHeight = textStyle.scaledLineHeight defaultFont = defaultFont.scaledFont + if useScaledLineHeight { + lineHeight = textStyle.scaledLineHeight + } } - + //set lineHeight if textStyle.lineHeight > 0.0 { if useMinimumLineHeight { diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index f587beb6..ccf05f42 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,6 @@ +1.0.33 +======= +- 1.0.32 ======= - Fixed bug dealing with Scaled From c16381ce08964f686357ab469d0553b4f06a52fc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 22 Jul 2023 12:18:11 -0500 Subject: [PATCH 12/20] comments Signed-off-by: Matt Bruce --- VDS/SupportingFiles/ReleaseNotes.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index ccf05f42..c05fd2f4 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,6 +1,7 @@ 1.0.33 ======= -- +- Add test variable to use ratio line height or not + 1.0.32 ======= - Fixed bug dealing with Scaled From 759c6a1d52c6652d7bd462e540dbcab59eb72afc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Jul 2023 10:56:17 -0500 Subject: [PATCH 13/20] removed var to set useMinimumLineHeight, this is now a required setting Signed-off-by: Matt Bruce --- VDS/Extensions/NSAttributedString.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index ed6f08b8..bbbd9a63 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -20,7 +20,6 @@ extension NSAttributedString { extension NSMutableAttributedString { - public static var useMinimumLineHeight: Bool = true public static var useScaledLineHeight: Bool = false public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { @@ -44,9 +43,7 @@ extension NSMutableAttributedString { //set lineHeight if textStyle.lineHeight > 0.0 { - if useMinimumLineHeight { - paragraph.minimumLineHeight = lineHeight - } + paragraph.minimumLineHeight = lineHeight paragraph.maximumLineHeight = lineHeight } From e02d4ed83fbccf3453fc8b5a69b3033ea89b920e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jul 2023 14:16:08 -0500 Subject: [PATCH 14/20] commented code for extensions Signed-off-by: Matt Bruce --- VDS/Extensions/NSAttributedString.swift | 15 +++ VDS/Extensions/UIColor+VDSColor.swift | 2 + VDS/Extensions/UIControl.swift | 4 + VDS/Extensions/UIView+CALayer.swift | 12 +- VDS/Extensions/UIView.swift | 162 +++++++++++++++++++++++- 5 files changed, 192 insertions(+), 3 deletions(-) diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index bbbd9a63..4f758762 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -9,6 +9,10 @@ import Foundation import UIKit extension NSAttributedString { + + /// Spacer in the form of a AttributedString. + /// - Parameter width: size of the space. + /// - Returns: AttributedString with the Space of the width you asked. public static func spacer(for width: CGFloat) -> NSAttributedString { let spacerImage = UIImage() let spacerAttachment = NSTextAttachment() @@ -20,7 +24,18 @@ extension NSAttributedString { extension NSMutableAttributedString { + /// This will used along with mutableText method to determine if you will use a ratio version of the lineHeight within a TextStyle if you have a scaled font being used. public static var useScaledLineHeight: Bool = false + + /// Creates a MutableAttributedString for the text and other properties you have passed into the method. + /// - Parameters: + /// - text: Text you want to draw onscreen. + /// - textStyle: Style of Typography you want to render the Text. + /// - useScaledFont: Determines if you used a scaledFont or a normal Font from the TextStyle. + /// - textColor: Color of Text to render. + /// - alignment: Text alignment. + /// - lineBreakMode: LineBreak Mode. + /// - Returns: MutableAttributedString from al lof the properties you passed in to help render Text using non-standard properties. public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { //var for if you can scale or not diff --git a/VDS/Extensions/UIColor+VDSColor.swift b/VDS/Extensions/UIColor+VDSColor.swift index 9fd177d1..a2b77290 100644 --- a/VDS/Extensions/UIColor+VDSColor.swift +++ b/VDS/Extensions/UIColor+VDSColor.swift @@ -125,6 +125,8 @@ extension UIColor { return true } + /// Convert your UIColor to a VDSColor + /// - Returns: VDSColor enum that matches the hexString for this UIColor public func toVDSColor() -> VDSColor? { guard let hex = hexString else { return nil } let found = VDSColor.allCases.first{ $0.uiColor.hexString == hex } diff --git a/VDS/Extensions/UIControl.swift b/VDS/Extensions/UIControl.swift index ce32dcad..e978bed9 100644 --- a/VDS/Extensions/UIControl.swift +++ b/VDS/Extensions/UIControl.swift @@ -9,6 +9,10 @@ import Foundation import UIKit extension UIControl.State { + + /// State for Error public static var error = UIControl.State(rawValue: 1 << 16) + + /// State for Success public static var success = UIControl.State(rawValue: 1 << 17) } diff --git a/VDS/Extensions/UIView+CALayer.swift b/VDS/Extensions/UIView+CALayer.swift index a9525598..05e60113 100644 --- a/VDS/Extensions/UIView+CALayer.swift +++ b/VDS/Extensions/UIView+CALayer.swift @@ -72,6 +72,9 @@ extension UIView { // MARK: - CALayer //-------------------------------------------------- extension CALayer { + + /// Removes a sublayer of a specific name. + /// - Parameter layerName: Layer with the name you want to remove. public func remove(layerName: String) { guard let sublayers = sublayers else { return @@ -90,6 +93,12 @@ extension CALayer { //-------------------------------------------------- extension UIView { + /// Adds a border to a specific sides with the parameters. + /// - Parameters: + /// - side: Side in which to add the border. + /// - width: Width of the border. + /// - color: Color of the border. + /// - offset: offset of the border. public func addBorder(side: UIRectEdge, width: CGFloat, color: UIColor, offset: CGFloat = 0) { let layerName = borderLayerName(for: side) layer.remove(layerName: layerName) @@ -113,7 +122,8 @@ extension UIView { layer.addSublayer(borderLayer) } - + + /// Removes all of the borders addeding using the addBorder method. public func removeBorders() { layer.borderWidth = 0 layer.borderColor = nil diff --git a/VDS/Extensions/UIView.swift b/VDS/Extensions/UIView.swift index 62ed355a..8bc4f28f 100644 --- a/VDS/Extensions/UIView.swift +++ b/VDS/Extensions/UIView.swift @@ -21,6 +21,11 @@ extension UIView { //-------------------------------------------------- extension UIView { @discardableResult + /// Pins each to the all 4 anchor points to a view. + /// - Parameters: + /// - view: View that you will be pinned within. + /// - edges: Insets for each side. + /// - Returns: Yourself. public func pin(_ view: UIView, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { pinLeading(view.leadingAnchor, edges.left) pinTrailing(view.trailingAnchor, edges.right) @@ -30,6 +35,10 @@ extension UIView { } @discardableResult + + /// Pins each to the all 4 anchor points to the view you are set within. + /// - Parameter edges: Insets for each side. + /// - Returns: Yourself. public func pinToSuperView(_ edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { if let superview { pin(superview, with: edges) @@ -44,34 +53,52 @@ extension UIView { extension UIView { @discardableResult + /// Adds a heightAnchor. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func height(_ constant: CGFloat) -> Self { height(constant: constant) return self } @discardableResult + /// Adds a heightAnchor where the height constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func heightGreaterThanEqualTo(_ constant: CGFloat) -> Self { heightGreaterThanEqualTo(constant: constant) return self } @discardableResult + /// Adds a heightAnchor where the height constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func heightLessThanEqualTo(_ constant: CGFloat) -> Self { heightLessThanEqualTo(constant: constant) return self } @discardableResult + /// Adds a heightAnchor for the constant passed into the method. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func height(constant: CGFloat) -> NSLayoutConstraint { heightAnchor.constraint(equalToConstant: constant).activate() } @discardableResult + /// Adds a heightAnchor where the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func heightGreaterThanEqualTo(constant: CGFloat) -> NSLayoutConstraint { heightAnchor.constraint(greaterThanOrEqualToConstant: constant).activate() } @discardableResult + /// Adds a heightAnchor where the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func heightLessThanEqualTo(constant: CGFloat) -> NSLayoutConstraint { heightAnchor.constraint(lessThanOrEqualToConstant: constant).activate() } @@ -84,34 +111,52 @@ extension UIView { extension UIView { @discardableResult + /// Adds a widthAnchor. + /// - Parameter constant: Width Constant size. + /// - Returns: Yourself. public func width(_ constant: CGFloat) -> Self { width(constant: constant) return self } @discardableResult + /// Adds a widthAnchor where the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func widthGreaterThanEqualTo(_ constant: CGFloat) -> Self { widthGreaterThanEqualTo(constant: constant) return self } @discardableResult + /// Adds a widthAnchor where the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func widthLessThanEqualTo(_ constant: CGFloat) -> Self { widthLessThanEqualTo(constant: constant) return self } @discardableResult + /// Adds a widthAnchor for the constant passed into the method. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func width(constant: CGFloat) -> NSLayoutConstraint { widthAnchor.constraint(equalToConstant: constant).activate() } @discardableResult + /// Adds a widthAnchor with the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func widthGreaterThanEqualTo(constant: CGFloat) -> NSLayoutConstraint { widthAnchor.constraint(greaterThanOrEqualToConstant: constant).activate() } @discardableResult + /// Adds a widthAnchor with the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter constant: Constant size. + /// - Returns: The Constraint that was created. public func widthLessThanEqualTo(constant: CGFloat) -> NSLayoutConstraint { widthAnchor.constraint(lessThanOrEqualToConstant: constant).activate() } @@ -123,29 +168,48 @@ extension UIView { extension UIView { @discardableResult + /// Adds a topAnchor. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func pinTop(_ constant: CGFloat = 0.0) -> Self { return pinTop(nil, constant) } @discardableResult + /// Adds a topAnchor to a specific YAxisAnchor. + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTop(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinTop(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a topAnchor to a specific YAxisAnchor passed in using a lessThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTopLessThanOrEqualTo(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { - pinBottomLessThanOrEqualTo(anchor: anchor, constant: constant) + pinTopLessThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a topAnchor to a specific YAxisAnchor passed in using a greaterThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTopGreaterThanOrEqualTo(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinTopGreaterThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a topAnchor for the constant passed into the method. + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTop(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.topAnchor guard let found else { return nil } @@ -153,6 +217,10 @@ extension UIView { } @discardableResult + /// Adds a topAnchor with the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTopLessThanOrEqualTo(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.topAnchor guard let found else { return nil } @@ -160,6 +228,10 @@ extension UIView { } @discardableResult + /// Adds a topAnchor with the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the topAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTopGreaterThanOrEqualTo(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.topAnchor guard let found else { return nil } @@ -173,29 +245,48 @@ extension UIView { //-------------------------------------------------- extension UIView { @discardableResult + /// Adds a bottomAnchor. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func pinBottom(_ constant: CGFloat = 0.0) -> Self { return pinBottom(nil, constant) } @discardableResult + /// Adds a bottomAnchor to a specific YAxisAnchor. + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinBottom(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinBottom(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a bottomAnchor to a specific YAxisAnchor passed in using a lessThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinBottomLessThanOrEqualTo(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinBottomLessThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a bottomAnchor to a specific YAxisAnchor passed in using a greaterThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinBottomGreaterThanOrEqualTo(_ anchor: NSLayoutYAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinBottomGreaterThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a bottomAnchor for the constant passed into the method. + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinBottom(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.bottomAnchor guard let found else { return nil } @@ -203,6 +294,10 @@ extension UIView { } @discardableResult + /// Adds a bottomAnchor with the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinBottomLessThanOrEqualTo(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.bottomAnchor guard let found else { return nil } @@ -210,6 +305,10 @@ extension UIView { } @discardableResult + /// Adds a bottomAnchor with the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the bottomAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinBottomGreaterThanOrEqualTo(anchor: NSLayoutYAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutYAxisAnchor? = anchor ?? superview?.bottomAnchor guard let found else { return nil } @@ -223,29 +322,48 @@ extension UIView { extension UIView { @discardableResult + /// Adds a leadingAnchor. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func pinLeading(_ constant: CGFloat = 0.0) -> Self { return pinLeading(nil, constant) } @discardableResult + /// Adds a leadingAnchor to a specific XAxisAnchor. + /// - Parameter anchor:The anchor in which to attach the leadingAnchor. + /// - constant: Constant size. + /// - Returns: Yourself. public func pinLeading(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinLeading(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a leadingAnchor to a specific XAxisAnchor passed in using a greaterThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the leadingAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinLeadingLessThanOrEqualTo(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinLeadingLessThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a leadingAnchor to a specific XAxisAnchor passed in using a greaterThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the leadingAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinLeadingGreaterThanOrEqualTo(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinLeadingGreaterThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a leadingAnchor for the constant passed into the method. + /// - Parameter anchor:The anchor in which to attach the leadingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinLeading(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.leadingAnchor guard let found else { return nil } @@ -253,6 +371,10 @@ extension UIView { } @discardableResult + /// Adds a leadingAnchor with the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the leadingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinLeadingLessThanOrEqualTo(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.leadingAnchor guard let found else { return nil } @@ -260,6 +382,10 @@ extension UIView { } @discardableResult + /// Adds a leadingAnchor with the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the leadingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinLeadingGreaterThanOrEqualTo(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.leadingAnchor guard let found else { return nil } @@ -273,29 +399,48 @@ extension UIView { extension UIView { @discardableResult + /// Adds a trailingAnchor. + /// - Parameter constant: Constant size. + /// - Returns: Yourself. public func pinTrailing(_ constant: CGFloat = 0.0) -> Self { pinTrailing(nil, constant) } @discardableResult + /// Adds a trailingAnchor to a specific XAxisAnchor. + /// - Parameter anchor:The anchor in which to attach the trailingAnchor. + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTrailing(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinTrailing(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a trailingAnchor to a specific XAxisAnchor passed in using a lessThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the trailingAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTrailingLessThanOrEqualTo(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinTrailingLessThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a trailingAnchor to a specific XAxisAnchor passed in using a greaterThanOrEqualTo Constraint + /// - Parameter anchor:The anchor in which to attach the trailingAnchor + /// - constant: Constant size. + /// - Returns: Yourself. public func pinTrailingGreaterThanOrEqualTo(_ anchor: NSLayoutXAxisAnchor? = nil, _ constant: CGFloat = 0.0) -> Self { pinTrailingGreaterThanOrEqualTo(anchor: anchor, constant: constant) return self } @discardableResult + /// Adds a trailingAnchor for the constant passed into the method. + /// - Parameter anchor:The anchor in which to attach the trailingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTrailing(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.trailingAnchor guard let found else { return nil } @@ -303,6 +448,10 @@ extension UIView { } @discardableResult + /// Adds a trailingAnchor with the constant passed in using a lessThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the trailingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTrailingLessThanOrEqualTo(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.trailingAnchor guard let found else { return nil } @@ -310,6 +459,10 @@ extension UIView { } @discardableResult + /// Adds a trailingAnchor with the constant passed in using a greaterThanOrEqualTo Constraint. + /// - Parameter anchor:The anchor in which to attach the trailingAnchor + /// - constant: Constant size. + /// - Returns: The Constraint that was created. public func pinTrailingGreaterThanOrEqualTo(anchor: NSLayoutXAxisAnchor?, constant: CGFloat = 0.0) -> NSLayoutConstraint? { let found: NSLayoutXAxisAnchor? = anchor ?? superview?.trailingAnchor guard let found else { return nil } @@ -320,17 +473,22 @@ extension UIView { extension NSLayoutConstraint { @discardableResult + /// Activates yourself + /// - Returns: Self public func activate() -> Self{ isActive = true return self } @discardableResult + /// Deactivates yourself + /// - Returns: Self public func deactivate() -> Self{ isActive = false return self } - + + /// Helper class that holds onto all types of Contraints. public class Container { public var topConstraint: NSLayoutConstraint? public var leadingConstraint: NSLayoutConstraint? From 48411cb7c3dd9549cd376ed9f7112fdea48ebe34 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jul 2023 14:19:28 -0500 Subject: [PATCH 15/20] commented on Fonts Signed-off-by: Matt Bruce --- VDS/Fonts/Font.swift | 2 ++ VDS/Fonts/FontProtocol.swift | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VDS/Fonts/Font.swift b/VDS/Fonts/Font.swift index 57ad5962..ecd692de 100644 --- a/VDS/Fonts/Font.swift +++ b/VDS/Fonts/Font.swift @@ -7,6 +7,7 @@ import Foundation +/// Enum that is matched up for the Verizon fonts. public enum Font: String, FontProtocol { case dsBold case dsRegular @@ -29,6 +30,7 @@ public enum Font: String, FontProtocol { } } + /// File Extension for each of the Font enums. public var fontFileExtension: String { return "otf" } diff --git a/VDS/Fonts/FontProtocol.swift b/VDS/Fonts/FontProtocol.swift index 74ad8701..9ee21939 100644 --- a/VDS/Fonts/FontProtocol.swift +++ b/VDS/Fonts/FontProtocol.swift @@ -8,12 +8,15 @@ import Foundation import UIKit +/// Used in Classes that require Fonts public protocol FontProtocol: CaseIterable, RawRepresentable, Hashable { var fontFileExtension: String { get } var fontName: String { get } } extension FontProtocol { + + /// Registers the fonts used in the VDS Framework. public func register() { guard let bundle = Bundle(identifier: "com.vzw.vds") else { return } Self.allCases.forEach{ font in @@ -29,6 +32,8 @@ extension FontProtocol { } } + /// Registers a font from a fileLocation + /// - Parameter url: URL of the file location. public static func register(from url: URL) throws { guard let fontDataProvider = CGDataProvider(url: url as CFURL) else { throw NSError(domain: "www.verizon.com", code: 123, userInfo: ["description":"Could not create font data provider for \(url)."]) @@ -40,7 +45,11 @@ extension FontProtocol { } } - public func font(ofSize size: CGFloat, isScaled: Bool = true) -> UIFont{ + /// Returns a UIFont for the fontName and size given. + /// - Parameters: + /// - size: Size of the font + /// - Returns: UIFont for the fontName and Size. + public func font(ofSize size: CGFloat) -> UIFont{ DispatchQueue.once(block: { self.register() }) guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) } return found From 0a9b4ec368ea36c1e858c694a8acfdcd3a3a66d0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Jul 2023 10:13:49 -0500 Subject: [PATCH 16/20] added comments for reset() Signed-off-by: Matt Bruce --- VDS/Classes/SelectorItemBase.swift | 1 + VDS/Components/Badge/Badge.swift | 1 + VDS/Components/BadgeIndicator/BadgeIndicator.swift | 1 + VDS/Components/Buttons/Button/Button.swift | 1 + VDS/Components/Buttons/Button/ButtonBase.swift | 1 + VDS/Components/Buttons/TextLink/TextLink.swift | 1 + VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift | 1 + VDS/Components/Icon/ButtonIcon/ButtonIcon.swift | 1 + VDS/Components/Icon/Icon.swift | 1 + VDS/Components/Label/Label.swift | 1 + VDS/Components/Line/Line.swift | 1 + VDS/Components/Notification/Notification.swift | 1 + VDS/Components/RadioBox/RadioBoxItem.swift | 1 + VDS/Components/RadioSwatch/RadioSwatch.swift | 3 ++- VDS/Components/TextFields/EntryField/EntryField.swift | 1 + VDS/Components/TextFields/InputField/InputField.swift | 1 + VDS/Components/TextFields/TextArea/TextArea.swift | 1 + VDS/Components/TileContainer/TileContainer.swift | 1 + VDS/Components/Tilelet/Tilelet.swift | 1 + VDS/Components/TitleLockup/TitleLockup.swift | 1 + VDS/Components/Toggle/Toggle.swift | 1 + VDS/Components/Toggle/ToggleView.swift | 1 + VDS/Components/Tooltip/Tooltip.swift | 1 + VDS/Components/Tooltip/TrailingTooltipLabel.swift | 1 + VDS/Protocols/Resetable.swift | 1 + 25 files changed, 26 insertions(+), 1 deletion(-) diff --git a/VDS/Classes/SelectorItemBase.swift b/VDS/Classes/SelectorItemBase.swift index 9575f7a2..b9f659bd 100644 --- a/VDS/Classes/SelectorItemBase.swift +++ b/VDS/Classes/SelectorItemBase.swift @@ -226,6 +226,7 @@ open class SelectorItemBase: Control, Errorable, } } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index da8ff792..321753f9 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -75,6 +75,7 @@ open class Badge: View { } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 748025e2..d35b7187 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -278,6 +278,7 @@ open class BadgeIndicator: View { } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 3ac084fa..be1a7cec 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -130,6 +130,7 @@ open class Button: ButtonBase, Useable { heightConstraint?.isActive = true } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index a3bd1941..054c10b3 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -135,6 +135,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab } + /// Resets back to this objects default settings. open func reset() { shouldUpdateView = false surface = .light diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index f604cad9..573665e0 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -87,6 +87,7 @@ open class TextLink: ButtonBase { } } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index ad95a4af..c7c14e74 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -79,6 +79,7 @@ open class TextLinkCaret: ButtonBase { accessibilityTraits = .link } + /// Resets back to this objects default settings. open override func reset() { super.reset() iconPosition = .right diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index 12db5a56..5d7c63ba 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -253,6 +253,7 @@ open class ButtonIcon: Control { iconLayoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)]) } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 7983d7c9..b1cb3c0b 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -62,6 +62,7 @@ open class Icon: View { accessibilityTraits = .image } + /// Resets back to this objects default settings. open override func reset() { super.reset() color = VDSColor.paletteBlack diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 203e669d..f2f83116 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -111,6 +111,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open func setup() {} + /// Resets back to this objects default settings. open func reset() { shouldUpdateView = false surface = .light diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 417fb077..18bb485f 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -40,6 +40,7 @@ open class Line: View { lineView.pinToSuperView() } + /// Resets back to this objects default settings. open override func reset() { super.reset() style = .primary diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 20d39096..de382de3 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -228,6 +228,7 @@ open class Notification: View { subTitleLabel.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() } + /// Resets back to this objects default settings. open override func reset() { super.reset() diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 380383b9..74e2f574 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -200,6 +200,7 @@ open class RadioBoxItem: Control, Changeable { } } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 8178f971..465aef71 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -88,7 +88,8 @@ open class RadioSwatch: Control { fillView.width(fillSize.width) } - + + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 0a280ffb..eb43ba49 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -228,6 +228,7 @@ open class EntryField: Control, Changeable { return containerView } + /// Resets back to this objects default settings. open override func reset() { super.reset() titleLabel.reset() diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index acbec3ec..6b25c7e1 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -140,6 +140,7 @@ open class InputField: EntryField, UITextFieldDelegate { } + /// Resets back to this objects default settings. open override func reset() { super.reset() textField.text = "" diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 31ade50c..9064c9fc 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -79,6 +79,7 @@ open class TextArea: EntryField { textView.delegate = self } + /// Resets back to this objects default settings. open override func reset() { super.reset() textView.text = "" diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 0fb735fe..6b5eef20 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -189,6 +189,7 @@ open class TileContainer: Control { } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index c91c7eba..9cc2e938 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -240,6 +240,7 @@ open class Tilelet: TileContainer { } + /// Resets back to this objects default settings. open override func reset() { shouldUpdateView = false aspectRatio = .none diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 6381fed5..9fd0f6b6 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -196,6 +196,7 @@ open class TitleLockup: View { } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index ba718598..1d9b77b0 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -172,6 +172,7 @@ open class Toggle: Control, Changeable { } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 917d4676..db07e66d 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -136,6 +136,7 @@ open class ToggleView: Control, Changeable { open override var intrinsicContentSize: CGSize { toggleSize } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index fd75c610..585ab355 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -139,6 +139,7 @@ open class Tooltip: Control, TooltipLaunchable { }) } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 220cb2f3..00cbc8f3 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -77,6 +77,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { } } + /// Resets back to this objects default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Protocols/Resetable.swift b/VDS/Protocols/Resetable.swift index 6dde1028..528cba1d 100644 --- a/VDS/Protocols/Resetable.swift +++ b/VDS/Protocols/Resetable.swift @@ -8,5 +8,6 @@ import Foundation public protocol Resettable { + /// Called to reset back an objects default settings. func reset() } From cd88205b408226800a0c1263e0947827426976b2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Jul 2023 10:20:11 -0500 Subject: [PATCH 17/20] added comments Signed-off-by: Matt Bruce --- VDS/Protocols/Changeable.swift | 2 ++ VDS/Protocols/Clickable.swift | 2 ++ 2 files changed, 4 insertions(+) diff --git a/VDS/Protocols/Changeable.swift b/VDS/Protocols/Changeable.swift index 38f9cd03..d51c734b 100644 --- a/VDS/Protocols/Changeable.swift +++ b/VDS/Protocols/Changeable.swift @@ -14,6 +14,8 @@ public protocol Changeable: Handlerable where Self: UIControl { } extension Changeable { + /// Allows the setting of a completion block against the onChangeSubscriber cancellable. This will + /// completion block will get executed against the UIControl publisher for the 'valueChange' action. public var onChange: ((Self) -> ())? { get { return nil } set { diff --git a/VDS/Protocols/Clickable.swift b/VDS/Protocols/Clickable.swift index a202850a..f98dd1c7 100644 --- a/VDS/Protocols/Clickable.swift +++ b/VDS/Protocols/Clickable.swift @@ -15,6 +15,8 @@ public protocol Clickable: Handlerable where Self: UIControl { } extension Clickable { + /// Allows the setting of a completion block against the onClickSubscriber cancellable. This will + /// completion block will get executed against the UIControl publisher for the 'touchUpInside' action. public var onClick: ((Self) -> ())? { get { return nil } set { From 16e8067f8edb86af7eb958d2d98f04b35518324b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Jul 2023 10:23:38 -0500 Subject: [PATCH 18/20] commented code Signed-off-by: Matt Bruce --- VDS/Protocols/EnumSubset.swift | 2 ++ VDS/Protocols/Errorable.swift | 5 +++++ VDS/Protocols/FormFieldable.swift | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/VDS/Protocols/EnumSubset.swift b/VDS/Protocols/EnumSubset.swift index 5f92a1cd..a690fca3 100644 --- a/VDS/Protocols/EnumSubset.swift +++ b/VDS/Protocols/EnumSubset.swift @@ -13,6 +13,8 @@ public protocol EnumSubset: RawRepresentable, CaseIterable { } extension EnumSubset where RawValue == T.RawValue { + + /// Will either return the Generic RawRepresentable object or the defaultValue public var value: T { T(rawValue: rawValue) ?? defaultValue } diff --git a/VDS/Protocols/Errorable.swift b/VDS/Protocols/Errorable.swift index bd9b41de..5323dd17 100644 --- a/VDS/Protocols/Errorable.swift +++ b/VDS/Protocols/Errorable.swift @@ -7,7 +7,12 @@ import Foundation +/// Protocol used for objects that require to show an error public protocol Errorable { + + /// Whether not to show the errorText var showError: Bool { get set } + + /// Text that needs to be shown if showError is true var errorText: String? { get set } } diff --git a/VDS/Protocols/FormFieldable.swift b/VDS/Protocols/FormFieldable.swift index 41017204..935b3d53 100644 --- a/VDS/Protocols/FormFieldable.swift +++ b/VDS/Protocols/FormFieldable.swift @@ -7,7 +7,12 @@ import Foundation +/// Protocol used for a FormField object public protocol FormFieldable { + + /// Unique Id for the Form Field object within a Form var inputId: String? { get set } + + /// Value for the Form Field var value: AnyHashable? { get set } } From 56fc899a2060925eb9693cca3704e1f347a1b520 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Jul 2023 14:30:42 -0500 Subject: [PATCH 19/20] added the bottom insets to the TextStyles Signed-off-by: Matt Bruce --- VDS/Typography/Typogprahy+Styles.swift | 45 ++++++++++++++++++-------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index 3894b3f7..b593f33b 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -16,73 +16,86 @@ extension TextStyle { fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: VDSTypography.letterSpacingSemiWide) - + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) + public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) public static let featureLarge = TextStyle(rawValue: "featureLarge", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) + public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) public static let featureMedium = TextStyle(rawValue: "featureMedium", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) public static let featureSmall = TextStyle(rawValue: "featureSmall", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let featureXSmall = TextStyle(rawValue: "featureXSmall", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let title2XLarge = TextStyle(rawValue: "title2XLarge", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: VDSTypography.letterSpacingSemiWide, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", fontFace: .dsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - letterSpacing: 0) + letterSpacing: 0, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let titleXLarge = TextStyle(rawValue: "titleXLarge", fontFace: .dsLight, @@ -214,6 +227,12 @@ extension TextStyle { } } +extension UIEdgeInsets { + public init(bottom: CGFloat) { + self.init(top: 0, left: 0, bottom: bottom, right: 0) + } +} + extension TextStyle { public enum StandardStyle: String, CaseIterable { case featureXLarge, From 0da74efd9d0b0516194d839605716192cf5b5e69 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Jul 2023 14:33:38 -0500 Subject: [PATCH 20/20] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index aea11af8..6c0e23ad 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index c05fd2f4..418fbd1e 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,7 @@ +1.0.34 +======= +- Added new spec for Bottom Inset for TextStyle + 1.0.33 ======= - Add test variable to use ratio line height or not