From 4a93c882e659790066f83e023b0dc698d809fea9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 10:24:15 -0500 Subject: [PATCH 01/14] fixed constraints Signed-off-by: Matt Bruce --- VDS/Components/BadgeIndicator/BadgeIndicator.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 4ab72bb7..5356a6df 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -276,8 +276,12 @@ open class BadgeIndicator: View { widthConstraint = badgeView.widthGreaterThanEqualTo(constant: badgeSize) //we are insetting the padding to compensate for the border - badgeView.pinToSuperView(.init(top: borderWidth, left: borderWidth, bottom: borderWidth, right: borderWidth)) - + badgeView + .pinTop(borderWidth) + .pinLeading(borderWidth) + .pinTrailing(borderWidth, .defaultHigh) + .pinBottom(borderWidth, .defaultHigh) + labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: badgeView.topAnchor) labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: badgeView.bottomAnchor) labelContraints.leadingConstraint = label.pinLeadingGreaterThanOrEqualTo(anchor: badgeView.leadingAnchor) From f6e3960546bf4deca383ed07a5c5e8af662fc31a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 10:24:24 -0500 Subject: [PATCH 02/14] fixed constraints Signed-off-by: Matt Bruce --- VDS/Components/Icon/ButtonIcon/ButtonIcon.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index b3e7ecb9..85e0ae6e 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -264,7 +264,11 @@ open class ButtonIcon: Control { layoutGuideHeightConstraint = iconLayoutGuide.height(constant: size.containerSize) //pin layout guide - iconLayoutGuide.pinToSuperView() + iconLayoutGuide + .pinTop() + .pinLeading() + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) //determines the center point of the icon centerXConstraint = icon.centerXAnchor.constraint(equalTo: iconLayoutGuide.centerXAnchor, constant: 0) From 5d6bba44ba7223f7d5dd117e81d4662fdfde2d34 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 11:06:11 -0500 Subject: [PATCH 03/14] removed width = 100 Signed-off-by: Matt Bruce --- VDS/Components/Tilelet/Tilelet.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index c9feb0f1..657a735b 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -213,7 +213,6 @@ open class Tilelet: TileContainer { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() - width = 100 aspectRatio = .none color = .black addContentView(stackView) From c7393aee84d306ec7f166d9b8ca1d376b510afd0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 11:53:32 -0500 Subject: [PATCH 04/14] fixed issues with TileContainer Signed-off-by: Matt Bruce --- .../TileContainer/TileContainer.swift | 35 ++++++++++++------- VDS/Protocols/LayoutConstraintable.swift | 16 ++++----- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index ad0951e6..bad144e2 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -187,29 +187,40 @@ open class TileContainer: Control { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() + + let layoutGuide = UILayoutGuide() + addLayoutGuide(layoutGuide) + layoutGuide + .pinTop() + .pinLeading() + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + addSubview(backgroundImageView) addSubview(containerView) addSubview(highlightView) - - widthConstraint = widthAnchor.constraint(equalToConstant: 0) + + widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0) + widthConstraint?.priority = .defaultHigh - heightGreaterThanConstraint = heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0) + heightGreaterThanConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0) heightGreaterThanConstraint?.isActive = false - heightConstraint = heightAnchor.constraint(equalToConstant: 0) - - backgroundImageView.pinToSuperView() + heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: 0) + heightConstraint?.priority = .defaultHigh + + backgroundImageView.pin(layoutGuide) backgroundImageView.isUserInteractionEnabled = false backgroundImageView.isHidden = true - + containerView.backgroundColor = .clear - containerTopConstraint = containerView.pinTop(anchor: topAnchor, constant: padding.value) - containerBottomConstraint = containerView.pinBottom(anchor: bottomAnchor, constant: padding.value) - containerLeadingConstraint = containerView.pinLeading(anchor: leadingAnchor, constant: padding.value) - containerTrailingConstraint = containerView.pinTrailing(anchor: trailingAnchor, constant: padding.value) + containerTopConstraint = containerView.pinTop(anchor: layoutGuide.topAnchor, constant: padding.value) + containerBottomConstraint = containerView.pinBottom(anchor: layoutGuide.bottomAnchor, constant: padding.value) + containerLeadingConstraint = containerView.pinLeading(anchor: layoutGuide.leadingAnchor, constant: padding.value) + containerTrailingConstraint = containerView.pinTrailing(anchor: layoutGuide.trailingAnchor, constant: padding.value) - highlightView.pinToSuperView() + highlightView.pin(layoutGuide) highlightView.isHidden = true highlightView.backgroundColor = .clear diff --git a/VDS/Protocols/LayoutConstraintable.swift b/VDS/Protocols/LayoutConstraintable.swift index ceededbc..3c05bbc7 100644 --- a/VDS/Protocols/LayoutConstraintable.swift +++ b/VDS/Protocols/LayoutConstraintable.swift @@ -31,19 +31,19 @@ extension LayoutConstraintable { @discardableResult /// Pins each to the all 4 anchor points to a view. /// - Parameters: - /// - view: View that you will be pinned within. + /// - layoutConstrainable: LayoutConstrainable 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) - pinTop(view.topAnchor, edges.top) - pinBottom(view.bottomAnchor, edges.bottom) + public func pin(_ layoutConstrainable: LayoutConstraintable, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { + pinLeading(layoutConstrainable.leadingAnchor, edges.left) + pinTrailing(layoutConstrainable.trailingAnchor, edges.right) + pinTop(layoutConstrainable.topAnchor, edges.top) + pinBottom(layoutConstrainable.bottomAnchor, edges.bottom) return self } - + + @discardableResult - /// Pins each to the all 4 anchor points to the view you are set within. /// - Parameter edges: Insets for each side. /// - Returns: Yourself. From a4259419737e0e3bfe39f8ec3047c635a77eed75 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 15:14:35 -0500 Subject: [PATCH 05/14] ONEAPP-4684 - Acessibility - Tooltip Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/Tooltip.swift | 4 ++-- VDS/Components/Tooltip/TooltipDialog.swift | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index b8ce0bf6..679c260e 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -177,9 +177,9 @@ open class Tooltip: Control, TooltipLaunchable { if let label, !label.isEmpty { accessibilityLabel = label } else { - accessibilityLabel = "Tooltip" + accessibilityLabel = "Modal" } - accessibilityHint = isEnabled ? "Click to open Tooltip." : "" + accessibilityHint = isEnabled ? "Double tap to open." : "" accessibilityValue = "collapsed" } diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index c80b8637..5480c8c5 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -46,7 +46,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { } lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { - $0.accessibilityLabel = "Tooltip" + $0.accessibilityLabel = "Modal" $0.accessibilityValue = "expanded" $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) } @@ -181,10 +181,12 @@ open class TooltipDialog: View, UIScrollViewDelegate { } let wrapper = View() wrapper.addSubview(contentView) - contentView.pinTop() - contentView.pinLeading() - contentView.pinBottom() - contentView.pinTrailingLessThanOrEqualTo() + contentView + .pinTop() + .pinLeading() + .pinBottom() + .pinTrailingLessThanOrEqualTo() + contentView.setNeedsLayout() contentStackView.addArrangedSubview(wrapper) addedContent = true @@ -232,7 +234,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { open override func updateAccessibility() { super.updateAccessibility() - primaryAccessibilityElement.accessibilityHint = "Click on the \(closeButtonText) button to close." + primaryAccessibilityElement.accessibilityHint = "Double tap on the \(closeButtonText) button to close." var elements: [Any] = [primaryAccessibilityElement] contentStackView.arrangedSubviews.forEach{ elements.append($0) } From 18ff68e76e1f36f8a9a8bc56f8410915696e9890 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 15:50:12 -0500 Subject: [PATCH 06/14] updated radioboxitem Signed-off-by: Matt Bruce --- VDS/Components/RadioBox/RadioBoxItem.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 71cf2c2e..28a54f5a 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -194,7 +194,12 @@ open class RadioBoxItem: Control, Changeable, FormFieldable { selectorLeftLabelStackView.addArrangedSubview(textLabel) selectorLeftLabelStackView.addArrangedSubview(subTextLabel) - selectorView.pinToSuperView() + selectorView + .pinTop() + .pinLeading() + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + mainStackView.pinToSuperView(.init(top: 16, left: 16, bottom: 16, right: 16)) } From 5ff8d2f06e4fcf82896e657fab1c43082ef53d5c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 16:39:16 -0500 Subject: [PATCH 07/14] fixed bug in radiobutton group Signed-off-by: Matt Bruce --- VDS/BaseClasses/Selector/SelectorGroupBase.swift | 6 +++++- VDS/BaseClasses/Selector/SelectorItemBase.swift | 6 +++++- VDS/Components/RadioButton/RadioButtonGroup.swift | 12 ------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/VDS/BaseClasses/Selector/SelectorGroupBase.swift b/VDS/BaseClasses/Selector/SelectorGroupBase.swift index 5c6cacef..1543ba8d 100644 --- a/VDS/BaseClasses/Selector/SelectorGroupBase.swift +++ b/VDS/BaseClasses/Selector/SelectorGroupBase.swift @@ -106,7 +106,11 @@ open class SelectorGroupBase: Control, SelectorGroup, super.setup() addSubview(mainStackView) - mainStackView.pinToSuperView() + mainStackView + .pinTop() + .pinLeading() + .pinTrailing() + .pinBottom(0, .defaultHigh) } /// Handler for the Group to override on a select event. diff --git a/VDS/BaseClasses/Selector/SelectorItemBase.swift b/VDS/BaseClasses/Selector/SelectorItemBase.swift index 1745ae65..9ca86d8c 100644 --- a/VDS/BaseClasses/Selector/SelectorItemBase.swift +++ b/VDS/BaseClasses/Selector/SelectorItemBase.swift @@ -178,7 +178,11 @@ open class SelectorItemBase: Control, Errorable, selectorStackView.addArrangedSubview(selectorLabelStackView) selectorLabelStackView.addArrangedSubview(label) selectorLabelStackView.addArrangedSubview(childLabel) - mainStackView.pinToSuperView() + mainStackView + .pinTop() + .pinLeading() + .pinTrailing() + .pinBottom(0, .defaultHigh) } /// Used to make changes to the View based off a change events or from local properties. diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index c0d7a433..c33a376e 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -73,18 +73,6 @@ open class RadioButtonGroup: SelectorGroupBase, SelectorGroupSi } } - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. - open override func setup() { - super.setup() - - addSubview(mainStackView) - - mainStackView.pinToSuperView() - } - public override func didSelect(_ selectedControl: RadioButtonItem) { if let selectedItem { updateToggle(selectedItem) From 01a177f64355d69226d13fcf0bd91e50f29bba61 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 31 Aug 2023 16:56:48 -0500 Subject: [PATCH 08/14] fixed notification issues Signed-off-by: Matt Bruce --- .../Notification/Notification.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index f51d9f11..724620a8 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -221,15 +221,24 @@ open class Notification: View { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() - addSubview(mainStackView) - mainStackView.pinToSuperView(.init(top: edgeSpacing, left: edgeSpacing, bottom: edgeSpacing, right: edgeSpacing)) + let layoutGuide = UILayoutGuide() + addLayoutGuide(layoutGuide) + layoutGuide + .pinTop(0) + .pinLeading(0) + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + + addSubview(mainStackView) + mainStackView.pin(layoutGuide, with: .init(top: edgeSpacing, left: edgeSpacing, bottom: edgeSpacing, right: edgeSpacing)) + NSLayoutConstraint.activate([ - heightAnchor.constraint(greaterThanOrEqualToConstant: minViewHeight), + layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: minViewHeight), mainStackView.heightAnchor.constraint(greaterThanOrEqualToConstant: minContentHeight), - widthAnchor.constraint(greaterThanOrEqualToConstant: minViewWidth) + layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: minViewWidth) ]) - maxWidthConstraint = widthAnchor.constraint(lessThanOrEqualToConstant: maxViewWidth) + maxWidthConstraint = layoutGuide.widthAnchor.constraint(lessThanOrEqualToConstant: maxViewWidth) labelButtonView.addArrangedSubview(labelsView) From 469200270ac776812d23be461f0e0cd774eb62fc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 5 Sep 2023 11:47:20 -0500 Subject: [PATCH 09/14] added extension Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 +++ VDS/Extensions/UIEdgeInsets.swift | 49 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 VDS/Extensions/UIEdgeInsets.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 7495635c..99b17753 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ EA0B18022A9E236900F2D0CD /* SelectorGroupBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0B18012A9E236900F2D0CD /* SelectorGroupBase.swift */; }; EA0B18052A9E2D2D00F2D0CD /* SelectorBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0B18032A9E2D2D00F2D0CD /* SelectorBase.swift */; }; EA0B18062A9E2D2D00F2D0CD /* SelectorItemBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0B18042A9E2D2D00F2D0CD /* SelectorItemBase.swift */; }; + EA0B180A2AA78F9000F2D0CD /* UIEdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0B18092AA78F9000F2D0CD /* UIEdgeInsets.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 */; }; @@ -160,6 +161,7 @@ EA0B18012A9E236900F2D0CD /* SelectorGroupBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectorGroupBase.swift; sourceTree = ""; }; EA0B18032A9E2D2D00F2D0CD /* SelectorBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectorBase.swift; sourceTree = ""; }; EA0B18042A9E2D2D00F2D0CD /* SelectorItemBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectorItemBase.swift; sourceTree = ""; }; + EA0B18092AA78F9000F2D0CD /* UIEdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIEdgeInsets.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 = ""; }; @@ -478,6 +480,7 @@ EA3361A7288B23300071C351 /* UIColor.swift */, EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */, EA33623D2892EE950071C351 /* UIDevice.swift */, + EA0B18092AA78F9000F2D0CD /* UIEdgeInsets.swift */, EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */, EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */, EAB5FED329267EB300998C17 /* UIView+NSLayoutConstraint.swift */, @@ -982,6 +985,7 @@ EAF978212A99035B00C2FEA9 /* Enabling.swift in Sources */, EA5E3058295105A40082B959 /* Tilelet.swift in Sources */, EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */, + EA0B180A2AA78F9000F2D0CD /* UIEdgeInsets.swift in Sources */, EA985C1D296CD13600F2FF2E /* BundleManager.swift in Sources */, EA0B18052A9E2D2D00F2D0CD /* SelectorBase.swift in Sources */, EAC71A1D2A2E155A00E47A9F /* Checkbox.swift in Sources */, diff --git a/VDS/Extensions/UIEdgeInsets.swift b/VDS/Extensions/UIEdgeInsets.swift new file mode 100644 index 00000000..650a6d16 --- /dev/null +++ b/VDS/Extensions/UIEdgeInsets.swift @@ -0,0 +1,49 @@ +// +// UIEdgeInset.swift +// VDS +// +// Created by Matt Bruce on 9/5/23. +// + +import Foundation +import UIKit + +extension UIEdgeInsets { + + public static func uniform(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: value, left: value, bottom: value, right: value) + } + + public static func top(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: value, left: 0, bottom: 0, right: 0) + } + + public static func left(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: value, bottom: 0, right: 0) + } + + public static func bottom(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 0, bottom: value, right: 0) + } + + public static func right(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: value) + } + + public static func horizontal(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: value, bottom: 0, right: value) + } + + public static func vertical(_ value: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: value, left: 0, bottom: value, right: 0) + } + + public static func axis(horizontal: CGFloat, vertical: CGFloat) -> UIEdgeInsets { + return UIEdgeInsets(top: vertical, left: horizontal, bottom: vertical, right: horizontal) + } + +} + +public func + (lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> UIEdgeInsets { + return .init(top: lhs.top + rhs.top, left: lhs.left + rhs.left, bottom: lhs.bottom + rhs.bottom, right: lhs.right + rhs.right) +} From 945fbc05dc9463b6bc8a870bc4d1503221287a26 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 5 Sep 2023 11:47:44 -0500 Subject: [PATCH 10/14] refactored to use extension Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 13 ++++---- .../Notification/Notification.swift | 2 +- VDS/Components/RadioBox/RadioBoxItem.swift | 2 +- .../TextFields/EntryFieldBase.swift | 10 ++++--- VDS/Typography/Typogprahy+Styles.swift | 30 ++++++++----------- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 5356a6df..45432458 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -126,7 +126,7 @@ open class BadgeIndicator: View { case .small: break } - return .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) + return .axis(horizontal: horizontalPadding, vertical: verticalPadding) } } @@ -193,7 +193,7 @@ open class BadgeIndicator: View { open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() } } /// Sets the padding at the left/right of the label. - open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() } } + open var horizontalPadding: CGFloat? { didSet { setNeedsUpdate() } } /// Hides the dot when you are in Kind.simple mode. open var hideDot: Bool = false { didSet { setNeedsUpdate() } } @@ -217,12 +217,13 @@ open class BadgeIndicator: View { private var badgeSize: CGFloat { max(minSize, size.textStyle.font.lineHeight) } private var labelEdgeInset: UIEdgeInsets { var newInset = size.edgeInset - if let verticalPadding, let horitonalPadding { - newInset = .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding) + if let verticalPadding, let horizontalPadding { + newInset = .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) + newInset = .axis(horizontal: horizontalPadding, vertical: verticalPadding) } else if let verticalPadding { newInset = .init(top: verticalPadding, left: newInset.left, bottom: verticalPadding, right: newInset.right) - } else if let horitonalPadding { - newInset = .init(top: newInset.top, left: horitonalPadding, bottom: newInset.bottom, right: horitonalPadding) + } else if let horizontalPadding { + newInset = .init(top: newInset.top, left: horizontalPadding, bottom: newInset.bottom, right: horizontalPadding) } return newInset diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 724620a8..274ad8af 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -231,7 +231,7 @@ open class Notification: View { .pinBottom(0, .defaultHigh) addSubview(mainStackView) - mainStackView.pin(layoutGuide, with: .init(top: edgeSpacing, left: edgeSpacing, bottom: edgeSpacing, right: edgeSpacing)) + mainStackView.pin(layoutGuide, with: .uniform(edgeSpacing)) NSLayoutConstraint.activate([ layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: minViewHeight), diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 28a54f5a..81f3f709 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -200,7 +200,7 @@ open class RadioBoxItem: Control, Changeable, FormFieldable { .pinTrailing(0, .defaultHigh) .pinBottom(0, .defaultHigh) - mainStackView.pinToSuperView(.init(top: 16, left: 16, bottom: 16, right: 16)) + mainStackView.pinToSuperView(.uniform(16)) } /// Resets to default settings. diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index 8404afb2..f62e0694 100644 --- a/VDS/Components/TextFields/EntryFieldBase.swift +++ b/VDS/Components/TextFields/EntryFieldBase.swift @@ -189,10 +189,12 @@ open class EntryFieldBase: Control, Changeable { //create the wrapping view heightConstraint = containerView.heightAnchor.constraint(greaterThanOrEqualToConstant: containerSize.height) + widthConstraint?.priority = .defaultHigh heightConstraint?.isActive = true widthConstraint = containerView.widthAnchor.constraint(equalToConstant: 0) - + widthConstraint?.priority = .defaultHigh + //get the container this is what is color //border, internal, etc... let container = getContainer() @@ -201,7 +203,7 @@ open class EntryFieldBase: Control, Changeable { //this is the horizontal stack that contains //the left, InputContainer, Icons, Buttons container.addSubview(containerStackView) - containerStackView.pinToSuperView(.init(top: 12, left: 12, bottom: 12, right: 12)) + containerStackView.pinToSuperView(.uniform(12)) //add the view to add input fields containerStackView.addArrangedSubview(controlContainerView) @@ -218,9 +220,9 @@ open class EntryFieldBase: Control, Changeable { stackView .pinTop() - .pinBottom() .pinLeading() - .trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor).isActive = true + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) titleLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index e278646d..ec144617 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -17,79 +17,79 @@ extension TextStyle { fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) + edgeInsets: .bottom(UIDevice.isIPad ? -6: -4)) 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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) + edgeInsets: .bottom(UIDevice.isIPad ? -6: -4)) public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) + edgeInsets: .bottom(UIDevice.isIPad ? -6: -2)) 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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) + edgeInsets: .bottom(UIDevice.isIPad ? -6: -2)) public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) + edgeInsets: .bottom(UIDevice.isIPad ? -4: -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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) + edgeInsets: .bottom(UIDevice.isIPad ? -4: -2)) public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .bottom(UIDevice.isIPad ? -2: 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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .bottom(UIDevice.isIPad ? -2: 0)) public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .bottom(UIDevice.isIPad ? -2: 0)) public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", fontFace: .edsBold, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .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, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + edgeInsets: .bottom(UIDevice.isIPad ? -2: 0)) public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge", fontFace: .edsBold, @@ -211,12 +211,6 @@ extension TextStyle { } } -extension UIEdgeInsets { - public init(bottom: CGFloat) { - self.init(top: 0, left: 0, bottom: bottom, right: 0) - } -} - extension TextStyle { /// Enum used to describe the naming convention for the Typography. public enum StandardStyle: String, CaseIterable { From 1d010d69eaba4f97880f517722de9b80ae84a816 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 5 Sep 2023 11:47:58 -0500 Subject: [PATCH 11/14] fixed bug for priority on layout Signed-off-by: Matt Bruce --- VDS/Components/TextFields/InputField/InputField.swift | 7 ++++++- VDS/Components/TextFields/TextArea/TextArea.swift | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 1f891b70..94ef5231 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -129,7 +129,12 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { minWidthConstraint?.isActive = true controlContainerView.addSubview(textField) - textField.pinToSuperView() + textField + .pinTop() + .pinLeading() + .pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh) + .pinBottom(0, .defaultHigh) + textField.heightAnchor.constraint(equalToConstant: 20).isActive = true textField .textPublisher diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 69bacccd..7d70cb44 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -76,7 +76,12 @@ open class TextArea: EntryFieldBase { minWidthConstraint?.isActive = true controlContainerView.addSubview(textView) - textView.pinToSuperView() + textView + .pinTop() + .pinLeading() + .pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh) + .pinBottom(0, .defaultHigh) + textViewHeightConstraint = textView.heightAnchor.constraint(greaterThanOrEqualToConstant: 64) textViewHeightConstraint?.isActive = true backgroundColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success) From dfa81934e6662ed186a855d3014f56829afa8918 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 6 Sep 2023 08:51:41 -0500 Subject: [PATCH 12/14] updated with multiplier Signed-off-by: Matt Bruce --- VDS/Components/Toggle/ToggleView.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 8b817e28..b6802c58 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -191,20 +191,22 @@ open class ToggleView: Control, Changeable, FormFieldable { shadowLayer1.frame = knobView.bounds shadowLayer2.frame = knobView.bounds + let shadow1Opacity: Float = 0.24 + let shadow2Opacity: Float = 0.08 + let disabledMultiplier: Float = 0.75 - let shadowColor = isEnabled ? VDSColor.paletteBlack.cgColor : VDSColor.paletteGray95.cgColor + let shadowColor = VDSColor.paletteBlack.cgColor shadowLayer1.cornerRadius = knobView.layer.cornerRadius shadowLayer1.shadowColor = shadowColor - shadowLayer1.shadowOpacity = isEnabled ? 0.24 : 0.1 + shadowLayer1.shadowRadius = 10.0 shadowLayer1.shadowOffset = .init(width: 0, height: 1) - shadowLayer1.shadowRadius = isEnabled ? 5.0 : 10.0 + shadowLayer1.shadowOpacity = isEnabled ? shadow1Opacity : shadow1Opacity * disabledMultiplier shadowLayer2.cornerRadius = knobView.layer.cornerRadius shadowLayer2.shadowColor = shadowColor - shadowLayer2.shadowOpacity = isEnabled ? 0.08 : 0.04 - shadowLayer2.shadowOffset = .init(width: 0, height: 2) shadowLayer2.shadowRadius = 2.0 - + shadowLayer2.shadowOffset = .init(width: 0, height: 2) + shadowLayer2.shadowOpacity = isEnabled ? shadow2Opacity : shadow2Opacity * disabledMultiplier } //-------------------------------------------------- From 035f7fac1edd69f6ffeadbace3e1d3ac56cd25db Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 6 Sep 2023 09:02:46 -0500 Subject: [PATCH 13/14] reverted back to 50% Signed-off-by: Matt Bruce --- VDS/Components/Toggle/ToggleView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index b6802c58..7586553e 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -193,7 +193,7 @@ open class ToggleView: Control, Changeable, FormFieldable { shadowLayer2.frame = knobView.bounds let shadow1Opacity: Float = 0.24 let shadow2Opacity: Float = 0.08 - let disabledMultiplier: Float = 0.75 + let disabledMultiplier: Float = 0.50 let shadowColor = VDSColor.paletteBlack.cgColor shadowLayer1.cornerRadius = knobView.layer.cornerRadius From 14f4778658b8442e527f7cb8d6b3784923a7a6ef Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 6 Sep 2023 12:58:53 -0500 Subject: [PATCH 14/14] reverted to hard numbers Signed-off-by: Matt Bruce --- VDS/Components/Toggle/ToggleView.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 7586553e..f4d257d5 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -191,22 +191,20 @@ open class ToggleView: Control, Changeable, FormFieldable { shadowLayer1.frame = knobView.bounds shadowLayer2.frame = knobView.bounds - let shadow1Opacity: Float = 0.24 - let shadow2Opacity: Float = 0.08 - let disabledMultiplier: Float = 0.50 - + let shadowColor = VDSColor.paletteBlack.cgColor shadowLayer1.cornerRadius = knobView.layer.cornerRadius shadowLayer1.shadowColor = shadowColor shadowLayer1.shadowRadius = 10.0 shadowLayer1.shadowOffset = .init(width: 0, height: 1) - shadowLayer1.shadowOpacity = isEnabled ? shadow1Opacity : shadow1Opacity * disabledMultiplier + shadowLayer1.shadowOpacity = isEnabled ? 0.24 : 0.12 shadowLayer2.cornerRadius = knobView.layer.cornerRadius shadowLayer2.shadowColor = shadowColor shadowLayer2.shadowRadius = 2.0 shadowLayer2.shadowOffset = .init(width: 0, height: 2) - shadowLayer2.shadowOpacity = isEnabled ? shadow2Opacity : shadow2Opacity * disabledMultiplier + shadowLayer2.shadowOpacity = isEnabled ? 0.08 : 0.04 + } //--------------------------------------------------