Differentiate swipe and tap events (#22916)

Summary:
Motivation:
----------

As developers want to handle multiple actions on Siri Remote input when using TVEventHandler, it is crucial to differentiate 'swap' and 'tap' events.

Changelog:
----------

[tvOS] [Changed] - 'up', 'down', 'left' and 'right' events are now connected with tapping on edges of remote. New events 'swipeUp', 'swipeDown', 'swipeLeft' and 'swipeRight' added to detect swipes.
Pull Request resolved: https://github.com/facebook/react-native/pull/22916

Differential Revision: D13682705

Pulled By: hramos

fbshipit-source-id: 233ad1cecc04ca4ced75cd00e7fcb65d224ed3ca
This commit is contained in:
Wojciech Tyczynski 2019-01-15 16:08:32 -08:00 committed by Facebook Github Bot
parent bb9d013935
commit 3654b9edb2
1 changed files with 27 additions and 7 deletions

View File

@ -69,22 +69,22 @@ NSString *const RCTTVRemoteEventSwipeDown = @"swipeDown";
name:RCTTVRemoteEventSelect];
// Up
[self addTapGestureRecognizerWithSelector:@selector(swipedUp:)
[self addTapGestureRecognizerWithSelector:@selector(tappedUp:)
pressType:UIPressTypeUpArrow
name:RCTTVRemoteEventUp];
// Down
[self addTapGestureRecognizerWithSelector:@selector(swipedDown:)
[self addTapGestureRecognizerWithSelector:@selector(tappedDown:)
pressType:UIPressTypeDownArrow
name:RCTTVRemoteEventDown];
// Left
[self addTapGestureRecognizerWithSelector:@selector(swipedLeft:)
[self addTapGestureRecognizerWithSelector:@selector(tappedLeft:)
pressType:UIPressTypeLeftArrow
name:RCTTVRemoteEventLeft];
// Right
[self addTapGestureRecognizerWithSelector:@selector(swipedRight:)
[self addTapGestureRecognizerWithSelector:@selector(tappedRight:)
pressType:UIPressTypeRightArrow
name:RCTTVRemoteEventRight];
@ -158,20 +158,40 @@ NSString *const RCTTVRemoteEventSwipeDown = @"swipeDown";
- (void)swipedUp:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventUp toView:r.view];
[self sendAppleTVEvent:RCTTVRemoteEventSwipeUp toView:r.view];
}
- (void)swipedDown:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventDown toView:r.view];
[self sendAppleTVEvent:RCTTVRemoteEventSwipeDown toView:r.view];
}
- (void)swipedLeft:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventLeft toView:r.view];
[self sendAppleTVEvent:RCTTVRemoteEventSwipeLeft toView:r.view];
}
- (void)swipedRight:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventSwipeRight toView:r.view];
}
- (void)tappedUp:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventUp toView:r.view];
}
- (void)tappedDown:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventDown toView:r.view];
}
- (void)tappedLeft:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventLeft toView:r.view];
}
- (void)tappedRight:(UIGestureRecognizer *)r
{
[self sendAppleTVEvent:RCTTVRemoteEventRight toView:r.view];
}