From 58388b81b84f483545a364bdcc5fafec5a762baf Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 19 Jun 2023 14:38:13 -0500 Subject: [PATCH 1/7] updated Signed-off-by: Matt Bruce --- .../Buttons/Button/ButtonBase.swift | 9 +--- VDS/Components/Label/Label.swift | 44 ++++--------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index a7f5ca17..60844f89 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -195,17 +195,12 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //set lineHeight if textStyle.lineHeight > 0.0 { let lineHeight = textStyle.lineHeight - let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0 - let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment paragraph.maximumLineHeight = lineHeight paragraph.minimumLineHeight = lineHeight - mutableText.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange) - mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - - } else { - mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) } + mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) + if let attributes = attributes { //loop through the models attributes for attribute in attributes { diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index c460530b..111743d0 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -38,15 +38,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() - - open var edgeInset: UIEdgeInsets = .zero { - didSet { - setNeedsUpdate() - - } - } - override open var text: String? { didSet { attributes = nil @@ -178,38 +170,20 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange) } + let paragraph = NSMutableParagraphStyle() + paragraph.alignment = textPosition.textAlignment + paragraph.lineBreakMode = lineBreakMode + //set lineHeight if textStyle.lineHeight > 0.0 { let lineHeight = textStyle.lineHeight - let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0 - let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment - let paragraph = NSMutableParagraphStyle().with { - $0.maximumLineHeight = lineHeight - $0.minimumLineHeight = lineHeight - $0.alignment = textPosition.textAlignment - $0.lineBreakMode = lineBreakMode - } - attributedString.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange) - attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - - } else if textPosition != .left { - let paragraph = NSMutableParagraphStyle().with { - $0.alignment = textPosition.textAlignment - $0.lineBreakMode = lineBreakMode - } - attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) + paragraph.maximumLineHeight = lineHeight + paragraph.minimumLineHeight = lineHeight } + + attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) } - - open override func drawText(in rect: CGRect) { - super.drawText(in: rect.inset(by: edgeInset)) - } - - open override var intrinsicContentSize: CGSize { - let size = super.intrinsicContentSize - return CGSize(width: size.width + edgeInset.left + edgeInset.right, height: size.height + edgeInset.top + edgeInset.bottom) - } - + //-------------------------------------------------- // MARK: - Actionable //-------------------------------------------------- From 94fffc289a0137de7be22436df3d762aee359a94 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 19 Jun 2023 14:52:48 -0500 Subject: [PATCH 2/7] refactored to use new extension Signed-off-by: Matt Bruce --- .../Buttons/Button/ButtonBase.swift | 33 +++------------ VDS/Components/Label/Label.swift | 40 +++---------------- VDS/Extensions/NSAttributedString.swift | 30 ++++++++++++++ 3 files changed, 42 insertions(+), 61 deletions(-) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 60844f89..00eed2db 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -169,38 +169,17 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab // MARK: - PRIVATE //-------------------------------------------------- private func updateLabel() { - let font = textStyle.font - + //clear the arrays holding actions accessibilityCustomActions = [] //create the primary string - let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] - let mutableText = NSMutableAttributedString(string: text ?? "No Text", attributes: startingAttributes) + let mutableText = NSMutableAttributedString.mutableText(for: text ?? "No Text", + textStyle: textStyle, + textColor: textColor, + alignment: titleLabel?.textAlignment ?? .center, + lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail) - //set the local lineHeight/lineSpacing attributes - //get the range - let entireRange = NSRange(location: 0, length: mutableText.length) - - //set letterSpacing - if textStyle.letterSpacing > 0.0 { - mutableText.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange) - } - - let paragraph = NSMutableParagraphStyle().with { - $0.alignment = titleLabel?.textAlignment ?? .center - $0.lineBreakMode = titleLabel?.lineBreakMode ?? .byTruncatingTail - } - - //set lineHeight - if textStyle.lineHeight > 0.0 { - let lineHeight = textStyle.lineHeight - paragraph.maximumLineHeight = lineHeight - paragraph.minimumLineHeight = lineHeight - } - - mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - if let attributes = attributes { //loop through the models attributes for attribute in attributes { diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 111743d0..0ca91cd0 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -110,20 +110,15 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- open func updateView() { if !useAttributedText { - textAlignment = textPosition.textAlignment - textColor = textColorConfiguration.getColor(self) - font = textStyle.font - - if let text = text, let font = font, let textColor = textColor { + if let text = text { accessibilityCustomActions = [] - //clear the arrays holding actions //create the primary string - let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] - let mutableText = NSMutableAttributedString(string: text, attributes: startingAttributes) - - //set the local lineHeight/lineSpacing attributes - setStyleAttributes(attributedString: mutableText) + let mutableText = NSMutableAttributedString.mutableText(for: text, + textStyle: textStyle, + textColor: textColorConfiguration.getColor(self), + alignment: textPosition.textAlignment, + lineBreakMode: lineBreakMode) applyAttributes(mutableText) @@ -160,30 +155,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { } } } - - private func setStyleAttributes(attributedString: NSMutableAttributedString) { - //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) - } - - let paragraph = NSMutableParagraphStyle() - paragraph.alignment = textPosition.textAlignment - paragraph.lineBreakMode = lineBreakMode - - //set lineHeight - if textStyle.lineHeight > 0.0 { - let lineHeight = textStyle.lineHeight - paragraph.maximumLineHeight = lineHeight - paragraph.minimumLineHeight = lineHeight - } - - attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - } - //-------------------------------------------------- // MARK: - Actionable //-------------------------------------------------- diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index d51ec05a..a4b94fb9 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -17,3 +17,33 @@ extension NSAttributedString { return NSAttributedString(attachment: spacerAttachment) } } + +extension NSMutableAttributedString { + public static func mutableText(for text: String, textStyle: TextStyle, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { + let startingAttributes = [NSAttributedString.Key.font: textStyle.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) + } + + let paragraph = NSMutableParagraphStyle() + paragraph.alignment = alignment + paragraph.lineBreakMode = lineBreakMode + + //set lineHeight + if textStyle.lineHeight > 0.0 { + let lineHeight = textStyle.lineHeight + paragraph.maximumLineHeight = lineHeight + paragraph.minimumLineHeight = lineHeight + } + + attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) + + return attributedString + } +} From 1603beb911e13a1b6c81aa6ac5a0d53b93c0320e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 19 Jun 2023 14:52:57 -0500 Subject: [PATCH 3/7] added isActive Signed-off-by: Matt Bruce --- VDS/Extensions/UIView.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/VDS/Extensions/UIView.swift b/VDS/Extensions/UIView.swift index 517ef104..62ed355a 100644 --- a/VDS/Extensions/UIView.swift +++ b/VDS/Extensions/UIView.swift @@ -339,6 +339,17 @@ extension NSLayoutConstraint { public var widthConstraint: NSLayoutConstraint? public var heightConstraint: NSLayoutConstraint? + public var isActive: Bool = false { + didSet{ + topConstraint?.isActive = isActive + bottomConstraint?.isActive = isActive + leadingConstraint?.isActive = isActive + trailingConstraint?.isActive = isActive + heightConstraint?.isActive = isActive + widthConstraint?.isActive = isActive + } + } + public init(){} } From 67cbef5265dd08ccf5b431f06318ce762019afe2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 19 Jun 2023 16:20:16 -0500 Subject: [PATCH 4/7] fixed letterspacing Signed-off-by: Matt Bruce --- VDS/Typography/Typography.swift | 59 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 3759cb26..167f378e 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -48,6 +48,9 @@ public struct TextStyle: Equatable, RawRepresentable { } } +extension VDSTypography { + public static let letterSpacingSemiWide: CGFloat = 0.25 +} //MARK: Definitions extension TextStyle { @@ -56,169 +59,169 @@ extension TextStyle { fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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: 0.25) + 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.25) + 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.25) + 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.25) + 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.25) + 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.25) + letterSpacing: 0) public static let bodyLarge = TextStyle(rawValue: "bodyLarge", fontFace: .dsRegular, pointSize: VDSTypography.fontSizeBody16, lineHeight: VDSTypography.lineHeightBody20, - letterSpacing: 0.5) + letterSpacing:VDSTypography.letterSpacingWide) public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge", fontFace: .dsBold, pointSize: VDSTypography.fontSizeBody16, lineHeight: VDSTypography.lineHeightBody20, - letterSpacing: 0.5) + letterSpacing: VDSTypography.letterSpacingWide) public static let bodyMedium = TextStyle(rawValue: "bodyMedium", fontFace: .dsRegular, pointSize: VDSTypography.fontSizeBody14, lineHeight: VDSTypography.lineHeightBody18, - letterSpacing: 0.5) + letterSpacing: VDSTypography.letterSpacingWide) public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium", fontFace: .dsBold, pointSize: VDSTypography.fontSizeBody14, lineHeight: VDSTypography.lineHeightBody18, - letterSpacing: 0.5) + letterSpacing: VDSTypography.letterSpacingWide) public static let bodySmall = TextStyle(rawValue: "bodySmall", fontFace: .dsRegular, pointSize: VDSTypography.fontSizeBody12, lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0.25) + letterSpacing: 0) public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall", fontFace: .dsBold, pointSize: VDSTypography.fontSizeBody12, lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0.5) + letterSpacing: 0) public static let micro = TextStyle(rawValue: "micro", fontFace: .dsRegular, pointSize: VDSTypography.fontSizeMicro11, lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0.25) + letterSpacing: 0) public static let boldMicro = TextStyle(rawValue: "boldMicro", fontFace: .dsBold, pointSize: VDSTypography.fontSizeMicro11, lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0.5) + letterSpacing: 0) public static var allCases: [TextStyle] { return [ From c1b91cc651bbeb6a465df4e86c60789e7326d74f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 19 Jun 2023 16:20:26 -0500 Subject: [PATCH 5/7] refactored some badge properties Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 166 ++++++++++-------- 1 file changed, 93 insertions(+), 73 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 4554f11f..69ca0264 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -52,80 +52,41 @@ open class BadgeIndicator: View { } } - public enum TextSize: String, CaseIterable { + public enum Size: String, CaseIterable { case xxlarge = "2XLarge" case xlarge = "XLarge" case large = "Large" case medium = "Medium" case small = "Small" - - public var inset: CGFloat { - return textStyle.pointSize * 0.3333 -// switch self { -// case .xxlarge: -// return 8 -// case .xlarge: -// return 6 -// case .large: -// return 6 -// case .medium: -// return 6 -// case .small: -// return 4 -// } - } - - public var lineHeight: CGFloat { - switch self { - case .xxlarge: - return 29 - case .xlarge: - return 24 - case .large: - return 20 - case .medium: - return 18 - case .small: - return 16 - } - } public var textStyle: TextStyle { let style = TextStyle.bodySmall var pointSize: CGFloat = VDSTypography.fontSizeBody12 + var letterSpacing: CGFloat = 0.0 switch self { case .xxlarge: pointSize = VDSTypography.fontSizeTitle24 - + letterSpacing = VDSTypography.letterSpacingWide + case .xlarge: pointSize = VDSTypography.fontSizeTitle20 case .large: pointSize = VDSTypography.fontSizeBody16 + letterSpacing = VDSTypography.letterSpacingWide case .medium: pointSize = VDSTypography.fontSizeBody14 - + letterSpacing = VDSTypography.letterSpacingWide case .small: pointSize = VDSTypography.fontSizeBody12 } -// var ratio: CGFloat = 1.3333 // less than 14 -// if pointSize > 13 && pointSize < 16 { -// ratio = 1.28 -// } else if pointSize > 15 && pointSize < 19 { -// ratio = 1.25 -// } else if pointSize > 19 { -// ratio = 1.20 -// } - - let calculatedLineHeight = pointSize * 1.265//ratio - print("lineHeight\noriginal: \(lineHeight)\ncalculated:\(calculatedLineHeight)") return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator", fontFace: style.fontFace, pointSize: pointSize, - lineHeight: calculatedLineHeight, - letterSpacing: style.letterSpacing) + lineHeight: 0, + letterSpacing: letterSpacing) } } @@ -171,7 +132,13 @@ open class BadgeIndicator: View { open var leadingCharacter: String? { didSet { setNeedsUpdate() }} - open var textSize: TextSize = .xxlarge { didSet { setNeedsUpdate() }} + open var size: Size = .xxlarge { didSet { setNeedsUpdate() }} + + open var dotSize: CGFloat? { didSet { setNeedsUpdate() }} + + open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() }} + + open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() }} open var hideDot: Bool = false { didSet { setNeedsUpdate() }} @@ -179,31 +146,50 @@ open class BadgeIndicator: View { open var maxDigits: MaxDigits = .two { didSet { setNeedsUpdate() }} + open var width: CGFloat? { didSet { setNeedsUpdate() }} + + open var height: CGFloat? { didSet { setNeedsUpdate() }} + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- - private var labelWidthConstraint: NSLayoutConstraint? - private var labelHeightConstraint: NSLayoutConstraint? - private var defaultBadgeSize: CGFloat = 16 + private let layoutGuide = UILayoutGuide() + private var defaultBadgeSize: CGFloat { max(16.0, size.textStyle.font.lineHeight) } + private var widthConstraint: NSLayoutConstraint? + private var heightConstraint: NSLayoutConstraint? + private var labelContraints = NSLayoutConstraint.Container() + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- open override func setup() { super.setup() - + + addLayoutGuide(layoutGuide) + addSubview(label) accessibilityElements = [label] - addSubview(label) - label.pinToSuperView() + heightConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + heightConstraint?.isActive = true + widthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + widthConstraint?.isActive = true + NSLayoutConstraint.activate([ - label.centerXAnchor.constraint(equalTo: centerXAnchor), - label.centerYAnchor.constraint(equalTo: centerYAnchor) - ]) - - labelWidthConstraint = label.widthGreaterThanEqualTo(constant: defaultBadgeSize).activate() - labelHeightConstraint = label.heightGreaterThanEqualTo(constant: defaultBadgeSize).activate() + layoutGuide.topAnchor.constraint(equalTo: topAnchor, constant: 1), + layoutGuide.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -1), + layoutGuide.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 1), + layoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -1)]) + + labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: layoutGuide.topAnchor) + labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: layoutGuide.bottomAnchor) + labelContraints.leadingConstraint = label.pinLeadingGreaterThanOrEqualTo(anchor: layoutGuide.leadingAnchor) + labelContraints.trailingConstraint = label.pinTrailingGreaterThanOrEqualTo(anchor: layoutGuide.trailingAnchor) + label.centerXAnchor.constraint(equalTo: layoutGuide.centerXAnchor).isActive = true + label.centerYAnchor.constraint(equalTo: layoutGuide.centerYAnchor).isActive = true + labelContraints.isActive = true + } open override func reset() { @@ -218,6 +204,21 @@ open class BadgeIndicator: View { setNeedsUpdate() } + private let defaultInset = VDSLayout.Spacing.space1X.value + + private var labelEdgeInset: UIEdgeInsets { + + if let verticalPadding, let horitonalPadding { + return .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding) + } else if let verticalPadding { + return .init(top: verticalPadding, left: defaultInset, bottom: verticalPadding, right: defaultInset) + } else if let horitonalPadding { + return .init(top: defaultInset, left: horitonalPadding, bottom: defaultInset, right: horitonalPadding) + } else { + return .init(top: 0, left: defaultInset, bottom: 0, right: defaultInset) + } + } + //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- @@ -266,10 +267,30 @@ open class BadgeIndicator: View { backgroundColor = backgroundColorConfiguration.getColor(self) - label.useAttributedText = true - label.edgeInset = .init(top: 0, left: textSize.inset, bottom: 0, right: textSize.inset) - label.font = textSize.textStyle.font - label.textColor = textColorConfiguration.getColor(self) + //height width + heightConstraint?.isActive = false + widthConstraint?.isActive = false + if let width, let height { + heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: height) + widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: width) + } else { + heightConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + widthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + } + heightConstraint?.isActive = true + widthConstraint?.isActive = true + + //label constraints + let insets = labelEdgeInset + labelContraints.isActive = false + labelContraints.topConstraint?.constant = insets.top + labelContraints.bottomConstraint?.constant = -insets.bottom + labelContraints.leadingConstraint?.constant = insets.left + labelContraints.trailingConstraint?.constant = -insets.right + labelContraints.isActive = true + + //label properties + label.textStyle = size.textStyle label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() label.text = getText() label.surface = surface @@ -308,9 +329,6 @@ open class BadgeIndicator: View { open override func layoutSubviews() { super.layoutSubviews() - let size = textSize.textStyle.lineHeight - labelWidthConstraint?.constant = size - labelHeightConstraint?.constant = size layer.cornerRadius = frame.size.height / 2 if hideBorder { @@ -322,17 +340,19 @@ open class BadgeIndicator: View { layer.remove(layerName: "dot") if kind == .simple && !hideDot { - let dotSize: CGFloat = bounds.width * 0.1875 + var dot: CGFloat = bounds.width * 0.1875 + if let dotSize { + dot = dotSize + } let dotLayer = CAShapeLayer() dotLayer.name = "dot" - let centerX = (bounds.width - dotSize) / 2.0 - let centerY = (bounds.width - dotSize) / 2.0 + let centerX = (bounds.width - dot) / 2.0 + let centerY = (bounds.height - dot) / 2.0 - dotLayer.frame = .init(x: centerX, y: centerY, width: dotSize, height: dotSize) - dotLayer.path = UIBezierPath(ovalIn: .init(origin: .zero, size: .init(width: dotSize, height: dotSize))).cgPath + dotLayer.frame = .init(x: centerX, y: centerY, width: dot, height: dot) + dotLayer.path = UIBezierPath(ovalIn: .init(origin: .zero, size: .init(width: dot, height: dot))).cgPath dotLayer.fillColor = textColorConfiguration.getColor(self).cgColor - layer.addSublayer(dotLayer) } } From b6e7dcbadaeddeaea9b4cd814956822c3f99a0d4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 20 Jun 2023 14:21:11 -0500 Subject: [PATCH 6/7] refactored badge indicator to final specs Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 115 +++++++++++------- VDS/SupportingFiles/ReleaseNotes.txt | 6 +- 2 files changed, 77 insertions(+), 44 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 69ca0264..a1d7fed1 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -89,6 +89,21 @@ open class BadgeIndicator: View { letterSpacing: letterSpacing) } + public var edgeInset: UIEdgeInsets { + var horizontalPadding: CGFloat = VDSLayout.Spacing.space1X.value + let verticalPadding: CGFloat = 0 + + switch self { + case .xxlarge: + horizontalPadding = VDSLayout.Spacing.space2X.value + case .xlarge, .large,.medium: + horizontalPadding = 6.0 + case .small: + break + } + return .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) + } + } //-------------------------------------------------- @@ -149,12 +164,17 @@ open class BadgeIndicator: View { open var width: CGFloat? { didSet { setNeedsUpdate() }} open var height: CGFloat? { didSet { setNeedsUpdate() }} - + + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private let borderWidth: CGFloat = 1.0 + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- - private let layoutGuide = UILayoutGuide() - private var defaultBadgeSize: CGFloat { max(16.0, size.textStyle.font.lineHeight) } + private let badgeView = View() + private var badgeSize: CGFloat { max(16.0, size.textStyle.font.lineHeight) } private var widthConstraint: NSLayoutConstraint? private var heightConstraint: NSLayoutConstraint? private var labelContraints = NSLayoutConstraint.Container() @@ -166,28 +186,29 @@ open class BadgeIndicator: View { open override func setup() { super.setup() - addLayoutGuide(layoutGuide) - addSubview(label) + addSubview(badgeView) + badgeView.addSubview(label) accessibilityElements = [label] - heightConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + heightConstraint = badgeView.heightAnchor.constraint(greaterThanOrEqualToConstant: badgeSize) heightConstraint?.isActive = true - widthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + widthConstraint = badgeView.widthAnchor.constraint(greaterThanOrEqualToConstant: badgeSize) widthConstraint?.isActive = true + //we are insetting the padding to compensate for the border NSLayoutConstraint.activate([ - layoutGuide.topAnchor.constraint(equalTo: topAnchor, constant: 1), - layoutGuide.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -1), - layoutGuide.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 1), - layoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -1)]) + badgeView.topAnchor.constraint(equalTo: topAnchor, constant: borderWidth), + badgeView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -borderWidth), + badgeView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: borderWidth), + badgeView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -borderWidth)]) - labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: layoutGuide.topAnchor) - labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: layoutGuide.bottomAnchor) - labelContraints.leadingConstraint = label.pinLeadingGreaterThanOrEqualTo(anchor: layoutGuide.leadingAnchor) - labelContraints.trailingConstraint = label.pinTrailingGreaterThanOrEqualTo(anchor: layoutGuide.trailingAnchor) - label.centerXAnchor.constraint(equalTo: layoutGuide.centerXAnchor).isActive = true - label.centerYAnchor.constraint(equalTo: layoutGuide.centerYAnchor).isActive = true + labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: badgeView.topAnchor) + labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: badgeView.bottomAnchor) + labelContraints.leadingConstraint = label.pinLeadingGreaterThanOrEqualTo(anchor: badgeView.leadingAnchor) + labelContraints.trailingConstraint = label.pinTrailingGreaterThanOrEqualTo(anchor: badgeView.trailingAnchor) + label.centerXAnchor.constraint(equalTo: badgeView.centerXAnchor).isActive = true + label.centerYAnchor.constraint(equalTo: badgeView.centerYAnchor).isActive = true labelContraints.isActive = true } @@ -203,20 +224,18 @@ open class BadgeIndicator: View { shouldUpdateView = true setNeedsUpdate() } - - private let defaultInset = VDSLayout.Spacing.space1X.value - - private var labelEdgeInset: UIEdgeInsets { + private var labelEdgeInset: UIEdgeInsets { + var newInset = size.edgeInset if let verticalPadding, let horitonalPadding { - return .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding) + newInset = .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding) } else if let verticalPadding { - return .init(top: verticalPadding, left: defaultInset, bottom: verticalPadding, right: defaultInset) + newInset = .init(top: verticalPadding, left: newInset.left, bottom: verticalPadding, right: newInset.right) } else if let horitonalPadding { - return .init(top: defaultInset, left: horitonalPadding, bottom: defaultInset, right: horitonalPadding) - } else { - return .init(top: 0, left: defaultInset, bottom: 0, right: defaultInset) + newInset = .init(top: newInset.top, left: horitonalPadding, bottom: newInset.bottom, right: horitonalPadding) } + + return newInset } //-------------------------------------------------- @@ -265,17 +284,17 @@ open class BadgeIndicator: View { open override func updateView() { updateTextColorConfig() - backgroundColor = backgroundColorConfiguration.getColor(self) + badgeView.backgroundColor = backgroundColorConfiguration.getColor(self) //height width heightConstraint?.isActive = false widthConstraint?.isActive = false - if let width, let height { - heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: height) - widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: width) + if let width, let height, height > badgeSize, width > badgeSize, height <= width { + heightConstraint = badgeView.heightAnchor.constraint(equalToConstant: height) + widthConstraint = badgeView.widthAnchor.constraint(equalToConstant: width) } else { - heightConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) - widthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: defaultBadgeSize) + heightConstraint = badgeView.heightAnchor.constraint(greaterThanOrEqualToConstant: badgeSize) + widthConstraint = badgeView.widthAnchor.constraint(greaterThanOrEqualToConstant: badgeSize) } heightConstraint?.isActive = true widthConstraint?.isActive = true @@ -329,32 +348,42 @@ open class BadgeIndicator: View { open override func layoutSubviews() { super.layoutSubviews() - layer.cornerRadius = frame.size.height / 2 + //update the cornerRadius + badgeView.layer.cornerRadius = badgeView.frame.size.height / 2 + layer.cornerRadius = frame.size.height / 2 + + //border if hideBorder { layer.borderWidth = 0 } else { + layer.borderWidth = borderWidth layer.borderColor = borderColorConfiguration.getColor(surface).cgColor - layer.borderWidth = 1 } - layer.remove(layerName: "dot") + //dot + badgeView.layer.remove(layerName: "dot") if kind == .simple && !hideDot { - var dot: CGFloat = bounds.width * 0.1875 - if let dotSize { + //frame for the dot to sit inside + let frame = badgeView.frame + + //default calculation if a dotSize isn't given + var dot: CGFloat = frame.width * 0.1875 + if let dotSize, dotSize < frame.width, dotSize < frame.height { dot = dotSize } + + //get the center of the frame + let centerX = (frame.width - dot) / 2.0 + let centerY = (frame.height - dot) / 2.0 + + //create the layer to draw the dot let dotLayer = CAShapeLayer() dotLayer.name = "dot" - - let centerX = (bounds.width - dot) / 2.0 - let centerY = (bounds.height - dot) / 2.0 - dotLayer.frame = .init(x: centerX, y: centerY, width: dot, height: dot) dotLayer.path = UIBezierPath(ovalIn: .init(origin: .zero, size: .init(width: dot, height: dot))).cgPath dotLayer.fillColor = textColorConfiguration.getColor(self).cgColor - layer.addSublayer(dotLayer) + badgeView.layer.addSublayer(dotLayer) } } } - diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 858ac541..b983e954 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,4 +1,8 @@ -1.0.23 +1.0.25 +======= +- Added Size, Width, Height, Horizontal/Vertical Padding + more to Badge Indicator + +1.0.24 ======= - Added Badge Indicator - Refactored the TextStyle system to support Badge Indicator From 4ba642242ed133fcb8c39aead06cc7a5e3f64a10 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 20 Jun 2023 14:25:39 -0500 Subject: [PATCH 7/7] refactored name Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 8 ++++---- VDS/Fonts/{Fonts.swift => Font.swift} | 2 +- VDS/Typography/Typography.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename VDS/Fonts/{Fonts.swift => Font.swift} (93%) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 65ecb9e6..1a7114bf 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -37,7 +37,7 @@ EA3362072891E14D0071C351 /* VerizonNHGeDS-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */; }; EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622B2891E73B0071C351 /* FontProtocol.swift */; }; EA33622E2891EA3C0071C351 /* DispatchQueue+Once.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */; }; - EA3362302891EB4A0071C351 /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Fonts.swift */; }; + EA3362302891EB4A0071C351 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Font.swift */; }; EA33623E2892EE950071C351 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623D2892EE950071C351 /* UIDevice.swift */; }; EA3362402892EF6C0071C351 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623F2892EF6B0071C351 /* Label.swift */; }; EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; }; @@ -170,7 +170,7 @@ EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Regular.otf"; sourceTree = ""; }; EA33622B2891E73B0071C351 /* FontProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontProtocol.swift; sourceTree = ""; }; EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Once.swift"; sourceTree = ""; }; - EA33622F2891EB4A0071C351 /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = ""; }; + EA33622F2891EB4A0071C351 /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = ""; }; EA33623D2892EE950071C351 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = ""; }; EA33623F2892EF6B0071C351 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = ""; }; @@ -497,7 +497,7 @@ EA3361DF2891D0F10071C351 /* Fonts */ = { isa = PBXGroup; children = ( - EA33622F2891EB4A0071C351 /* Fonts.swift */, + EA33622F2891EB4A0071C351 /* Font.swift */, EA33622B2891E73B0071C351 /* FontProtocol.swift */, ); path = Fonts; @@ -945,7 +945,7 @@ EA33623E2892EE950071C351 /* UIDevice.swift in Sources */, EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */, EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */, - EA3362302891EB4A0071C351 /* Fonts.swift in Sources */, + EA3362302891EB4A0071C351 /* Font.swift in Sources */, EAF7F0AD289B142900B287F5 /* StrikeThroughLabelAttribute.swift in Sources */, EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */, EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */, diff --git a/VDS/Fonts/Fonts.swift b/VDS/Fonts/Font.swift similarity index 93% rename from VDS/Fonts/Fonts.swift rename to VDS/Fonts/Font.swift index 034e2b6f..57ad5962 100644 --- a/VDS/Fonts/Fonts.swift +++ b/VDS/Fonts/Font.swift @@ -7,7 +7,7 @@ import Foundation -public enum Fonts: String, FontProtocol { +public enum Font: String, FontProtocol { case dsBold case dsRegular case dsLight diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 167f378e..a89b75de 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -28,7 +28,7 @@ public struct TextStyle: Equatable, RawRepresentable { public let pointSize: CGFloat public let lineHeight: CGFloat public let letterSpacing: CGFloat - public let fontFace: Fonts + public let fontFace: Font public init?(rawValue: String) { guard let style = TextStyle.textStyle(for: rawValue) else { return nil } @@ -39,7 +39,7 @@ public struct TextStyle: Equatable, RawRepresentable { self.fontFace = style.fontFace } - public init(rawValue: String, fontFace: Fonts, pointSize: CGFloat, lineHeight: CGFloat, letterSpacing: CGFloat) { + public init(rawValue: String, fontFace: Font, pointSize: CGFloat = 0.0, lineHeight: CGFloat = 0.0, letterSpacing: CGFloat = 0.0) { self.rawValue = rawValue self.fontFace = fontFace self.pointSize = pointSize