removing touchUpInsideCount, since now we are keying off of onClickSubscriber
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
fdb7e955e2
commit
ad6c00214e
@ -63,14 +63,12 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
|
|||||||
/// Whether the Control can handle the isHighlighted state.
|
/// Whether the Control can handle the isHighlighted state.
|
||||||
open var canHighlight: Bool = true
|
open var canHighlight: Bool = true
|
||||||
|
|
||||||
open var touchUpInsideCount: Int = 0
|
|
||||||
|
|
||||||
var isHighlightAnimating = false
|
var isHighlightAnimating = false
|
||||||
|
|
||||||
/// 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 canHighlight && isHighlightAnimating == false && touchUpInsideCount > 0 {
|
if canHighlight && isHighlightAnimating == false && onClickSubscriber != nil {
|
||||||
isHighlightAnimating = true
|
isHighlightAnimating = true
|
||||||
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
||||||
self?.setNeedsUpdate()
|
self?.setNeedsUpdate()
|
||||||
|
|||||||
@ -97,14 +97,12 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
|
|||||||
|
|
||||||
open var userInfo = [String: Primitive]()
|
open var userInfo = [String: Primitive]()
|
||||||
|
|
||||||
open var touchUpInsideCount: Int = 0
|
|
||||||
|
|
||||||
internal var isHighlightAnimating = false
|
internal var isHighlightAnimating = false
|
||||||
|
|
||||||
/// 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 && touchUpInsideCount > 0 {
|
if isHighlightAnimating == false && onClickSubscriber != nil {
|
||||||
isHighlightAnimating = true
|
isHighlightAnimating = true
|
||||||
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
UIView.animate(withDuration: 0.1, animations: { [weak self] in
|
||||||
self?.setNeedsUpdate()
|
self?.setNeedsUpdate()
|
||||||
|
|||||||
@ -10,8 +10,6 @@ import UIKit
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public protocol Clickable: ViewProtocol where Self: UIControl {
|
public protocol Clickable: ViewProtocol where Self: UIControl {
|
||||||
/// Reference count used when a subscriber is listening for the UIControl event .touchUpInside.
|
|
||||||
var touchUpInsideCount: Int { get set }
|
|
||||||
/// Sets the primary Subscriber used for the UIControl event .touchUpInside.
|
/// Sets the primary Subscriber used for the UIControl event .touchUpInside.
|
||||||
var onClickSubscriber: AnyCancellable? { get set }
|
var onClickSubscriber: AnyCancellable? { get set }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,6 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
|
|||||||
self.control = control
|
self.control = control
|
||||||
self.event = event
|
self.event = event
|
||||||
|
|
||||||
//allow highlight for VDS.Controls on "onClick" events
|
|
||||||
if let c = control as? Clickable, event == .touchUpInside {
|
|
||||||
c.touchUpInsideCount += 1
|
|
||||||
}
|
|
||||||
control.addTarget(self, action: #selector(eventHandler), for: event)
|
control.addTarget(self, action: #selector(eventHandler), for: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,13 +32,6 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
|
|||||||
subscriber = nil
|
subscriber = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
|
||||||
//remove highlight for VDS.Controls on "onClick" events
|
|
||||||
if let c = control as? Clickable, event == .touchUpInside, c.touchUpInsideCount > 0 {
|
|
||||||
c.touchUpInsideCount -= 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func eventHandler() {
|
@objc private func eventHandler() {
|
||||||
_ = subscriber?.receive(control)
|
_ = subscriber?.receive(control)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user