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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.swmansion.gesturehandler.react

import com.facebook.react.bridge.ReadableArray
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.PointerEvents.Companion.parsePointerEvents
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewGroupManager
import com.facebook.react.uimanager.ViewManagerDelegate
Expand Down Expand Up @@ -45,4 +46,8 @@ class RNGestureHandlerDetectorViewManager :
view.onViewDrop()
super.onDropViewInstance(view)
}

override fun setPointerEvents(view: RNGestureHandlerDetectorView, pointerEventsStr: String?) {
view.pointerEvents = parsePointerEvents(pointerEventsStr)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
DirectEventHandler,
UnsafeMixed,
Double,
WithDefault,
} from 'react-native/Libraries/Types/CodegenTypes';
import type { ViewProps } from 'react-native';

Expand Down Expand Up @@ -47,6 +48,8 @@ export interface VirtualChildrenProps {
viewTag: Int32;
}

// @ts-expect-error WithDefault adds `| null` to the type, which doesn't align with ViewProps.pointerEvents
// Using Exclude to remove null from the type makes the error go away, but breaks codegen.
export interface NativeProps extends ViewProps {
onGestureHandlerEvent?: DirectEventHandler<GestureHandlerEvent>;
onGestureHandlerStateChange?: DirectEventHandler<GestureHandlerStateChangeEvent>;
Expand All @@ -59,6 +62,11 @@ export interface NativeProps extends ViewProps {
handlerTags: Int32[];
moduleId: Int32;
virtualChildren: VirtualChildrenProps[];

pointerEvents?: WithDefault<
'box-none' | 'none' | 'box-only' | 'auto',
'auto'
>;
}

export default codegenNativeComponent<NativeProps>('RNGestureHandlerDetector', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function NativeDetector<THandlerData, TConfig>({

return (
<NativeDetectorComponent
pointerEvents={'box-none'}
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types
onGestureHandlerStateChange={
gesture.detectorCallbacks.onGestureHandlerStateChange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export function InterceptingGestureDetector<THandlerData, TConfig>({
return (
<InterceptingDetectorContext value={contextValue}>
<NativeDetectorComponent
pointerEvents={'box-none'}
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types
onGestureHandlerStateChange={useMemo(
() => createGestureEventHandler('onGestureHandlerStateChange'),
Expand Down
Loading