import React from 'react';
import { TextStyle, PressableProps, DimensionValue } from 'react-native';
import ThemedButton from '@/components/theme/buttons/ThemedButton';
import ThemedText from '@/components/theme/default/ThemedText';
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';

// Extend ThemedButton props (which already extends PressableProps)
type ThemedTextButtonProps = Omit<PressableProps, 'children'> & {
  width?: DimensionValue;
  height?: DimensionValue;
  text: string;
  fontSize?: number;
  fontWeight?: 'normal' | 'semibold' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
  textStyle?: TextStyle;
  containerStyle?: object;
  buttonStyle?: object;
};

const ThemedTextButton: React.FC<ThemedTextButtonProps> = ({
  width,
  height,
  text,
  fontSize = 16,
  fontWeight = 'normal',
  textStyle,
  containerStyle,
  buttonStyle,
  ...restProps // This includes onPress and all other Pressable props
}) => {
  const scheme = useColorScheme() ?? 'dark';
  if (fontWeight === 'semibold') fontWeight = '600';

  return (
    <ThemedButton
      width={width}
      height={height}
      containerStyle={containerStyle}
      buttonStyle={buttonStyle}
      {...restProps}
    >
      <ThemedText
        style={[
          {
            color: Colors[scheme].background,
            fontSize,
            lineHeight: fontSize * 1.5,
            fontWeight,
          },
          textStyle,
        ]}
      >
        {text}
      </ThemedText>
    </ThemedButton>
  );
};

export default ThemedTextButton;
