import { Pressable, type PressableProps } from 'react-native'

type PressableOpacityProps = PressableProps & {
  activeOpacity?: number
}

/**
 * Drop-in replacement for the abandoned `react-native-pressable-opacity` package.
 * Renders a standard RN Pressable that dims to `activeOpacity` (default 0.6) when pressed.
 */
export function PressableOpacity({
  activeOpacity = 0.6,
  style,
  ...rest
}: PressableOpacityProps) {
  return (
    <Pressable
      style={(state) => [
        typeof style === 'function' ? style(state) : style,
        state.pressed && { opacity: activeOpacity },
      ]}
      {...rest}
    />
  )
}

export default PressableOpacity
