
import * as React from 'react';
import { View, Text, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
import { useTranslation } from 'react-i18next';

type RootStackParamList = {
  Home: undefined,
  Loby: undefined,
  Game: {gameId: string}
};

type HomeScreenProps = NativeStackScreenProps<RootStackParamList, 'Home'>;
type LobyScreenProps = NativeStackScreenProps<RootStackParamList, 'Loby'>;

function HomeScreen({ navigation, route }: HomeScreenProps) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Button 
        title='New Game'
        onPress={() => navigation.navigate('Loby')}></Button>
    </View>
  );
}

function LobyScreen({ navigation, route }: LobyScreenProps) {
  const { t } = useTranslation();

  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>{t('hello')}</Text>
    </View>
  );
}

const Stack = createNativeStackNavigator<RootStackParamList>();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Loby" component={LobyScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;