import React from 'react';
import { ViewStyle } from 'react-native';
import PagerViewNative from 'react-native-pager-view';

type PagerViewProps = {
  style?: ViewStyle;
  initialPage?: number;
  onPageSelected?: (e: { nativeEvent: { position: number } }) => void;
  overdrag?: boolean;
  children: React.ReactNode;
};

export const PagerView = React.forwardRef<PagerViewNative, PagerViewProps>(
  ({ style, initialPage, onPageSelected, overdrag, children }, ref) => {
    return (
      <PagerViewNative
        ref={ref}
        style={style}
        initialPage={initialPage}
        onPageSelected={onPageSelected}
        overdrag={overdrag}
      >
        {children}
      </PagerViewNative>
    );
  }
);

PagerView.displayName = 'PagerView';

export default PagerView;
