import React, { ForwardedRef } from 'react';
import { View, ViewStyle } from 'react-native';

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

type PagerViewRef = {
  setPage: (page: number) => void;
  setPageWithoutAnimation: (page: number) => void;
  setScrollEnabled: (scrollEnabled: boolean) => void;
};

function PagerViewInternal(
  { style, children }: PagerViewProps,
  _ref: ForwardedRef<PagerViewRef>
) {
  const childrenArray = React.Children.toArray(children);
  return (
    <View style={style}>
      {childrenArray[0]}
    </View>
  );
}

export const PagerView = React.forwardRef(PagerViewInternal);
PagerView.displayName = 'PagerView';

export default PagerView;
