updated isHighlighted even more

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-09-14 19:15:36 -05:00
parent 143d1bf717
commit c7746874b6
2 changed files with 12 additions and 17 deletions

View File

@ -71,10 +71,8 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
didSet { didSet {
if shouldHighlight { if shouldHighlight {
isHighlighting = true isHighlighting = true
UIView.animate(withDuration: 0.1, animations: { [weak self] in setNeedsUpdate()
self?.setNeedsUpdate() isHighlighting = false
self?.isHighlighting = false
})
} }
} }
} }

View File

@ -77,26 +77,23 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
open var userInfo = [String: Primitive]() 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. /// Whether the Control is highlighted or not.
open override var isHighlighted: Bool { open override var isHighlighted: Bool {
didSet { didSet {
if isHighlightAnimating == false && onClickSubscriber != nil { if shouldHighlight {
isHighlightAnimating = true isHighlighting = true
UIView.animate(withDuration: 0.1, animations: { [weak self] in setNeedsUpdate()
self?.setNeedsUpdate() isHighlighting = false
}) { [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
})
}
} }
} }
} }
/// Whether the Control is enabled or not. /// Whether the Control is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate() } } open override var isEnabled: Bool { didSet { setNeedsUpdate() } }