Ei kuvausta

_layout.tsx 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
  2. import { Stack } from 'expo-router';
  3. import { StatusBar } from 'expo-status-bar';
  4. import 'react-native-reanimated';
  5. import { useColorScheme } from '@/hooks/use-color-scheme';
  6. import { LocalizationProvider, useTranslation } from '@/localization/i18n';
  7. export const unstable_settings = {
  8. anchor: '(tabs)',
  9. };
  10. export default function RootLayout() {
  11. const colorScheme = useColorScheme();
  12. return (
  13. <LocalizationProvider>
  14. <RootNavigator colorScheme={colorScheme} />
  15. </LocalizationProvider>
  16. );
  17. }
  18. function RootNavigator({ colorScheme }: { colorScheme: string | null }) {
  19. const { t } = useTranslation();
  20. return (
  21. <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
  22. <Stack>
  23. <Stack.Screen name="(tabs)" options={{ headerShown: false, title: '' }} />
  24. <Stack.Screen
  25. name="fields"
  26. options={{
  27. headerShown: true,
  28. title: t('fields.title'),
  29. headerBackTitleVisible: false,
  30. headerBackTitle: '',
  31. }}
  32. />
  33. <Stack.Screen
  34. name="tasks"
  35. options={{
  36. headerShown: true,
  37. title: t('tasks.title'),
  38. headerBackTitleVisible: false,
  39. headerBackTitle: '',
  40. }}
  41. />
  42. <Stack.Screen
  43. name="task-history"
  44. options={{
  45. headerShown: true,
  46. title: t('tasks.historyTitle'),
  47. headerBackTitleVisible: false,
  48. headerBackTitle: '',
  49. }}
  50. />
  51. <Stack.Screen
  52. name="observations"
  53. options={{
  54. headerShown: true,
  55. title: t('observations.title'),
  56. headerBackTitleVisible: false,
  57. headerBackTitle: '',
  58. }}
  59. />
  60. <Stack.Screen
  61. name="crops"
  62. options={{
  63. headerShown: true,
  64. title: t('crops.title'),
  65. headerBackTitleVisible: false,
  66. headerBackTitle: '',
  67. }}
  68. />
  69. <Stack.Screen
  70. name="harvests"
  71. options={{
  72. headerShown: true,
  73. title: t('harvests.title'),
  74. headerBackTitleVisible: false,
  75. headerBackTitle: '',
  76. }}
  77. />
  78. <Stack.Screen
  79. name="sales"
  80. options={{
  81. headerShown: true,
  82. title: t('sales.title'),
  83. headerBackTitleVisible: false,
  84. headerBackTitle: '',
  85. }}
  86. />
  87. <Stack.Screen
  88. name="costs"
  89. options={{
  90. headerShown: true,
  91. title: t('costs.title'),
  92. headerBackTitleVisible: false,
  93. headerBackTitle: '',
  94. }}
  95. />
  96. <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
  97. </Stack>
  98. <StatusBar style="auto" />
  99. </ThemeProvider>
  100. );
  101. }