import React from 'react';
import {Pressable, PressableProps} from 'react-native';
import {IconProps} from '@tabler/icons-react-native';
import {useTheme} from '@shared/theme';

import {styles} from './styles';

interface Props extends PressableProps {
  Icon?: React.ComponentType<IconProps>;
  onPress: () => void;
  active?: boolean;
}

export function BaseButton({disabled, Icon, active, ...props}: Props) {
  const {theme} = useTheme();
  return (
    <Pressable
      {...props}
      disabled={disabled}
      style={[
        styles.baseButton,
        active && {backgroundColor: theme.action.background.neutral.hover},
      ]}>
      {Icon && (
        <Icon
          stroke={
            disabled ? theme.text.neutral.disabled : theme.text.neutral.default
          }
        />
      )}
    </Pressable>
  );
}
