@@ -2,60 +2,60 @@ import UIKit
22
33extension DeclarativeProtocol {
44 @discardableResult
5- public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( UIGestureRecognizer . State ) -> Void ) -> Self {
6- declarativeView. addGestureRecognizer ( LongPressGestureRecognizer ( taps: taps, touches: touches) . trackState ( action) )
7- return self
5+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , on state: UIGestureRecognizer . State , _ action: @escaping ( ) -> Void ) -> Self {
6+ onLongPressGesture ( taps: taps, touches: touches, on: state) { v, r in
7+ action ( )
8+ }
89 }
910
1011 @discardableResult
11- public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self , UIGestureRecognizer . State ) -> Void ) -> Self {
12- declarativeView. addGestureRecognizer ( LongPressGestureRecognizer ( taps: taps, touches: touches) . trackState {
13- action ( self , $0)
14- } )
15- return self
12+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , on state: UIGestureRecognizer . State , _ action: @escaping ( Self ) -> Void ) -> Self {
13+ onLongPressGesture ( taps: taps, touches: touches, on: state) { v, r in
14+ action ( self )
15+ }
1616 }
1717
1818 @discardableResult
19- public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self , UIGestureRecognizer . State , LongPressGestureRecognizer ) -> Void ) -> Self {
20- let recognizer = LongPressGestureRecognizer ( taps: taps, touches: touches)
21- declarativeView . addGestureRecognizer ( recognizer . trackState {
22- action ( self , $0 , recognizer )
23- } )
24- return self
19+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , on state : UIGestureRecognizer . State , _ action: @escaping ( Self , LongPressGestureRecognizer ) -> Void ) -> Self {
20+ onLongPressGesture ( taps: taps, touches: touches) { v , s , r in
21+ if s == state {
22+ action ( v , r )
23+ }
24+ }
2525 }
2626
2727 @discardableResult
28- public func onLongPressGesture( on state: UIGestureRecognizer . State = . began, taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( ) -> Void ) -> Self {
29- declarativeView. addGestureRecognizer ( LongPressGestureRecognizer ( taps: taps, touches: touches) . trackState {
30- switch $0 {
31- case state: action ( )
32- default : break
33- }
34- } )
35- return self
28+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self ) -> Void ) -> Self {
29+ onLongPressGesture ( taps: taps, touches: touches) { v, s, r in
30+ action ( v)
31+ }
3632 }
3733
3834 @discardableResult
39- public func onLongPressGesture( on state: UIGestureRecognizer . State = . began, taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self ) -> Void ) -> Self {
40- declarativeView. addGestureRecognizer ( LongPressGestureRecognizer ( taps: taps, touches: touches) . trackState {
41- switch $0 {
42- case state: action ( self )
43- default : break
44- }
45- } )
46- return self
35+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self , UIGestureRecognizer . State ) -> Void ) -> Self {
36+ onLongPressGesture ( taps: taps, touches: touches) { v, s, r in
37+ action ( v, s)
38+ }
4739 }
4840
4941 @discardableResult
50- public func onLongPressGesture( _ state: State < UIGestureRecognizer . State > , taps: Int = 0 , touches: Int = 1 ) -> Self {
51- declarativeView. addGestureRecognizer ( LongPressGestureRecognizer ( taps: taps, touches: touches) . trackState {
52- state. wrappedValue = $0
42+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ action: @escaping ( Self , UIGestureRecognizer . State , LongPressGestureRecognizer ) -> Void ) -> Self {
43+ let recognizer = LongPressGestureRecognizer ( taps: taps, touches: touches)
44+ declarativeView. addGestureRecognizer ( recognizer. trackState {
45+ action ( self , $0, recognizer)
5346 } )
5447 return self
5548 }
49+
50+ @discardableResult
51+ public func onLongPressGesture( taps: Int = 0 , touches: Int = 1 , _ state: State < UIGestureRecognizer . State > ) -> Self {
52+ onLongPressGesture ( taps: taps, touches: touches) { v, s, r in
53+ state. wrappedValue = s
54+ }
55+ }
5656
5757 @discardableResult
58- public func onLongPressGesture< V> ( _ expressable : ExpressableState < V , UIGestureRecognizer . State > , taps: Int = 0 , touches: Int = 1 ) -> Self {
59- onLongPressGesture ( expressable . unwrap ( ) , taps: taps, touches: touches)
58+ public func onLongPressGesture< V> ( taps: Int = 0 , touches: Int = 1 , _ expressable : ExpressableState < V , UIGestureRecognizer . State > ) -> Self {
59+ onLongPressGesture ( taps: taps, touches: touches, expressable . unwrap ( ) )
6060 }
6161}
0 commit comments