// components/EditableText.tsx import React, { useState, useRef } from 'react'; import { TextInput, TouchableOpacity, StyleSheet, View, StyleProp, ViewStyle, TextStyle } from 'react-native'; import { Text } from '@/components/ui/text'; import { Check, Edit2 } from 'lucide-react-native'; import { cn } from '@/lib/utils'; import { useColorScheme } from '@/lib/theme/useColorScheme'; import { useIconColor } from '@/lib/theme/iconUtils'; interface EditableTextProps { value: string; onChangeText: (text: string) => void; style?: StyleProp; textStyle?: StyleProp; inputStyle?: StyleProp; placeholder?: string; placeholderTextColor?: string; } export default function EditableText({ value, onChangeText, style, textStyle, inputStyle, placeholder, placeholderTextColor }: EditableTextProps) { const [isEditing, setIsEditing] = useState(false); const [tempValue, setTempValue] = useState(value); const inputRef = useRef(null); const { isDarkColorScheme } = useColorScheme(); const { getIconProps } = useIconColor(); const handleSubmit = () => { if (tempValue.trim()) { onChangeText(tempValue); } else { setTempValue(value); } setIsEditing(false); }; return ( {isEditing ? ( ) : ( setIsEditing(true)} className="flex-col p-2 rounded-lg" activeOpacity={0.7} > {value || placeholder} Edit )} ); } const styles = StyleSheet.create({ container: { flexDirection: 'column', }, input: { flex: 1, fontSize: 18, fontWeight: '600', padding: 0, }, });