import React from 'react';
import {
  RefreshControl as RNRefreshControl,
  RefreshControlProps,
} from 'react-native';
import {useTheme} from '@shared/theme';

interface Props extends Omit<RefreshControlProps, 'tintColor' | 'colors'> {
  color?: string;
}

export const RefreshControl = ({color, ...props}: Props) => {
  const {theme} = useTheme();
  return (
    <RNRefreshControl
      {...props}
      tintColor={color || theme.primary}
      colors={[color || theme.primary]}
    />
  );
};
