From de9b57362c8c75a60094ca0214c360b0218b4589 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 6 Dec 2022 11:04:28 -0600 Subject: [PATCH] added animation block for updateview Signed-off-by: Matt Bruce --- .../Buttons/Button/ButtonBase.swift | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 887fff2c..121ae8f6 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -43,9 +43,23 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } - - open override var isHighlighted: Bool { didSet { if isHighlighted != oldValue { updateView() } } } - + + var isHighlightAnimating = false + open override var isHighlighted: Bool { + didSet { + if isHighlightAnimating == false { + isHighlightAnimating = true + UIView.animate(withDuration: 0.1, animations: { [weak self] in + self?.updateView() + }) { [weak self] _ in + //you update the view since this is typically a quick change + self?.updateView() + self?.isHighlightAnimating = false + } + } + } + } + open var typograpicalStyle: TypographicalStyle { .defaultStyle } open var textColor: UIColor { .black } @@ -129,7 +143,6 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab // MARK: - PRIVATE //-------------------------------------------------- private func updateLabel() { - let font = typograpicalStyle.font //clear the arrays holding actions