import React, { useCallback, useRef, useState } from "react"; import { Keyboard, Pressable, Text, TextInput, View, } from "react-native"; import { VoiceButton } from "./VoiceButton"; interface InputBarProps { onSendText: (text: string) => void; onSendVoice: (audioUri: string, durationMs: number) => void; } export function InputBar({ onSendText, onSendVoice }: InputBarProps) { const [text, setText] = useState(""); const [isVoiceMode, setIsVoiceMode] = useState(false); const inputRef = useRef(null); const handleSend = useCallback(() => { const trimmed = text.trim(); if (!trimmed) return; onSendText(trimmed); setText(""); }, [text, onSendText]); const toggleMode = useCallback(() => { setIsVoiceMode((prev) => { if (prev) { // Switching to text mode — focus input after mode switch setTimeout(() => inputRef.current?.focus(), 100); } else { Keyboard.dismiss(); } return !prev; }); }, []); if (isVoiceMode) { return ( {/* Mode toggle */} ⌨️ ); } return ( {/* Voice mode toggle */} 🎤 {/* Text input */} {/* Send button */} ); }