-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathRNGestureHandler.h
More file actions
143 lines (122 loc) · 6.16 KB
/
Copy pathRNGestureHandler.h
File metadata and controls
143 lines (122 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#import "RNGHUIKit.h"
#import "RNGestureHandlerActionType.h"
#import "RNGestureHandlerDirection.h"
#import "RNGestureHandlerEventHandlerType.h"
#import "RNGestureHandlerEvents.h"
#import "RNGestureHandlerPointerEvents.h"
#import "RNGestureHandlerPointerTracker.h"
#import "RNGestureHandlerPointerType.h"
#import "RNGestureHandlerState.h"
#import <Foundation/Foundation.h>
#import <React/RCTConvert.h>
#define VEC_LEN_SQ(pt) (pt.x * pt.x + pt.y * pt.y)
#define TEST_MIN_IF_NOT_NAN(value, limit) \
(!isnan(limit) && ((limit < 0 && value <= limit) || (limit >= 0 && value >= limit)))
#define TEST_MAX_IF_NOT_NAN(value, max) (!isnan(max) && ((max < 0 && value < max) || (max >= 0 && value > max)))
#define APPLY_PROP(recognizer, config, type, prop, propName) \
do { \
id value = config[propName]; \
if (value != nil) { \
recognizer.prop = [RCTConvert type:value]; \
} \
} while (0)
#define APPLY_FLOAT_PROP(prop) \
do { \
APPLY_PROP(recognizer, config, CGFloat, prop, @ #prop); \
} while (0)
#define APPLY_INT_PROP(prop) \
do { \
APPLY_PROP(recognizer, config, NSInteger, prop, @ #prop); \
} while (0)
#define APPLY_NAMED_INT_PROP(prop, propName) \
do { \
APPLY_PROP(recognizer, config, NSInteger, prop, propName); \
} while (0)
@protocol RNGestureHandlerEventEmitter
- (void)sendEvent:(nonnull RNGestureHandlerStateChange *)event
withActionType:(RNGestureHandlerActionType)actionType
forHandlerType:(RNGestureHandlerEventHandlerType)eventHandlerType
forView:(nonnull RNGHUIView *)detectorView;
- (void)sendNativeTouchEventForGestureHandler:(nonnull RNGestureHandler *)handler
withPointerType:(NSInteger)pointerType
forHandlerType:(RNGestureHandlerEventHandlerType)eventHandlerType;
@end
@protocol RNRootViewGestureRecognizerDelegate <UIGestureRecognizerDelegate>
- (void)gestureRecognizer:(nullable UIGestureRecognizer *)gestureRecognizer
didActivateInViewWithTouchHandler:(nullable RNGHUIView *)viewWithTouchHandler;
@end
@interface RNGestureHandler : NSObject <UIGestureRecognizerDelegate> {
@protected
UIGestureRecognizer *_recognizer;
@protected
RNGestureHandlerState _lastState;
@protected
NSInteger _pointerType;
}
+ (nullable RNGestureHandler *)findGestureHandlerByRecognizer:(nonnull UIGestureRecognizer *)recognizer;
- (nonnull instancetype)initWithTag:(nonnull NSNumber *)tag;
@property (nonatomic, readonly, nonnull) NSNumber *tag;
@property (nonatomic, weak, nullable) id<RNGestureHandlerEventEmitter> emitter;
@property (nonatomic, readonly, nullable) UIGestureRecognizer *recognizer;
@property (nonatomic, readonly, nullable) RNGestureHandlerPointerTracker *pointerTracker;
@property (nonatomic, nullable) NSString *testID;
@property (nonatomic) BOOL enabled;
@property (nonatomic) RNGestureHandlerActionType actionType;
@property (nonatomic) BOOL shouldCancelWhenOutside;
@property (nonatomic) BOOL needsPointerData;
@property (nonatomic) BOOL manualActivation;
@property (nonatomic) BOOL preventRecognizers;
@property (nonatomic) BOOL dispatchesAnimatedEvents;
@property (nonatomic) BOOL dispatchesReanimatedEvents;
@property (nonatomic, weak, nullable) RNGHUIView *hostDetectorView;
@property (nonatomic, nullable, assign) NSNumber *virtualViewTag;
@property (nonatomic, copy, nullable) NSNumber *viewTag;
@property (nonatomic, readonly) RNGestureHandlerState lastState;
- (BOOL)isViewParagraphComponent:(nullable RNGHUIView *)view;
- (nonnull RNGHUIView *)chooseViewForInteraction:(nonnull UIGestureRecognizer *)recognizer;
- (void)bindToView:(nonnull RNGHUIView *)view;
- (void)unbindFromView;
- (void)resetConfig NS_REQUIRES_SUPER;
- (void)setConfig:(nullable NSDictionary *)config NS_REQUIRES_SUPER;
- (void)updateConfig:(nullable NSDictionary *)config NS_REQUIRES_SUPER;
- (void)updateRelations:(nonnull NSDictionary *)relations;
- (void)handleGesture:(nonnull id)recognizer;
- (void)handleGesture:(nonnull id)recognizer fromReset:(BOOL)fromReset;
- (void)handleGesture:(nonnull id)recognizer
fromReset:(BOOL)fromReset
fromManualStateChange:(BOOL)fromManualStateChange;
- (void)handleGesture:(nonnull id)recognizer inState:(RNGestureHandlerState)state;
- (void)handleGesture:(nonnull id)recognizer
inState:(RNGestureHandlerState)state
fromManualStateChange:(BOOL)fromManualStateChange;
- (BOOL)containsPointInView;
- (BOOL)wantsToHandleEventsAtPoint:(CGPoint)point;
- (RNGestureHandlerState)state;
- (nullable RNGestureHandlerEventExtraData *)eventExtraData:(nonnull id)recognizer;
- (void)stopActivationBlocker;
- (void)reset;
- (void)sendEventsInState:(RNGestureHandlerState)state
forViewWithTag:(nonnull NSNumber *)reactTag
withExtraData:(nonnull RNGestureHandlerEventExtraData *)extraData;
- (void)sendEventsInState:(RNGestureHandlerState)state
forViewWithTag:(nonnull NSNumber *)reactTag
withExtraData:(nonnull RNGestureHandlerEventExtraData *)extraData
fromManualStateChange:(BOOL)fromManualStateChange;
- (void)sendEvent:(nonnull RNGestureHandlerStateChange *)event;
- (void)sendTouchEventInState:(RNGestureHandlerState)state forViewWithTag:(nonnull NSNumber *)reactTag;
- (nullable RNGHUIScrollView *)retrieveScrollView:(nonnull RNGHUIView *)view;
- (nonnull RNGHUIView *)findViewForEvents;
- (BOOL)wantsToAttachDirectlyToView;
- (BOOL)usesNativeOrVirtualDetector;
#if !TARGET_OS_OSX
- (BOOL)isUIScrollViewPanGestureRecognizer:(nonnull UIGestureRecognizer *)gestureRecognizer;
#else
- (BOOL)isUIScrollViewPanGestureRecognizer:(nonnull NSGestureRecognizer *)gestureRecognizer;
#endif
#if !TARGET_OS_OSX
- (void)setCurrentPointerType:(RNGestureHandlerPointerType)pointerType;
- (void)setCurrentPointerTypeForEvent:(nonnull UIEvent *)event;
#else
- (void)setCurrentPointerTypeToMouse;
#endif
@end