import { useLanguage } from '@/common/hooks/useStrings';
import { TextInput as RNTextInput, TextInputProps, StyleSheet, TextStyle } from 'react-native';

const FONT_SCALE = 1.15;

const fonts = {
  en: 'CormorantGaramond_600SemiBold',
  ko: 'NanumMyeongjo_400Regular',
};

export function TextInput({ style, ...props }: TextInputProps) {
  const { language } = useLanguage();
  const flat = StyleSheet.flatten(style) as TextStyle | undefined;
  const size = (flat?.fontSize ?? 14) * FONT_SCALE;

  return (
    <RNTextInput
      style={[style, { fontFamily: fonts[language], fontSize: size, letterSpacing: 0.3 }]}
      {...props}
    />
  );
}
