Skip to content

Commit

Permalink
refactor: remove pan gesture code
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Dec 12, 2024
1 parent 049435d commit 3c7d00d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- (x) 4 two events get dispatched after 2nd onInteractive (fix with pan gesture responder - when it's active ignore plain keyboard events)
- (x) 5 TimingAnimation is unsynchronized

Check failure on line 9 in TODO

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (unsynchronized)
- (x) 6 hide interactively -> tap input many times -> keyboard is shown and composer is not moving and it looks like events are broken -> for RCTRootView we need to resign synchronously
- 7 remove pan gesture responder stuff
- (x) 7 remove pan gesture responder stuff
- 8 resolve swiftlint issues
- 9 resolve various flickers (test iOS 15 - 18)
- 10 iOS 15 sometimes keyboardDidDisappear gets triggered before onKeyboardMove events (duration = 85) --> caused by constant usage of onMove?
Expand Down
5 changes: 2 additions & 3 deletions ios/observers/KeyboardEventsIgnorer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ public class KeyboardEventsIgnorer: NSObject {
@objc public static let shared = KeyboardEventsIgnorer()

var shouldIgnoreKeyboardEvents = false
@objc public var isInteractiveGesture = false

public var shouldIgnore: Bool {
print("KeyboardEventsIgnorer \(shouldIgnoreKeyboardEvents) \(isInteractiveGesture)")
return shouldIgnoreKeyboardEvents || isInteractiveGesture
print("KeyboardEventsIgnorer \(shouldIgnoreKeyboardEvents)")
return shouldIgnoreKeyboardEvents
}

override init() {
Expand Down
34 changes: 2 additions & 32 deletions ios/views/KeyboardGestureAreaManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ - (UIView *)view

// MARK: View
#ifdef RCT_NEW_ARCH_ENABLED
@interface KeyboardGestureArea () <RCTKeyboardGestureAreaViewProtocol, UIGestureRecognizerDelegate>
@interface KeyboardGestureArea () <RCTKeyboardGestureAreaViewProtocol>
#else
@interface KeyboardGestureArea () <UIGestureRecognizerDelegate>
@interface KeyboardGestureArea ()
#endif
@end

@implementation KeyboardGestureArea {
UIPanGestureRecognizer *_panGestureRecognizer;
}

#ifdef RCT_NEW_ARCH_ENABLED
Expand All @@ -84,7 +83,6 @@ + (void)load
- (instancetype)init
{
if (self = [super init]) {
[self setupGestureRecognizers];
}
return self;
}
Expand All @@ -93,40 +91,12 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
{
self = [super initWithFrame:CGRectZero];
if (self) {
[self setupGestureRecognizers];
}

return self;
}
#endif

// MARK: Gesture Recognizers
- (void)setupGestureRecognizers
{
_panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
_panGestureRecognizer.delegate = self; // Set delegate to enable simultaneous recognition
[self addGestureRecognizer:_panGestureRecognizer];
}

- (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
[KeyboardEventsIgnorer shared].isInteractiveGesture = YES;
}
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
NSLog(@"set to false");
[KeyboardEventsIgnorer shared].isInteractiveGesture = NO;
}

}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// Allow simultaneous gesture recognition
return YES;
}

// MARK: lifecycle methods
- (void)didMoveToSuperview
{
Expand Down

0 comments on commit 3c7d00d

Please sign in to comment.