From 3ca168a53b85e2eea385a075312267e7d1101a48 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 16 Aug 2023 08:38:31 -0500 Subject: [PATCH] added canHighlight Signed-off-by: Matt Bruce --- VDS/Classes/Control.swift | 7 +++++-- VDS/Components/Tabs/Tab.swift | 3 +++ VDS/Components/Toggle/Toggle.swift | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 10eb8ef9..1acca2d5 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -52,7 +52,10 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { /// Whether the Control is selected or not. open override var isSelected: Bool { didSet { setNeedsUpdate() } } - + + /// Whether the Control can handle the isHighlighted state. + open var canHighlight: Bool = true + open var touchUpInsideCount: Int = 0 var isHighlightAnimating = false @@ -60,7 +63,7 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { /// Whether the Control is highlighted or not.. open override var isHighlighted: Bool { didSet { - if isHighlightAnimating == false && touchUpInsideCount > 0 { + if canHighlight && isHighlightAnimating == false && touchUpInsideCount > 0 { isHighlightAnimating = true UIView.animate(withDuration: 0.1, animations: { [weak self] in self?.setNeedsUpdate() diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index d33bea63..7369202f 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -124,6 +124,9 @@ extension Tabs { open override func setup() { super.setup() + + canHighlight = false + addLayoutGuide(layoutGuide) addSubview(label) accessibilityTraits = .button diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 82a602b2..c4194496 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -140,7 +140,8 @@ open class Toggle: Control, Changeable { open override func setup() { super.setup() - + + canHighlight = false isAccessibilityElement = true accessibilityTraits = .button addSubview(label)