mancala/mobile/App.tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
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';
2024-03-24 14:05:32 +03:00
import { useTranslation } from 'react-i18next';
2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
type RootStackParamList = {
Home: undefined,
Loby: undefined,
Game: {gameId: string}
};
2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
type HomeScreenProps = NativeStackScreenProps<RootStackParamList, 'Home'>;
type LobyScreenProps = NativeStackScreenProps<RootStackParamList, 'Loby'>;
2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
function HomeScreen({ navigation, route }: HomeScreenProps) {
2024-03-24 03:47:18 +03:00
return (
2024-03-24 13:34:12 +03:00
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
title='New Game'
onPress={() => navigation.navigate('Loby')}></Button>
2024-03-24 03:47:18 +03:00
</View>
);
}
2024-03-24 13:34:12 +03:00
function LobyScreen({ navigation, route }: LobyScreenProps) {
2024-03-24 14:05:32 +03:00
const { t } = useTranslation();
2024-03-24 13:34:12 +03:00
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2024-03-24 14:05:32 +03:00
<Text>{t('hello')}</Text>
2024-03-24 13:34:12 +03:00
</View>
);
}
2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
const Stack = createNativeStackNavigator<RootStackParamList>();
2024-03-24 03:47:18 +03:00
2024-03-24 13:34:12 +03:00
function App() {
2024-03-24 03:47:18 +03:00
return (
2024-03-24 13:34:12 +03:00
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Loby" component={LobyScreen} />
</Stack.Navigator>
</NavigationContainer>
2024-03-24 03:47:18 +03:00
);
}
2024-03-24 13:34:12 +03:00
export default App;