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.
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()

View File

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

View File

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