removing touchUpInsideCount, since now we are keying off of onClickSubscriber

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-09-14 08:31:51 -05:00
parent fdb7e955e2
commit ad6c00214e
4 changed files with 2 additions and 19 deletions

View File

@ -63,14 +63,12 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
/// Whether the Control can handle the isHighlighted state.
open var canHighlight: Bool = true
open var touchUpInsideCount: Int = 0
var isHighlightAnimating = false
/// Whether the Control is highlighted or not.
open override var isHighlighted: Bool {
didSet {
if canHighlight && isHighlightAnimating == false && touchUpInsideCount > 0 {
if canHighlight && isHighlightAnimating == false && onClickSubscriber != nil {
isHighlightAnimating = true
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.setNeedsUpdate()

View File

@ -97,14 +97,12 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
open var userInfo = [String: Primitive]()
open var touchUpInsideCount: Int = 0
internal var isHighlightAnimating = false
/// Whether the Control is highlighted or not.
open override var isHighlighted: Bool {
didSet {
if isHighlightAnimating == false && touchUpInsideCount > 0 {
if isHighlightAnimating == false && onClickSubscriber != nil {
isHighlightAnimating = true
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.setNeedsUpdate()

View File

@ -10,8 +10,6 @@ import UIKit
import Combine
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.
var onClickSubscriber: AnyCancellable? { get set }
}

View File

@ -20,10 +20,6 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
self.control = control
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)
}
@ -36,13 +32,6 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
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() {
_ = subscriber?.receive(control)
}