From 190e29bbd267b845ef84944922a8a0eba54d7d21 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 09:35:27 -0500 Subject: [PATCH 1/5] removed padding now working on ratio of pointSize Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 3f202b01..6fa6d212 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -59,21 +59,6 @@ open class BadgeIndicator: View { case medium = "Medium" case small = "Small" - public var minimumSize: 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 padding: CGFloat { switch self { case .xxlarge: @@ -114,7 +99,7 @@ open class BadgeIndicator: View { return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator", fontFace: style.fontFace, pointSize: pointSize, - lineHeight: style.lineHeight, + lineHeight: pointSize * (16.0 / 12.0), letterSpacing: style.letterSpacing) } @@ -298,8 +283,9 @@ open class BadgeIndicator: View { open override func layoutSubviews() { super.layoutSubviews() - labelWidthConstraint?.constant = textSize.minimumSize - labelHeightConstraint?.constant = textSize.minimumSize + let size = textSize.textStyle.lineHeight + labelWidthConstraint?.constant = size + labelHeightConstraint?.constant = size layer.cornerRadius = frame.size.height / 2 if hideBorder { From c23b7fb79af2c6e90af1f1901915d9ba1670a054 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 14:59:45 -0500 Subject: [PATCH 2/5] public func Signed-off-by: Matt Bruce --- VDS/Extensions/NSLayoutAnchor.swift | 58 ------------------ VDS/Extensions/NSLayoutDimension.swift | 84 -------------------------- VDS/Extensions/UIView+CALayer.swift | 2 +- 3 files changed, 1 insertion(+), 143 deletions(-) delete mode 100644 VDS/Extensions/NSLayoutAnchor.swift delete mode 100644 VDS/Extensions/NSLayoutDimension.swift diff --git a/VDS/Extensions/NSLayoutAnchor.swift b/VDS/Extensions/NSLayoutAnchor.swift deleted file mode 100644 index 21c526e6..00000000 --- a/VDS/Extensions/NSLayoutAnchor.swift +++ /dev/null @@ -1,58 +0,0 @@ -// -// NSLayoutAnchor.swift -// VDS -// -// Created by Matt Bruce on 6/15/23. -// - -import Foundation -import UIKit - -//-------------------------------------------------- -// MARK: - NSLayoutAnchor -//-------------------------------------------------- -extension NSLayoutAnchor { - // These methods return an inactive constraint of the form thisAnchor = otherAnchor. - @discardableResult - @objc public func constraint(equalTo anchor: NSLayoutAnchor, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(equalTo: anchor) - constraint.identifier = identifier - return constraint - } - - @discardableResult - @objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutAnchor, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(greaterThanOrEqualTo: anchor) - constraint.identifier = identifier - return constraint - } - - @discardableResult - @objc public func constraint(lessThanOrEqualTo anchor: NSLayoutAnchor, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(lessThanOrEqualTo: anchor) - constraint.identifier = identifier - return constraint - } - - - @discardableResult - @objc public func constraint(equalTo anchor: NSLayoutAnchor, constant: CGFloat, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(equalTo: anchor, constant: constant) - constraint.identifier = identifier - return constraint - } - - @discardableResult - @objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutAnchor, constant: CGFloat, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(greaterThanOrEqualTo: anchor, constant: constant) - constraint.identifier = identifier - return constraint - } - - @discardableResult - @objc public func constraint(lessThanOrEqualTo anchor: NSLayoutAnchor, constant: CGFloat, identifier: String) -> NSLayoutConstraint { - let constraint = self.constraint(lessThanOrEqualTo: anchor, constant: constant) - constraint.identifier = identifier - return constraint - } -} diff --git a/VDS/Extensions/NSLayoutDimension.swift b/VDS/Extensions/NSLayoutDimension.swift deleted file mode 100644 index d8eacf79..00000000 --- a/VDS/Extensions/NSLayoutDimension.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// NSLayoutDimension.swift -// VDS -// -// Created by Matt Bruce on 6/15/23. -// - -import Foundation -import UIKit - -//-------------------------------------------------- -// MARK: - NSLayoutDimension -//-------------------------------------------------- -extension NSLayoutDimension { - // These methods return an inactive constraint of the form thisVariable = constant. - @discardableResult - @objc public func constraint(equalToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(equalToConstant: c) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(greaterThanOrEqualToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(greaterThanOrEqualToConstant: c) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(lessThanOrEqualToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(lessThanOrEqualToConstant: c) - lc.identifier = identifier - return lc - } - - - // These methods return an inactive constraint of the form thisAnchor = otherAnchor * multiplier. - @discardableResult - @objc public func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(equalTo: anchor, multiplier: m) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(greaterThanOrEqualTo: anchor ,multiplier: m) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(lessThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(lessThanOrEqualTo: anchor, multiplier: m) - lc.identifier = identifier - return lc - } - - - // These methods return an inactive constraint of the form thisAnchor = otherAnchor * multiplier + constant. - @discardableResult - @objc public func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(equalTo: anchor, multiplier: m, constant: c) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(greaterThanOrEqualTo: anchor, multiplier: m, constant: c) - lc.identifier = identifier - return lc - } - - @discardableResult - @objc public func constraint(lessThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint { - let lc = constraint(lessThanOrEqualTo: anchor, multiplier: m, constant: c) - lc.identifier = identifier - return lc - } - -} - diff --git a/VDS/Extensions/UIView+CALayer.swift b/VDS/Extensions/UIView+CALayer.swift index 2ad15363..a9525598 100644 --- a/VDS/Extensions/UIView+CALayer.swift +++ b/VDS/Extensions/UIView+CALayer.swift @@ -72,7 +72,7 @@ extension UIView { // MARK: - CALayer //-------------------------------------------------- extension CALayer { - func remove(layerName: String) { + public func remove(layerName: String) { guard let sublayers = sublayers else { return } From ab074a1cadd1910ec9b88c633775b9ff935a63a7 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 15:11:05 -0500 Subject: [PATCH 3/5] removed files Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 1f086e68..56d68602 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -107,8 +107,6 @@ EAC9258C2911C9DE00091998 /* InputField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAC925872911C9DE00091998 /* InputField.swift */; }; EAC9258F2911C9DE00091998 /* EntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAC9258B2911C9DE00091998 /* EntryField.swift */; }; EAD062A72A3B67770015965D /* UIView+CALayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062A62A3B67770015965D /* UIView+CALayer.swift */; }; - EAD062A92A3B67B10015965D /* NSLayoutAnchor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062A82A3B67B10015965D /* NSLayoutAnchor.swift */; }; - EAD062AB2A3B67D00015965D /* NSLayoutDimension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062AA2A3B67D00015965D /* NSLayoutDimension.swift */; }; EAD062B02A3B873E0015965D /* BadgeIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062AF2A3B873E0015965D /* BadgeIndicator.swift */; }; EAD8D2C128BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */; }; EAF1FE9929D4850E00101452 /* Clickable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF1FE9829D4850E00101452 /* Clickable.swift */; }; @@ -242,8 +240,6 @@ EAC925872911C9DE00091998 /* InputField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputField.swift; sourceTree = ""; }; EAC9258B2911C9DE00091998 /* EntryField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryField.swift; sourceTree = ""; }; EAD062A62A3B67770015965D /* UIView+CALayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+CALayer.swift"; sourceTree = ""; }; - EAD062A82A3B67B10015965D /* NSLayoutAnchor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutAnchor.swift; sourceTree = ""; }; - EAD062AA2A3B67D00015965D /* NSLayoutDimension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutDimension.swift; sourceTree = ""; }; EAD062AF2A3B873E0015965D /* BadgeIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeIndicator.swift; sourceTree = ""; }; EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIGestureRecognizer+Publisher.swift"; sourceTree = ""; }; EAF1FE9829D4850E00101452 /* Clickable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clickable.swift; sourceTree = ""; }; @@ -438,8 +434,6 @@ EAF7F0992899B17200B287F5 /* CATransaction.swift */, EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */, EABFEB632A26473700C4C106 /* NSAttributedString.swift */, - EAD062A82A3B67B10015965D /* NSLayoutAnchor.swift */, - EAD062AA2A3B67D00015965D /* NSLayoutDimension.swift */, EAB2376529E9952D00AABE9A /* UIApplication.swift */, EA3361A7288B23300071C351 /* UIColor.swift */, EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */, @@ -904,7 +898,6 @@ EA33624728931B050071C351 /* Initable.swift in Sources */, EAF7F0A4289B017C00B287F5 /* LabelAttributeModel.swift in Sources */, EA5F86D02A1F936100BC83E4 /* TabsContainer.swift in Sources */, - EAD062A92A3B67B10015965D /* NSLayoutAnchor.swift in Sources */, EAF7F0B1289B177F00B287F5 /* ColorLabelAttribute.swift in Sources */, EAC9258F2911C9DE00091998 /* EntryField.swift in Sources */, EAB1D2EA28AE84AA00DAE764 /* UIControlPublisher.swift in Sources */, @@ -949,7 +942,6 @@ EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */, EAB5FED429267EB300998C17 /* UIView.swift in Sources */, EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */, - EAD062AB2A3B67D00015965D /* NSLayoutDimension.swift in Sources */, EA33623E2892EE950071C351 /* UIDevice.swift in Sources */, EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */, EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */, From 49bae9c706a8572abcbd0ca709e6b3298c23579b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 15:28:13 -0500 Subject: [PATCH 4/5] added dynamic lineHeight Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 6fa6d212..4554f11f 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -59,25 +59,40 @@ open class BadgeIndicator: View { case medium = "Medium" case small = "Small" - public var padding: CGFloat { + 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 8 + return 29 case .xlarge: - return 6 + return 24 case .large: - return 6 + return 20 case .medium: - return 6 + return 18 case .small: - return 4 + return 16 } } public var textStyle: TextStyle { let style = TextStyle.bodySmall var pointSize: CGFloat = VDSTypography.fontSizeBody12 - switch self { case .xxlarge: pointSize = VDSTypography.fontSizeTitle24 @@ -95,11 +110,21 @@ open class BadgeIndicator: View { 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: pointSize * (16.0 / 12.0), + lineHeight: calculatedLineHeight, letterSpacing: style.letterSpacing) } @@ -242,7 +267,7 @@ open class BadgeIndicator: View { backgroundColor = backgroundColorConfiguration.getColor(self) label.useAttributedText = true - label.edgeInset = .init(top: 0, left: textSize.padding, bottom: 0, right: textSize.padding) + label.edgeInset = .init(top: 0, left: textSize.inset, bottom: 0, right: textSize.inset) label.font = textSize.textStyle.font label.textColor = textColorConfiguration.getColor(self) label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() From 735e061831c14e7ec5530cc88c44148fa65e1f85 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 15:35:44 -0500 Subject: [PATCH 5/5] updated version added release notes 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 56d68602..65ecb9e6 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1106,7 +1106,7 @@ buildSettings = { BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 22; + CURRENT_PROJECT_VERSION = 24; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1139,7 +1139,7 @@ buildSettings = { BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 22; + CURRENT_PROJECT_VERSION = 24; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index d65d120e..858ac541 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.23 +======= +- Added Badge Indicator +- Refactored the TextStyle system to support Badge Indicator + 1.0.22 ======= - CXTDT-423133 - Tabs - Indicator should overlap Border