Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/docs-gesture-handler/docs/components/touchable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -237,29 +237,23 @@ defaultUnderlayOpacity?: number;

Defines the initial opacity of underlay when the button is inactive. By default set to `0`.

<Badges platforms={['web', 'android']}>
### hoverOpacity
</Badges>

```ts
hoverOpacity?: number;
```

Defines the opacity of the whole component when the button is hovered. By default falls back to [`defaultOpacity`](#defaultopacity).

<Badges platforms={['web', 'android']}>
### hoverScale
</Badges>

```ts
hoverScale?: number;
```

Defines the scale of the whole component when the button is hovered. By default falls back to [`defaultScale`](#defaultscale).

<Badges platforms={['web', 'android']}>
### hoverUnderlayOpacity
</Badges>

```ts
hoverUnderlayOpacity?: number;
Expand Down Expand Up @@ -296,7 +290,7 @@ Press and hover animation timing, in milliseconds. Defaults to 50ms for the in p

Each animation has two phases — `in` (running while the pointer engages the component) and `out` (running after the pointer releases) — across two categories:
- `tap` — applies to presses.
- `hover` — pointer hover (web and Android).
- `hover` — pointer hover.

`longPress` is an optional override for the press-out timing once the press has been held past [`delayLongPress`](#delaylongpress). It only has an `out` field (the press-in is always the `tap` in duration). If omitted, the long-press release uses the resolved `tap` out duration.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/software-mansion/react-native-gesture-handler", :tag => "#{s.version}" }
s.source_files = "apple/**/*.{h,m,mm}", "shared/**/*.{h,cpp}"
s.requires_arc = true
s.platforms = { ios: '11.0', tvos: '11.0', osx: '10.15', visionos: '1.0' }
s.platforms = { ios: '15.1', tvos: '15.1', osx: '14.0', visionos: '1.0' }
s.xcconfig = {
"OTHER_CFLAGS" => "$(inherited) #{compilation_metadata_generation_flag} #{version_flag}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ - (void)performFeedbackIfRequired
{
#if !TARGET_OS_TV && !TARGET_OS_VISION
if (_feedbackOnActivation) {
if (@available(iOS 10.0, *)) {
[[[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleMedium)] impactOccurred];
}
[[[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleMedium)] impactOccurred];
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@

#import "RNGestureHandler.h"

API_AVAILABLE(ios(13.4))
@interface RNHoverGestureHandler : RNGestureHandler
@end
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@
#import <React/RCTConvert.h>
#import <UIKit/UIGestureRecognizerSubclass.h>

#define CHECK_TARGET(__VERSION__) \
defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_##__VERSION__) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_##__VERSION__ && !TARGET_OS_TV

typedef NS_ENUM(NSInteger, RNGestureHandlerHoverEffect) {
RNGestureHandlerHoverEffectNone = 0,
RNGestureHandlerHoverEffectLift,
RNGestureHandlerHoverEffectHightlight,
};

#if CHECK_TARGET(13_4)
#if !TARGET_OS_TV

API_AVAILABLE(ios(13.4))
@interface RNBetterHoverGestureRecognizer : UIHoverGestureRecognizer <UIPointerInteractionDelegate>

- (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler;
Expand Down Expand Up @@ -85,7 +80,7 @@ - (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction style
#endif

@implementation RNHoverGestureHandler {
#if CHECK_TARGET(13_4)
#if !TARGET_OS_TV
UIPointerInteraction *_pointerInteraction;
#endif
}
Expand All @@ -97,67 +92,55 @@ - (instancetype)initWithTag:(NSNumber *)tag
#endif

if ((self = [super initWithTag:tag])) {
#if CHECK_TARGET(13_4)
if (@available(iOS 13.4, *)) {
_recognizer = [[RNBetterHoverGestureRecognizer alloc] initWithGestureHandler:self];
_pointerInteraction =
[[UIPointerInteraction alloc] initWithDelegate:(id<UIPointerInteractionDelegate>)_recognizer];
}
#if !TARGET_OS_TV
_recognizer = [[RNBetterHoverGestureRecognizer alloc] initWithGestureHandler:self];
_pointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:(id<UIPointerInteractionDelegate>)_recognizer];
#endif
}
return self;
}

- (void)bindToView:(UIView *)view
{
#if CHECK_TARGET(13_4)
if (@available(iOS 13.4, *)) {
[super bindToView:view];
[view addInteraction:_pointerInteraction];
}
#if !TARGET_OS_TV
[super bindToView:view];
[view addInteraction:_pointerInteraction];
#endif
}

- (void)unbindFromView
{
#if CHECK_TARGET(13_4)
if (@available(iOS 13.4, *)) {
// Remove the interaction before [super unbindFromView] detaches the recognizer and nils recognizer.view.
[self.recognizer.view removeInteraction:_pointerInteraction];
[super unbindFromView];
}
#if !TARGET_OS_TV
[self.recognizer.view removeInteraction:_pointerInteraction];
[super unbindFromView];
#endif
}

- (void)resetConfig
{
[super resetConfig];

#if CHECK_TARGET(13_4)
if (@available(iOS 13.4, *)) {
RNBetterHoverGestureRecognizer *recognizer = (RNBetterHoverGestureRecognizer *)_recognizer;
recognizer.hoverEffect = RNGestureHandlerHoverEffectNone;
}
#if !TARGET_OS_TV
RNBetterHoverGestureRecognizer *recognizer = (RNBetterHoverGestureRecognizer *)_recognizer;
recognizer.hoverEffect = RNGestureHandlerHoverEffectNone;
#endif
}

- (void)updateConfig:(NSDictionary *)config
{
[super updateConfig:config];

#if CHECK_TARGET(13_4)
if (@available(iOS 13.4, *)) {
RNBetterHoverGestureRecognizer *recognizer = (RNBetterHoverGestureRecognizer *)_recognizer;
APPLY_INT_PROP(hoverEffect);
}
#if !TARGET_OS_TV
RNBetterHoverGestureRecognizer *recognizer = (RNBetterHoverGestureRecognizer *)_recognizer;
APPLY_INT_PROP(hoverEffect);
#endif
}

- (void)setCurrentPointerType:(RNGestureHandlerPointerType)pointerType
{
_pointerType = pointerType;

#if CHECK_TARGET(16_1)
#if !TARGET_OS_TV
if (@available(iOS 16.1, *)) {
if (((UIHoverGestureRecognizer *)self.recognizer).zOffset > 0.0) {
_pointerType = RNGestureHandlerStylus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,9 @@ - (void)resetConfig
recognizer.activeOffsetYStart = NAN;
recognizer.activeOffsetYEnd = NAN;
recognizer.failOffsetYStart = NAN;
recognizer.failOffsetYStart = NAN;
recognizer.failOffsetYEnd = NAN;
#if !TARGET_OS_OSX && !TARGET_OS_TV && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130400
if (@available(iOS 13.4, *)) {
recognizer.allowedScrollTypesMask = 0;
}
#endif
#if !TARGET_OS_OSX && !TARGET_OS_TV
recognizer.allowedScrollTypesMask = 0;
recognizer.minimumNumberOfTouches = 1;
recognizer.maximumNumberOfTouches = NSUIntegerMax;
#endif
Expand All @@ -412,12 +407,10 @@ - (void)updateConfig:(NSDictionary *)config
APPLY_FLOAT_PROP(failOffsetYStart);
APPLY_FLOAT_PROP(failOffsetYEnd);

#if !TARGET_OS_OSX && !TARGET_OS_TV && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130400
if (@available(iOS 13.4, *)) {
bool enableTrackpadTwoFingerGesture = [RCTConvert BOOL:config[@"enableTrackpadTwoFingerGesture"]];
if (enableTrackpadTwoFingerGesture) {
recognizer.allowedScrollTypesMask = UIScrollTypeMaskAll;
}
#if !TARGET_OS_OSX && !TARGET_OS_TV
bool enableTrackpadTwoFingerGesture = [RCTConvert BOOL:config[@"enableTrackpadTwoFingerGesture"]];
if (enableTrackpadTwoFingerGesture) {
recognizer.allowedScrollTypesMask = UIScrollTypeMaskAll;
}

APPLY_NAMED_INT_PROP(minimumNumberOfTouches, @"minPointers");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
@property (nonatomic, assign) CGFloat defaultScale;
@property (nonatomic, assign) CGFloat defaultUnderlayOpacity;
@property (nonatomic, assign) CGFloat activeUnderlayOpacity;
@property (nonatomic, assign) NSInteger hoverAnimationInDuration;
@property (nonatomic, assign) NSInteger hoverAnimationOutDuration;
@property (nonatomic, assign) CGFloat hoverOpacity;
@property (nonatomic, assign) CGFloat hoverScale;
@property (nonatomic, assign) CGFloat hoverUnderlayOpacity;
@property (nonatomic, strong, nullable) RNGHColor *underlayColor;

/**
Expand All @@ -54,6 +59,8 @@
#if TARGET_OS_TV
- (void)handleAnimatePressIn;
- (void)handleAnimatePressOut;
- (void)onHoverIn;
- (void)onHoverOut;
#endif // TARGET_OS_TV

/**
Expand Down
Loading
Loading