diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 60401872..28bf12a8 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -25,7 +25,7 @@ EA0D1C452A6AD73000E5C127 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C442A6AD73000E5C127 /* RawRepresentable.swift */; }; EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */; }; EA297A5529FB07760031ED56 /* TooltipLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA297A5429FB07760031ED56 /* TooltipLabelAttribute.swift */; }; - EA297A5729FB0A360031ED56 /* AppleGuidlinesTouchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA297A5629FB0A360031ED56 /* AppleGuidlinesTouchable.swift */; }; + EA297A5729FB0A360031ED56 /* AppleGuidelinesTouchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA297A5629FB0A360031ED56 /* AppleGuidelinesTouchable.swift */; }; EA336171288B19200071C351 /* VDS.docc in Sources */ = {isa = PBXBuildFile; fileRef = EA336170288B19200071C351 /* VDS.docc */; }; EA336177288B19210071C351 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA33616C288B19200071C351 /* VDS.framework */; }; EA33617C288B19210071C351 /* VDSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33617B288B19210071C351 /* VDSTests.swift */; }; @@ -170,7 +170,7 @@ EA0D1C442A6AD73000E5C127 /* RawRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawRepresentable.swift; sourceTree = ""; }; EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroup.swift; sourceTree = ""; }; EA297A5429FB07760031ED56 /* TooltipLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipLabelAttribute.swift; sourceTree = ""; }; - EA297A5629FB0A360031ED56 /* AppleGuidlinesTouchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidlinesTouchable.swift; sourceTree = ""; }; + EA297A5629FB0A360031ED56 /* AppleGuidelinesTouchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesTouchable.swift; sourceTree = ""; }; EA33616C288B19200071C351 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EA33616F288B19200071C351 /* VDS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VDS.h; sourceTree = ""; }; EA336170288B19200071C351 /* VDS.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = VDS.docc; sourceTree = ""; }; @@ -493,7 +493,7 @@ isa = PBXGroup; children = ( EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */, - EA297A5629FB0A360031ED56 /* AppleGuidlinesTouchable.swift */, + EA297A5629FB0A360031ED56 /* AppleGuidelinesTouchable.swift */, EAF1FE9A29DB1A6000101452 /* Changeable.swift */, EAF1FE9829D4850E00101452 /* Clickable.swift */, EAA5EEDF28F49DB3003B3210 /* Colorable.swift */, @@ -908,7 +908,7 @@ EA0D1C3F2A6AD5E200E5C127 /* Typography+ContentSizeCategory.swift in Sources */, EA5F86C82A1BD99100BC83E4 /* TabModel.swift in Sources */, EA0D1C432A6AD70900E5C127 /* VDSTypography.swift in Sources */, - EA297A5729FB0A360031ED56 /* AppleGuidlinesTouchable.swift in Sources */, + EA297A5729FB0A360031ED56 /* AppleGuidelinesTouchable.swift in Sources */, EA3361C328902D960071C351 /* Toggle.swift in Sources */, EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */, EA89201328B568D8006B9984 /* RadioBoxItem.swift in Sources */, diff --git a/VDS/Components/Buttons/ButtonBase.swift b/VDS/Components/Buttons/ButtonBase.swift index cdc40078..60ad36a3 100644 --- a/VDS/Components/Buttons/ButtonBase.swift +++ b/VDS/Components/Buttons/ButtonBase.swift @@ -75,10 +75,12 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true + /// The ButtonSize available to this type of Buttonable. open var availableSizes: [ButtonSize] { [] } open var surface: Surface = .light { didSet { setNeedsUpdate() }} + /// Text that will be used in the titleLabel. open var text: String? { didSet { setNeedsUpdate() } } /// Array of LabelAttributeModel objects used in rendering the text. @@ -99,6 +101,7 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { internal var isHighlightAnimating = false + /// Whether the Control is highlighted or not. open override var isHighlighted: Bool { didSet { if isHighlightAnimating == false && touchUpInsideCount > 0 { @@ -225,9 +228,9 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { } -// MARK: AppleGuidlinesTouchable -extension ButtonBase: AppleGuidlinesTouchable { - +// MARK: AppleGuidelinesTouchable +extension ButtonBase: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroupCollectionViewCell.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroupCollectionViewCell.swift index cd9ff406..02078ddc 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroupCollectionViewCell.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroupCollectionViewCell.swift @@ -14,8 +14,8 @@ extension ButtonGroup { } -extension ButtonGroup.ButtonGroupCollectionViewCell: AppleGuidlinesTouchable { - +extension ButtonGroup.ButtonGroupCollectionViewCell: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 99f02a58..067e8b5c 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -150,9 +150,9 @@ open class Checkbox: SelectorBase { } } -// MARK: AppleGuidlinesTouchable -extension Checkbox: AppleGuidlinesTouchable { - +// MARK: AppleGuidelinesTouchable +extension Checkbox: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index b1a9bbce..9a28291d 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -79,7 +79,7 @@ open class ButtonIcon: Control { // MARK: - Public Properties //-------------------------------------------------- /// Icon object used to render out the Icon for this ButtonIcon. - open var icon = Icon() + open var icon = Icon().with { $0.isUserInteractionEnabled = false } /// Determines the type of button based on the contrast. open var kind: Kind = .ghost { didSet { setNeedsUpdate() } } @@ -351,23 +351,12 @@ open class ButtonIcon: Control { } } -// MARK: AppleGuidlinesTouchable -extension ButtonIcon: AppleGuidlinesTouchable { - +// MARK: AppleGuidelinesTouchable +extension ButtonIcon: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } - - open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { - let view = super.hitTest(point, with: event) - - if view == icon { - return self - } - - return view - } - } extension UIView { diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index c37e667d..a82932cc 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -109,9 +109,9 @@ open class RadioButton: SelectorBase { } } -// MARK: AppleGuidlinesTouchable -extension RadioButton: AppleGuidlinesTouchable { - /// Overrides to ensure that the touch point meets a minimum of 45 x 45. +// MARK: AppleGuidelinesTouchable +extension RadioButton: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index dc45a523..550ee726 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -248,9 +248,9 @@ open class ToggleView: Control, Changeable { } } -// MARK: AppleGuidlinesTouchable -extension ToggleView: AppleGuidlinesTouchable { - +// MARK: AppleGuidelinesTouchable +extension ToggleView: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index abe4477c..58f945a3 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -190,9 +190,9 @@ open class Tooltip: Control, TooltipLaunchable { } -// MARK: AppleGuidlinesTouchable -extension Tooltip: AppleGuidlinesTouchable { - +// MARK: AppleGuidelinesTouchable +extension Tooltip: AppleGuidelinesTouchable { + /// Overrides to ensure that the touch point meets a minimum of the minimumTappableArea. override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { Self.acceptablyOutsideBounds(point: point, bounds: bounds) } diff --git a/VDS/Extensions/UIView+CALayer.swift b/VDS/Extensions/UIView+CALayer.swift index f8d9f25e..acc5ddab 100644 --- a/VDS/Extensions/UIView+CALayer.swift +++ b/VDS/Extensions/UIView+CALayer.swift @@ -32,7 +32,7 @@ extension UIView { layer.addSublayer(borderLayer) //add touchborder if applicable - if type(of: self) is AppleGuidlinesTouchable.Type { + if type(of: self) is AppleGuidelinesTouchable.Type { let faultToleranceX: CGFloat = max((45 - bounds.size.width) / 2.0, 0) let faultToleranceY: CGFloat = max((45 - bounds.size.height) / 2.0, 0) diff --git a/VDS/Protocols/AppleGuidlinesTouchable.swift b/VDS/Protocols/AppleGuidelinesTouchable.swift similarity index 87% rename from VDS/Protocols/AppleGuidlinesTouchable.swift rename to VDS/Protocols/AppleGuidelinesTouchable.swift index 782e57cd..d260a63b 100644 --- a/VDS/Protocols/AppleGuidlinesTouchable.swift +++ b/VDS/Protocols/AppleGuidelinesTouchable.swift @@ -1,5 +1,5 @@ // -// AppleGuidlinesTouchable.swift +// AppleGuidelinesTouchable.swift // VDS // // Created by Matt Bruce on 4/27/23. @@ -7,12 +7,12 @@ import Foundation -public protocol AppleGuidlinesTouchable { +public protocol AppleGuidelinesTouchable { static var minimumTappableArea: CGFloat { get } static func acceptablyOutsideBounds(point: CGPoint, bounds: CGRect) -> Bool } -extension AppleGuidlinesTouchable { +extension AppleGuidelinesTouchable { static public var minimumTappableArea: CGFloat { return 45.0