1 #import "RNGestureHandlerActionType.h" 2 #import "RNGestureHandlerDirection.h" 3 #import "RNGestureHandlerEvents.h" 4 #import "RNGestureHandlerPointerTracker.h" 5 #import "RNGestureHandlerState.h" 6 7 #import <Foundation/Foundation.h> 8 #import <React/RCTConvert.h> 9 #import <UIKit/UIKit.h> 10 11 #define VEC_LEN_SQ(pt) (pt.x * pt.x + pt.y * pt.y) 12 #define TEST_MIN_IF_NOT_NAN(value, limit) \ 13 (!isnan(limit) && ((limit < 0 && value <= limit) || (limit >= 0 && value >= limit))) 14 15 #define TEST_MAX_IF_NOT_NAN(value, max) (!isnan(max) && ((max < 0 && value < max) || (max >= 0 && value > max))) 16 17 #define APPLY_PROP(recognizer, config, type, prop, propName) \ 18 do { \ 19 id value = config[propName]; \ 20 if (value != nil) { \ 21 recognizer.prop = [RCTConvert type:value]; \ 22 } \ 23 } while (0) 24 25 #define APPLY_FLOAT_PROP(prop) \ 26 do { \ 27 APPLY_PROP(recognizer, config, CGFloat, prop, @ #prop); \ 28 } while (0) 29 #define APPLY_INT_PROP(prop) \ 30 do { \ 31 APPLY_PROP(recognizer, config, NSInteger, prop, @ #prop); \ 32 } while (0) 33 #define APPLY_NAMED_INT_PROP(prop, propName) \ 34 do { \ 35 APPLY_PROP(recognizer, config, NSInteger, prop, propName); \ 36 } while (0) 37 38 @protocol RNGestureHandlerEventEmitter 39 40 - (void)sendEvent:(nonnull RNGestureHandlerStateChange *)event withActionType:(RNGestureHandlerActionType)actionType; 41 42 @end 43 44 @protocol RNRootViewGestureRecognizerDelegate <UIGestureRecognizerDelegate> 45 46 - (void)gestureRecognizer:(nullable UIGestureRecognizer *)gestureRecognizer 47 didActivateInViewWithTouchHandler:(nullable UIView *)viewWithTouchHandler; 48 49 @end 50 51 @interface RNGestureHandler : NSObject <UIGestureRecognizerDelegate> { 52 @protected 53 UIGestureRecognizer *_recognizer; 54 @protected 55 RNGestureHandlerState _lastState; 56 } 57 58 + (nullable RNGestureHandler *)findGestureHandlerByRecognizer:(nonnull UIGestureRecognizer *)recognizer; 59 60 - (nonnull instancetype)initWithTag:(nonnull NSNumber *)tag; 61 62 @property (nonatomic, readonly, nonnull) NSNumber *tag; 63 @property (nonatomic, weak, nullable) id<RNGestureHandlerEventEmitter> emitter; 64 @property (nonatomic, readonly, nullable) UIGestureRecognizer *recognizer; 65 @property (nonatomic, readonly, nullable) RNGestureHandlerPointerTracker *pointerTracker; 66 @property (nonatomic) BOOL enabled; 67 @property (nonatomic) RNGestureHandlerActionType actionType; 68 @property (nonatomic) BOOL shouldCancelWhenOutside; 69 @property (nonatomic) BOOL needsPointerData; 70 @property (nonatomic) BOOL manualActivation; 71 72 - (void)bindToView:(nonnull UIView *)view; 73 - (void)unbindFromView; 74 - (void)resetConfig NS_REQUIRES_SUPER; 75 - (void)configure:(nullable NSDictionary *)config NS_REQUIRES_SUPER; 76 - (void)handleGesture:(nonnull id)recognizer; 77 - (void)handleGesture:(nonnull id)recognizer inState:(RNGestureHandlerState)state; 78 - (BOOL)containsPointInView; 79 - (RNGestureHandlerState)state; 80 - (nullable RNGestureHandlerEventExtraData *)eventExtraData:(nonnull id)recognizer; 81 82 - (void)stopActivationBlocker; 83 - (void)reset; 84 - (void)sendEventsInState:(RNGestureHandlerState)state 85 forViewWithTag:(nonnull NSNumber *)reactTag 86 withExtraData:(nonnull RNGestureHandlerEventExtraData *)extraData; 87 - (void)sendEvent:(nonnull RNGestureHandlerStateChange *)event; 88 - (void)sendTouchEventInState:(RNGestureHandlerState)state forViewWithTag:(nonnull NSNumber *)reactTag; 89 90 @end 91