diff --git a/VDS/Classes/SelectorBase.swift b/VDS/Classes/SelectorBase.swift index 7ddb9d2f..a6d6a7f5 100644 --- a/VDS/Classes/SelectorBase.swift +++ b/VDS/Classes/SelectorBase.swift @@ -58,12 +58,10 @@ open class SelectorBase: Control, SelectorControlable { open var selectorColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() }} + private var selectorView = View() //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- - private var selectorHeightConstraint: NSLayoutConstraint? - private var selectorWidthConstraint: NSLayoutConstraint? - internal var shapeLayer: CAShapeLayer? open override func initialSetup() { @@ -78,35 +76,14 @@ open class SelectorBase: Control, SelectorControlable { isAccessibilityElement = true accessibilityTraits = .button - - let layoutGuide = UILayoutGuide() - addLayoutGuide(layoutGuide) - - selectorHeightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: size.height) - selectorHeightConstraint?.isActive = true - - selectorWidthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: size.width) - selectorWidthConstraint?.isActive = true - - NSLayoutConstraint.activate([ - layoutGuide.topAnchor.constraint(equalTo: topAnchor), - layoutGuide.bottomAnchor.constraint(equalTo: bottomAnchor), - layoutGuide.leadingAnchor.constraint(equalTo: leadingAnchor), - layoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)]) - - layer.cornerRadius = 2.0 - layer.borderWidth = VDSFormControls.widthBorder - } + open override var intrinsicContentSize: CGSize { size } + open func toggle() { } open override func updateView() { super.updateView() - - selectorHeightConstraint?.constant = size.height - selectorWidthConstraint?.constant = size.width - setNeedsLayout() layoutIfNeeded() } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 2b3ae6d7..9c22e616 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -46,7 +46,7 @@ open class Checkbox: SelectorBase { isSelected.toggle() sendActions(for: .valueChanged) } - + open override func layoutSubviews() { super.layoutSubviews() @@ -123,3 +123,12 @@ open class Checkbox: SelectorBase { } } } + +// MARK: AppleGuidlinesTouchable +extension Checkbox: AppleGuidlinesTouchable { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + Self.acceptablyOutsideBounds(point: point, bounds: bounds) + } + +} diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 00e7134c..65ad5485 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -36,6 +36,17 @@ open class RadioButton: SelectorBase { } + open override func toggle() { + guard !isSelected else { return } + + //removed error + if showError && isSelected == false { + showError.toggle() + } + isSelected.toggle() + sendActions(for: .valueChanged) + } + open override func layoutSubviews() { super.layoutSubviews() @@ -71,3 +82,12 @@ open class RadioButton: SelectorBase { } } } + +// MARK: AppleGuidlinesTouchable +extension RadioButton: AppleGuidlinesTouchable { + + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { + Self.acceptablyOutsideBounds(point: point, bounds: bounds) + } + +}