From 3e812cb4a15c471262bf4d7eed1b922213c4dd4d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 2 May 2023 09:20:35 -0500 Subject: [PATCH 1/5] updated tooltip to use subset enums of Icon Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/Tooltip.swift | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 022da1d1..316c87bb 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -21,21 +21,11 @@ open class Tooltip: Control, TooltipLaunchable { case primary, secondary, brandHighlight } - public enum Size: String, CaseIterable { + public enum Size: String, EnumSubset { case small case medium - public var dimensions: CGSize { - switch self { - - case .small: - return .init(width: 13.33, height: 13.33) - - case .medium: - return .init(width: 16.67, height: 16.67) - - } - } + public var defaultValue: Icon.Size { .small } } //-------------------------------------------------- @@ -126,9 +116,9 @@ open class Tooltip: Control, TooltipLaunchable { addSubview(imageView) imageView.pinToSuperView() - heightConstraint = imageView.heightAnchor.constraint(equalToConstant: size.dimensions.height) + heightConstraint = imageView.heightAnchor.constraint(equalToConstant: size.value.dimensions.height) heightConstraint?.isActive = true - widthConstraint = imageView.widthAnchor.constraint(equalToConstant: size.dimensions.width) + widthConstraint = imageView.widthAnchor.constraint(equalToConstant: size.value.dimensions.width) widthConstraint?.isActive = true backgroundColor = .clear @@ -160,7 +150,7 @@ open class Tooltip: Control, TooltipLaunchable { super.updateView() //set the dimensions - let dimensions = size.dimensions + let dimensions = size.value.dimensions heightConstraint?.constant = dimensions.height widthConstraint?.constant = dimensions.width From d77e1abc34f86054ad2f38992e47a33d798cc15d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 2 May 2023 09:20:53 -0500 Subject: [PATCH 2/5] updated with tooltip size change Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/TooltipLabelAttribute.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift index e6047dd0..aed3556a 100644 --- a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift @@ -45,7 +45,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable attributedString.insert(NSAttributedString(string: spaceForTooltip), at: location) //create the frame in which to hold the icon - let frame = CGRect(x: 0, y: 0, width: size.dimensions.width, height: size.dimensions.width) + let frame = CGRect(x: 0, y: 0, width: size.value.dimensions.width, height: size.value.dimensions.width) //create the image icon and match the color of the text let tooltipAttribute = ImageLabelAttribute(location: location + middle, From 31975f4e19cf324640ed4a047d43b992806fbf6c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 2 May 2023 09:21:00 -0500 Subject: [PATCH 3/5] added customsize Signed-off-by: Matt Bruce --- VDS/Components/Icon/Icon.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 74e4f854..e6443eaa 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -31,6 +31,7 @@ open class Icon: View { open var color: Color = .black { didSet { didChange() }} open var size: Size = .medium { didSet { didChange() }} open var name: Name? { didSet { didChange() }} + open var customSize: Int? { didSet { didChange() }} //functions //-------------------------------------------------- @@ -76,7 +77,12 @@ open class Icon: View { } //set the icon dimensions - let dimensions = size.dimensions + var dimensions = size.dimensions + + if let customSize { + dimensions = .init(width: customSize, height: customSize) + } + heightConstraint?.constant = dimensions.height widthConstraint?.constant = dimensions.width From 30951b6fc0487a4ff8d520562a07c002daed0b22 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 2 May 2023 11:29:56 -0500 Subject: [PATCH 4/5] updated debug layer Signed-off-by: Matt Bruce --- VDS/Extensions/UIView.swift | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/VDS/Extensions/UIView.swift b/VDS/Extensions/UIView.swift index 951cbbf5..74dfa59f 100644 --- a/VDS/Extensions/UIView.swift +++ b/VDS/Extensions/UIView.swift @@ -122,11 +122,37 @@ extension UIView { extension UIView { public func debugBorder(show shouldShow: Bool = true, color: UIColor = .red) { if shouldShow { - layer.borderColor = color.cgColor - layer.borderWidth = VDSFormControls.widthBorder + let borderLayer = CALayer() + borderLayer.name = "debugAreaLayer" + borderLayer.frame = bounds + borderLayer.bounds = bounds + borderLayer.borderWidth = VDSFormControls.widthBorder + borderLayer.borderColor = color.cgColor + layer.addSublayer(borderLayer) + + if type(of: self) is AppleGuidlinesTouchable.Type { + let faultToleranceX: CGFloat = max((45 - bounds.size.width) / 2.0, 0) + let faultToleranceY: CGFloat = max((45 - bounds.size.height) / 2.0, 0) + + let touchableAreaPath = UIBezierPath(rect: bounds.insetBy(dx: -faultToleranceX, dy: -faultToleranceY)) + let touchLayer = CAShapeLayer() + touchLayer.path = touchableAreaPath.cgPath + touchLayer.strokeColor = color.cgColor + touchLayer.fillColor = UIColor.clear.cgColor + touchLayer.lineWidth = VDSFormControls.widthBorder + touchLayer.opacity = 1.0 + touchLayer.name = "debugTouchableAreaLayer" + touchLayer.zPosition = 100 + touchLayer.frame = bounds + touchLayer.bounds = bounds + layer.addSublayer(touchLayer) + } } else { - layer.borderColor = UIColor.clear.cgColor - layer.borderWidth = 0 + layer.sublayers?.forEach({ layer in + if layer.name?.hasPrefix("debug") ?? false { + layer.removeFromSuperlayer() + } + }) } } } From 8fb60fde03843fbddf2fc2bf0286a353f66c5b4e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 2 May 2023 11:30:04 -0500 Subject: [PATCH 5/5] added touchable to button Signed-off-by: Matt Bruce --- VDS/Components/Buttons/Button/ButtonBase.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index cafd5cd8..bd00e312 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -238,3 +238,12 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab } } + +// MARK: AppleGuidlinesTouchable +extension ButtonBase: AppleGuidlinesTouchable { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + Self.acceptablyOutsideBounds(point: point, bounds: bounds) + } + +}