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
14 changes: 1 addition & 13 deletions packages/react-native-gesture-handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,8 @@ export type {
} from './components/Pressable';
export { default as Pressable } from './components/Pressable';

export {
GestureDetector,
InterceptingGestureDetector,
GestureDetectorProps,
VirtualGestureDetector,
} from './v3/detectors';

export * from './v3/hooks/composition';

export type { ComposedGesture } from './v3/types';
export type { GestureTouchEvent as SingleGestureTouchEvent } from './handlers/gestureHandlerCommon';

export * from './v3/hooks/gestures';

export * from './v3/components';
export * from './v3';
Comment thread
j-piasecki marked this conversation as resolved.
Resolved

initialize();
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import createNativeWrapper from '../createNativeWrapper';

import { NativeWrapperProperties } from '../types/NativeWrapperType';
import { NativeWrapperProps } from '../hooks/utils';
import { DetectorType } from '../detectors';
import { GestureDetectorType } from '../detectors';
import { NativeGesture } from '../hooks/gestures/native/useNativeGesture';
import { ghQueueMicrotask } from '../../ghQueueMicrotask';

Expand All @@ -30,7 +30,7 @@ export const RefreshControl = createNativeWrapper(
disallowInterruption: true,
shouldCancelWhenOutside: false,
},
DetectorType.Virtual
GestureDetectorType.Virtual
);

// eslint-disable-next-line @typescript-eslint/no-redeclare
Expand All @@ -42,7 +42,7 @@ const GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>(
disallowInterruption: true,
shouldCancelWhenOutside: false,
},
DetectorType.Intercepting
GestureDetectorType.Intercepting
);

export const ScrollView = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { useNativeGesture } from './hooks/gestures';
import { NativeDetector } from './detectors/NativeDetector';
import type { NativeWrapperProperties } from './types/NativeWrapperType';
import { NativeGesture } from './hooks/gestures/native/useNativeGesture';
import { DetectorType, InterceptingGestureDetector } from './detectors';
import { GestureDetectorType, InterceptingGestureDetector } from './detectors';
import { VirtualDetector } from './detectors/VirtualDetector/VirtualDetector';

export default function createNativeWrapper<P>(
Component: React.ComponentType<P>,
config: Readonly<NativeWrapperProperties> = {},
detectorType: DetectorType = DetectorType.Native
detectorType: GestureDetectorType = GestureDetectorType.Native
) {
const ComponentWrapper = (
props: P &
Expand Down Expand Up @@ -57,9 +57,9 @@ export default function createNativeWrapper<P>(
}, [native, onGestureUpdate_CAN_CAUSE_INFINITE_RERENDER]);

const DetectorComponent =
detectorType === DetectorType.Intercepting
detectorType === GestureDetectorType.Intercepting
? InterceptingGestureDetector
: detectorType === DetectorType.Virtual
: detectorType === GestureDetectorType.Virtual
? VirtualDetector
: NativeDetector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { Animated, StyleSheet } from 'react-native';
import HostGestureDetector from './HostGestureDetector';
import { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector';

export enum GestureDetectorType {
Native,
Virtual,
Intercepting,
}

export interface NativeDetectorProps<THandlerData, TConfig> {
children?: React.ReactNode;
gesture: Gesture<THandlerData, TConfig>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export type { GestureDetectorProps } from './common';
export { GestureDetectorType } from './common';
export { GestureDetector } from './GestureDetector';
export { VirtualDetector as VirtualGestureDetector } from './VirtualDetector/VirtualDetector';
export { InterceptingGestureDetector } from './VirtualDetector/InterceptingGestureDetector';

export enum DetectorType {
Native,
Virtual,
Intercepting,
}
2 changes: 2 additions & 0 deletions packages/react-native-gesture-handler/src/v3/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './composition';
export * from './gestures';
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export function prepareConfigForNativeSide<THandlerData, TConfig>(
return filteredConfig;
}

export function cloneConfig<THandlerData, TConfig>(
function cloneConfig<THandlerData, TConfig>(
config: ExcludeInternalConfigProps<BaseGestureConfig<THandlerData, TConfig>>
): BaseGestureConfig<THandlerData, TConfig> {
return { ...config } as BaseGestureConfig<THandlerData, TConfig>;
}

export function remapProps<
function remapProps<
TConfig extends object,
TInternalConfig extends Record<string, unknown>,
>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function useMemoizedGestureCallbacks<THandlerData>(
);
}

export function getHandler<THandlerData>(
function getHandler<THandlerData>(
type: CALLBACK_TYPE,
callbacks: GestureCallbacks<THandlerData>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon';
import { tagMessage } from '../../../utils';

export function isNativeEvent<THandlerData>(
function isNativeEvent<THandlerData>(
event: GestureHandlerEventWithHandlerData<THandlerData>
): event is
| NativeSyntheticEvent<GestureUpdateEventWithHandlerData<THandlerData>>
Expand Down
49 changes: 43 additions & 6 deletions packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
export * from './configUtils';
export * from './eventHandlersUtils';
export * from './eventUtils';
export * from './reanimatedUtils';
export * from './relationUtils';
export * from './propsWhiteList';
export {
prepareConfig,
prepareConfigForNativeSide,
useClonedAndRemappedConfig,
} from './configUtils';

export {
useMemoizedGestureCallbacks,
touchEventTypeToCallbackType,
runCallback,
} from './eventHandlersUtils';

export {
maybeExtractNativeEvent,
flattenAndFilterEvent,
isEventForHandlerWithTag,
isNativeAnimatedEvent,
checkMappingForChangeProperties,
shouldHandleTouchEvents,
getChangeEventCalculator,
} from './eventUtils';

export {
bindSharedValues,
unbindSharedValues,
hasWorkletEventHandlers,
maybeUnpackValue,
} from './reanimatedUtils';

export {
isComposedGesture,
prepareRelations,
containsDuplicates,
} from './relationUtils';

export {
allowedNativeProps,
NativeWrapperProps,
HandlerCallbacks,
PropsToFilter,
PropsWhiteLists,
EMPTY_WHITE_LIST,
} from './propsWhiteList';
74 changes: 74 additions & 0 deletions packages/react-native-gesture-handler/src/v3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
export type { GestureDetectorProps } from './detectors';
export {
GestureDetector,
VirtualGestureDetector,
InterceptingGestureDetector,
GestureDetectorType,
} from './detectors';

export type {
TapGesture,
TapGestureConfig,
TapGestureEvent,
FlingGesture,
FlingGestureConfig,
FlingGestureEvent,
LongPressGesture,
LongPressGestureConfig,
LongPressGestureEvent,
PinchGesture,
PinchGestureConfig,
PinchGestureEvent,
RotationGesture,
RotationGestureConfig,
RotationGestureEvent,
HoverGesture,
HoverGestureConfig,
HoverGestureEvent,
ManualGesture,
ManualGestureConfig,
ManualGestureEvent,
NativeGesture,
NativeViewGestureConfig,
NativeGestureEvent,
PanGesture,
PanGestureConfig,
PanGestureEvent,
SingleGesture,
SingleGestureEvent,
} from './hooks';
export {
useSimultaneousGestures,
useExclusiveGestures,
useCompetingGestures,
useTapGesture,
useFlingGesture,
useLongPressGesture,
usePinchGesture,
useRotationGesture,
useHoverGesture,
useManualGesture,
useNativeGesture,
usePanGesture,
} from './hooks';

export type {
RawButtonProps,
BaseButtonProps,
RectButtonProps,
BorderlessButtonProps,
} from './components';
export {
RawButton,
BaseButton,
RectButton,
BorderlessButton,
PureNativeButton,
ScrollView,
Switch,
TextInput,
FlatList,
RefreshControl,
} from './components';

export type { ComposedGesture } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type StateChangeEventPayload = EventPayload & {
oldState: State;
};

export type BaseHandlerData = {
type BaseHandlerData = {
numberOfPointers: number;
pointerType: PointerType;
};
Expand Down
55 changes: 49 additions & 6 deletions packages/react-native-gesture-handler/src/v3/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
export * from './ReanimatedTypes';
export * from './ConfigTypes';
export * from './EventTypes';
export * from './DetectorTypes';
export * from './GestureTypes';
export * from './UtilityTypes';
export type {
SharedValue,
SharedValueOrT,
WithSharedValue,
} from './ReanimatedTypes';

export type {
HandlerData,
GestureUpdateEventWithHandlerData,
GestureStateChangeEventWithHandlerData,
GestureHandlerEventWithHandlerData,
UnpackedGestureHandlerEventWithHandlerData,
UnpackedGestureHandlerEvent,
UpdateEventWithHandlerData,
StateChangeEventWithHandlerData,
TouchEvent,
GestureEvent,
AnimatedEvent,
ChangeCalculatorType,
DiffCalculatorType,
} from './EventTypes';

export type {
GestureCallbacks,
GestureRelations,
InternalConfigProps,
CommonGestureConfig,
ComposedGestureConfig,
} from './ConfigTypes';

export type { DetectorCallbacks, VirtualChild } from './DetectorTypes';

export { SingleGestureName, ComposedGestureName } from './GestureTypes';
export type {
ExternalRelations,
BaseDiscreteGestureConfig,
BaseGestureConfig,
SingleGesture,
DiscreteSingleGesture,
ComposedGesture,
Gesture,
AnyGesture,
} from './GestureTypes';

export type {
HandlersPropsWhiteList,
FilterNeverProperties,
ExcludeInternalConfigProps,
} from './UtilityTypes';
Loading