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/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 471e9b99..48b0717b 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/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index dcbc6ebd..ce01e5e8 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 { if oldValue != verticalPadding { setNeedsUpdate() } } } /// Sets the padding at the left/right of the label. - open var horitonalPadding: CGFloat? { didSet { if oldValue != horitonalPadding { setNeedsUpdate() } } } + open var horizontalPadding: CGFloat? { didSet { if oldValue != horizontalPadding { setNeedsUpdate() } } } /// Hides the dot when you are in Kind.simple mode. open var hideDot: Bool = false { didSet { if oldValue != hideDot { 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 59f568da..0e2920f9 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: .uniform(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) diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 9487d78a..86700e98 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -194,8 +194,13 @@ open class RadioBoxItem: Control, Changeable, FormFieldable { selectorLeftLabelStackView.addArrangedSubview(textLabel) selectorLeftLabelStackView.addArrangedSubview(subTextLabel) - selectorView.pinToSuperView() - mainStackView.pinToSuperView(.init(top: 16, left: 16, bottom: 16, right: 16)) + selectorView + .pinTop() + .pinLeading() + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + + mainStackView.pinToSuperView(.uniform(16)) } /// Resets to default settings. 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) diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index 07946eac..c5fb31a6 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/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index f18f28a1..da4fa1ec 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) diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index c1ebc0c8..75fed64d 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/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 1438ab32..cf5b63af 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) diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 6c072852..e8eef7ae 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -191,20 +191,20 @@ open class ToggleView: Control, Changeable, FormFieldable { shadowLayer1.frame = knobView.bounds shadowLayer2.frame = knobView.bounds - - 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 ? 0.24 : 0.12 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 ? 0.08 : 0.04 + } //-------------------------------------------------- diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index f1bc227c..1f725f2a 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 f77c9613..b5163fc2 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) } 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) +} 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. 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 {