added canHighlight

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-16 08:38:31 -05:00
parent 0f8ab50192
commit 3ca168a53b
3 changed files with 10 additions and 3 deletions

View File

@ -52,7 +52,10 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
/// Whether the Control is selected or not. /// Whether the Control is selected or not.
open override var isSelected: Bool { didSet { setNeedsUpdate() } } 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 open var touchUpInsideCount: Int = 0
var isHighlightAnimating = false var isHighlightAnimating = false
@ -60,7 +63,7 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
/// Whether the Control is highlighted or not.. /// Whether the Control is highlighted or not..
open override var isHighlighted: Bool { open override var isHighlighted: Bool {
didSet { didSet {
if isHighlightAnimating == false && touchUpInsideCount > 0 { if canHighlight && isHighlightAnimating == false && touchUpInsideCount > 0 {
isHighlightAnimating = true isHighlightAnimating = true
UIView.animate(withDuration: 0.1, animations: { [weak self] in UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.setNeedsUpdate() self?.setNeedsUpdate()

View File

@ -124,6 +124,9 @@ extension Tabs {
open override func setup() { open override func setup() {
super.setup() super.setup()
canHighlight = false
addLayoutGuide(layoutGuide) addLayoutGuide(layoutGuide)
addSubview(label) addSubview(label)
accessibilityTraits = .button accessibilityTraits = .button

View File

@ -140,7 +140,8 @@ open class Toggle: Control, Changeable {
open override func setup() { open override func setup() {
super.setup() super.setup()
canHighlight = false
isAccessibilityElement = true isAccessibilityElement = true
accessibilityTraits = .button accessibilityTraits = .button
addSubview(label) addSubview(label)