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

@ -62,15 +62,13 @@ 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

@ -96,15 +96,13 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
open var useScaledFont: Bool = false { didSet { setNeedsUpdate() } }
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)
}
@ -35,13 +31,6 @@ public final class UIControlSubscription<SubscriberType: Subscriber, Control: UI
public func cancel() {
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)