diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 8b9b37e..291255a 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,10 +1,17 @@ import { LanguageSelection } from '@/components/LanguageSelection'; +import { useState } from 'react'; import { Text } from 'react-native'; import { Image, StyleSheet, Platform } from 'react-native'; +import { Conversation, Speaker } from '../lib/conversation'; +import { language_matrix_entry, Translator } from '../i18n/api'; export default function HomeScreen() { + + const [language, setLanguage] = useState() + return ( - + language ? : + setLanguage(l)} /> ); } diff --git a/components/ConversationPlay.tsx b/components/ConversationPlay.tsx new file mode 100644 index 0000000..9f49423 --- /dev/null +++ b/components/ConversationPlay.tsx @@ -0,0 +1,107 @@ + +interface ConversationPlayProps { + translator: Translator; +} + +function ConversationPlay (props : ConversationPlayProps) { + const [language, setLanguage] = useState(languages[0].code); + const [message, setMessage] = useState(''); + const [conversation, setConversation] = useState(null); + + const startConversation = () => { + const speaker: Speaker = { id: "user", language }; + const newConversation = new Conversation(translator, speaker); + setConversation(newConversation); + }; + + const addMessage = async () => { + if (conversation) { + conversation.addMessage({ id: "user", language }, message); + await conversation.translateLast(); + setMessage(''); + } + }; + + return ( + + Select Language: + {languages.map(lang => ( +