From c7746874b6fda777519ffc18e5360e45bf7c6301 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Sep 2023 19:15:36 -0500 Subject: [PATCH] updated isHighlighted even more Signed-off-by: Matt Bruce --- VDS/BaseClasses/Control.swift | 6 ++---- VDS/Components/Buttons/ButtonBase.swift | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/VDS/BaseClasses/Control.swift b/VDS/BaseClasses/Control.swift index a8b62ed1..ce90d271 100644 --- a/VDS/BaseClasses/Control.swift +++ b/VDS/BaseClasses/Control.swift @@ -71,10 +71,8 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { didSet { if shouldHighlight { isHighlighting = true - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - self?.isHighlighting = false - }) + setNeedsUpdate() + isHighlighting = false } } } diff --git a/VDS/Components/Buttons/ButtonBase.swift b/VDS/Components/Buttons/ButtonBase.swift index 83627736..64dbea7e 100644 --- a/VDS/Components/Buttons/ButtonBase.swift +++ b/VDS/Components/Buttons/ButtonBase.swift @@ -77,26 +77,23 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { open var userInfo = [String: Primitive]() - internal var isHighlightAnimating = false + /// State of animating isHighlight. + public var isHighlighting = false + + /// Whether the Button should handle the isHighlighted state. + open var shouldHighlight: Bool { isHighlighting == false && onClickSubscriber != nil } /// Whether the Control is highlighted or not. open override var isHighlighted: Bool { didSet { - if isHighlightAnimating == false && onClickSubscriber != nil { - isHighlightAnimating = true - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - }) { [weak self] _ in - //you update the view since this is typically a quick change - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - self?.isHighlightAnimating = false - }) - } + if shouldHighlight { + isHighlighting = true + setNeedsUpdate() + isHighlighting = false } } } - + /// Whether the Control is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate() } }