updated button for onClickPublisher
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2920559d84
commit
2eee432ac0
@ -29,6 +29,16 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public var subject = PassthroughSubject<Void, Never>()
|
public var subject = PassthroughSubject<Void, Never>()
|
||||||
public var subscribers = Set<AnyCancellable>()
|
public var subscribers = Set<AnyCancellable>()
|
||||||
|
open var onClickSubscriber: AnyCancellable? {
|
||||||
|
willSet {
|
||||||
|
if let onClickSubscriber {
|
||||||
|
onClickSubscriber.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
didSet {
|
||||||
|
enabledHighlight = onClickSubscriber != nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
@ -50,10 +60,13 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
|
|
||||||
open var userInfo = [String: Primitive]()
|
open var userInfo = [String: Primitive]()
|
||||||
|
|
||||||
var isHighlightAnimating = false
|
internal var enabledHighlight: Bool = false
|
||||||
|
|
||||||
|
internal var isHighlightAnimating = false
|
||||||
|
|
||||||
open override var isHighlighted: Bool {
|
open override var isHighlighted: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
if isHighlightAnimating == false {
|
if isHighlightAnimating == false && enabledHighlight {
|
||||||
isHighlightAnimating = true
|
isHighlightAnimating = true
|
||||||
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
||||||
self?.updateView()
|
self?.updateView()
|
||||||
@ -227,4 +240,3 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,9 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
|
|||||||
//allow highlight for VDS.Controls on "onClick" events
|
//allow highlight for VDS.Controls on "onClick" events
|
||||||
if let c = control as? VDS.Control, event == .touchUpInside {
|
if let c = control as? VDS.Control, event == .touchUpInside {
|
||||||
c.enabledHighlight = true
|
c.enabledHighlight = true
|
||||||
|
} else if let c = control as? VDS.ButtonBase, event == .touchUpInside {
|
||||||
|
c.enabledHighlight = true
|
||||||
}
|
}
|
||||||
|
|
||||||
control.addTarget(self, action: #selector(eventHandler), for: event)
|
control.addTarget(self, action: #selector(eventHandler), for: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +42,8 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
|
|||||||
//remove highlight for VDS.Controls on "onClick" events
|
//remove highlight for VDS.Controls on "onClick" events
|
||||||
if let c = control as? VDS.Control, event == .touchUpInside {
|
if let c = control as? VDS.Control, event == .touchUpInside {
|
||||||
c.enabledHighlight = false
|
c.enabledHighlight = false
|
||||||
|
} else if let c = control as? VDS.ButtonBase, event == .touchUpInside {
|
||||||
|
c.enabledHighlight = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user