import {memo, PropsWithChildren} from 'react';
import {RNGesturePressable, RNGesturePressableProps} from '@components';

import {GestureEvent} from './types';

interface Props
  extends Pick<
    RNGesturePressableProps,
    'gestureOffsetLeft' | 'gestureOffsetRight'
  > {
  onGesture: (e: GestureEvent) => void;
}

const GestureContainer = memo(
  ({
    children,
    onGesture,
    gestureOffsetLeft,
    gestureOffsetRight,
  }: PropsWithChildren<Props>) => {
    return (
      <RNGesturePressable
        withHaptic
        onDoubleTap={onGesture}
        onLongPress={onGesture}
        gestureOffsetLeft={gestureOffsetLeft}
        gestureOffsetRight={gestureOffsetRight}>
        {children}
      </RNGesturePressable>
    );
  },
);

export default GestureContainer;
