Merge branch 'mbruce/bugfixes' into 'develop'

updated isHighlighted even more

See merge request BPHV_MIPS/vds_ios!112
This commit is contained in:
Bruce, Matt R 2023-09-15 00:16:04 +00:00
commit c830ee89f1
2 changed files with 12 additions and 17 deletions

View File

@ -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
}
}
}

View File

@ -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() } }