import React, { useEffect } from 'react';
import { View, StyleSheet, TouchableOpacity } from 'react-native';
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { ThemeProvider, DarkTheme, DefaultTheme, NavigationContainer } from '@react-navigation/native';
import Settings from '@/components/Settings';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomeScreen from '.';
import { LanguageSelection } from '@/components/LanguageSelection';
import { language_matrix_entry } from '../i18n/api';
import ConversationThread from '@/components/ConversationThread';


const Stack = createNativeStackNavigator();

export default function _layout() {
  const [loaded] = useFonts({
    SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
  });

  useEffect(() => {
    if (loaded) {
      SplashScreen.hideAsync();
    }
  }, [loaded]);

  if (!loaded) {
    return null;
  }

  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
          name="Home"
          component={HomeScreen}
          options={{title: 'Welcome'}}
        />
        <Stack.Screen
          name="LanguageSelection"
          component={LanguageSelection}
        />
        <Stack.Screen
          name="Conversation"
          component={ConversationThread}
        />
        <Stack.Screen name="Settings" component={Settings} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

const styles = StyleSheet.create({
  settingsIconContainer: {
    marginLeft: 16,
  },
});