Skip to content

Commit

Permalink
Add Text on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bert committed Nov 21, 2024
1 parent 414e507 commit 5a4bc5f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion apple/Handlers/RNNativeViewHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#import <React/UIView+React.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTParagraphComponentView.h>
#import <React/RCTScrollViewComponentView.h>
#else
#import <React/RCTScrollView.h>
#import <React/RCTTextView.h>
#endif // RCT_NEW_ARCH_ENABLED

#pragma mark RNDummyGestureRecognizer
Expand All @@ -40,6 +42,14 @@ - (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

#ifdef RCT_NEW_ARCH_ENABLED
if ([self.view.superview isKindOfClass:[RCTParagraphComponentView class]]) {
#else
if ([self.view isKindOfClass:[RCTTextView class]]) {
#endif
self.state = UIGestureRecognizerStatePossible;
}
}

- (void)touchesMoved:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
Expand All @@ -51,7 +61,16 @@ - (void)touchesMoved:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler.pointerTracker touchesEnded:touches withEvent:event];
self.state = UIGestureRecognizerStateFailed;

#ifdef RCT_NEW_ARCH_ENABLED
if ([self.view.superview isKindOfClass:[RCTParagraphComponentView class]]) {
#else
if ([self.view isKindOfClass:[RCTTextView class]]) {
#endif
self.state = UIGestureRecognizerStateEnded;
} else {
self.state = UIGestureRecognizerStateFailed;
}

// For now, we are handling only the scroll view case.
// If more views need special treatment, then we can switch to a delegate pattern
Expand Down

0 comments on commit 5a4bc5f

Please sign in to comment.