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) + } + +} 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 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, 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 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() + } + }) } } }