Nav apraksta

_layout.tsx 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
  2. import { Stack, useRouter } from 'expo-router';
  3. import { StatusBar } from 'expo-status-bar';
  4. import 'react-native-reanimated';
  5. import { Pressable } from 'react-native';
  6. import { IconSymbol } from '@/components/ui/icon-symbol';
  7. import { useColorScheme } from '@/hooks/use-color-scheme';
  8. import { LocalizationProvider, useTranslation } from '@/localization/i18n';
  9. export const unstable_settings = {
  10. anchor: '(tabs)',
  11. };
  12. export default function RootLayout() {
  13. const colorScheme = useColorScheme();
  14. return (
  15. <LocalizationProvider>
  16. <RootNavigator colorScheme={colorScheme} />
  17. </LocalizationProvider>
  18. );
  19. }
  20. function RootNavigator({ colorScheme }: { colorScheme: string | null }) {
  21. const { t } = useTranslation();
  22. const router = useRouter();
  23. return (
  24. <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
  25. <Stack
  26. screenOptions={{
  27. headerBackTitleVisible: false,
  28. headerBackTitle: '',
  29. headerBackTitleStyle: { display: 'none' },
  30. headerLeft: ({ canGoBack, tintColor }) =>
  31. canGoBack ? (
  32. <Pressable onPress={() => router.back()} hitSlop={10} style={{ paddingHorizontal: 8 }}>
  33. <IconSymbol
  34. name="chevron.left"
  35. size={20}
  36. color={tintColor ?? (colorScheme === 'dark' ? '#FFFFFF' : '#1C1C1C')}
  37. />
  38. </Pressable>
  39. ) : null,
  40. }}>
  41. <Stack.Screen name="(tabs)" options={{ headerShown: false, title: '' }} />
  42. <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
  43. </Stack>
  44. <StatusBar style="auto" />
  45. </ThemeProvider>
  46. );
  47. }