Nobody outside RCTTouchHandler should treat it as UIGestureRecognizer subclass
Reviewed By: mmmulani Differential Revision: D4387821 fbshipit-source-id: 8060772a5de669eeaca159ceac13b995d7518a1b
This commit is contained in:
parent
2e4be1c2c9
commit
47f18bdb17
|
@ -380,7 +380,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||||
_bridge = bridge;
|
_bridge = bridge;
|
||||||
self.reactTag = reactTag;
|
self.reactTag = reactTag;
|
||||||
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
||||||
[self addGestureRecognizer:_touchHandler];
|
[_touchHandler attachToView:self];
|
||||||
[_bridge.uiManager registerRootView:self withSizeFlexibility:sizeFlexibility];
|
[_bridge.uiManager registerRootView:self withSizeFlexibility:sizeFlexibility];
|
||||||
self.layer.backgroundColor = NULL;
|
self.layer.backgroundColor = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
@interface RCTTouchHandler : UIGestureRecognizer
|
@interface RCTTouchHandler : UIGestureRecognizer
|
||||||
|
|
||||||
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
- (void)attachToView:(UIView *)view;
|
||||||
|
- (void)detachFromView:(UIView *)view;
|
||||||
|
|
||||||
- (void)cancel;
|
- (void)cancel;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -64,6 +64,21 @@
|
||||||
|
|
||||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action)
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action)
|
||||||
|
|
||||||
|
- (void)attachToView:(UIView *)view
|
||||||
|
{
|
||||||
|
RCTAssert(self.view == nil, @"RCTTouchHandler already has attached view.");
|
||||||
|
|
||||||
|
[view addGestureRecognizer:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)detachFromView:(UIView *)view
|
||||||
|
{
|
||||||
|
RCTAssertParam(view);
|
||||||
|
RCTAssert(self.view == view, @"RCTTouchHandler attached to another view.");
|
||||||
|
|
||||||
|
[view removeGestureRecognizer:self];
|
||||||
|
}
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, RCTTouchEventType) {
|
typedef NS_ENUM(NSInteger, RCTTouchEventType) {
|
||||||
RCTTouchEventTypeStart,
|
RCTTouchEventTypeStart,
|
||||||
RCTTouchEventTypeMove,
|
RCTTouchEventTypeMove,
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#import "RCTModalHostView.h"
|
#import "RCTModalHostView.h"
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "RCTAssert.h"
|
#import "RCTAssert.h"
|
||||||
#import "RCTBridge.h"
|
#import "RCTBridge.h"
|
||||||
#import "RCTModalHostViewController.h"
|
#import "RCTModalHostViewController.h"
|
||||||
|
@ -16,8 +18,6 @@
|
||||||
#import "RCTUIManager.h"
|
#import "RCTUIManager.h"
|
||||||
#import "UIView+React.h"
|
#import "UIView+React.h"
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@implementation RCTModalHostView
|
@implementation RCTModalHostView
|
||||||
{
|
{
|
||||||
__weak RCTBridge *_bridge;
|
__weak RCTBridge *_bridge;
|
||||||
|
@ -87,7 +87,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||||
{
|
{
|
||||||
RCTAssert(_reactSubview == nil, @"Modal view can only have one subview");
|
RCTAssert(_reactSubview == nil, @"Modal view can only have one subview");
|
||||||
[super insertReactSubview:subview atIndex:atIndex];
|
[super insertReactSubview:subview atIndex:atIndex];
|
||||||
[subview addGestureRecognizer:_touchHandler];
|
[_touchHandler attachToView:subview];
|
||||||
subview.autoresizingMask = UIViewAutoresizingFlexibleHeight |
|
subview.autoresizingMask = UIViewAutoresizingFlexibleHeight |
|
||||||
UIViewAutoresizingFlexibleWidth;
|
UIViewAutoresizingFlexibleWidth;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||||
{
|
{
|
||||||
RCTAssert(subview == _reactSubview, @"Cannot remove view other than modal view");
|
RCTAssert(subview == _reactSubview, @"Cannot remove view other than modal view");
|
||||||
[super removeReactSubview:subview];
|
[super removeReactSubview:subview];
|
||||||
[subview removeGestureRecognizer:_touchHandler];
|
[_touchHandler detachFromView:subview];
|
||||||
_reactSubview = nil;
|
_reactSubview = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#import "RCTBridge.h"
|
#import "RCTBridge.h"
|
||||||
#import "RCTModalHostView.h"
|
#import "RCTModalHostView.h"
|
||||||
#import "RCTModalHostViewController.h"
|
#import "RCTModalHostViewController.h"
|
||||||
#import "RCTTouchHandler.h"
|
|
||||||
#import "RCTShadowView.h"
|
#import "RCTShadowView.h"
|
||||||
#import "RCTUtils.h"
|
#import "RCTUtils.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue