import React from 'react';
import { View, ViewStyle, TouchableOpacity } from 'react-native';
import { useAppTheme } from '@theme';
import { getStyles } from './card.styles';

interface CardProps {
  children: React.ReactNode;
  style?: ViewStyle;
  onPress?: () => void;
}

export const Card: React.FC<CardProps> = ({ children, style, onPress }) => {
  const { colors } = useAppTheme();
  const styles = getStyles(colors);

  if (onPress) {
    return (
      <TouchableOpacity
        style={[styles.card, style]}
        activeOpacity={0.8}
        onPress={onPress}
      >
        {children}
      </TouchableOpacity>
    );
  }

  return <View style={[styles.card, style]}>{children}</View>;
};
export default Card;
