import React, { useState, useEffect } from 'react'; import { View } from 'react-native'; import { useTheme } from '~/features/theme/ThemeProvider'; import Text from '~/components/atoms/Text'; import Button from '~/components/atoms/Button'; import Input from '~/components/atoms/Input'; import BaseModal from '~/components/atoms/BaseModal'; import { useTranslation } from 'react-i18next'; interface ReplaceWordModalProps { visible: boolean; onClose: () => void; onSubmit: (wordToReplace: string, replacementWord: string) => void; initialWordToReplace?: string; initialReplacementWord?: string; } /** * Modal component for replacing words in text * * Allows input of a word to replace and a replacement word. */ const ReplaceWordModal: React.FC = ({ visible, onClose, onSubmit, initialWordToReplace = '', initialReplacementWord = '', }) => { const { isDark } = useTheme(); const { t } = useTranslation(); // Debug borders (set to true to enable) const DEBUG_BORDERS = false; // State for input fields const [wordToReplace, setWordToReplace] = useState(initialWordToReplace); const [replacementWord, setReplacementWord] = useState(initialReplacementWord); // Reset input fields when initial values change useEffect(() => { setWordToReplace(initialWordToReplace); setReplacementWord(initialReplacementWord); }, [initialWordToReplace, initialReplacementWord]); // Handler for form submission const handleSubmit = () => { onSubmit(wordToReplace, replacementWord); onClose(); }; // Render the form content const renderContent = () => ( {t('memo.word_to_replace', 'Zu ersetzendes Wort:')} {t('memo.new_word', 'Neues Wort:')} ); // Render the footer with action buttons const renderFooter = () => (