frontend: fix tabs routes mess
I was kind of applying a weird pattern nesting those tabs, after re-reading and watching some other apps, I've realized that expo-router wants somewhat flat directories, so tabs initial pages must go flat-wise then the other pages must be outside the tags route group. I might also need to use `<Slot />` as well, since I think those are incorrect there instead of re-rendering the whole layout for those tabs, but I'll get there eventually
Parents:
f037eb77 file(s) changed
- frontend/app/(tabs)/_layout.tsx +4 -4
- frontend/app/(tabs)/actions.tsx +0 -0
- frontend/app/(tabs)/history.tsx +0 -0
- frontend/app/(tabs)/insights.tsx +0 -0
- frontend/app/(tabs)/settings.tsx +0 -0
- frontend/app/_layout.tsx +2 -1
- frontend/app/index.tsx +17 -0
frontend/app/(tabs)/_layout.tsx
@@ -40,7 +40,7 @@ tabBarButton: HapticTab,
40 40 }}>
41 41
42 42 <Tabs.Screen
43 - name="history/index"
43 + name="history"
44 44 options={{
45 45 title: 'Histórico',
46 46 tabBarIcon: ({ color }) => <IconSymbol size={28} name="history" color={color} />,
@@ -48,7 +48,7 @@ }}
48 48 />
49 49
50 50 <Tabs.Screen
51 - name="insights/index"
51 + name="insights"
52 52 options={{
53 53 title: 'Insights',
54 54 tabBarIcon: ({ color }) => <IconSymbol size={28} name="lightbulb-outline" color={color} />,
@@ -64,7 +64,7 @@ }}
64 64 />
65 65
66 66 <Tabs.Screen
67 - name="actions/index"
67 + name="actions"
68 68 options={{
69 69 title: 'Ações',
70 70 tabBarIcon: ({ color }) => <IconSymbol size={28} name="bolt" color={color} />,
@@ -72,7 +72,7 @@ }}
72 72 />
73 73
74 74 <Tabs.Screen
75 - name="settings/index"
75 + name="settings"
76 76 options={{
77 77 title: 'Ajustes',
78 78 tabBarIcon: ({ color }) => <IconSymbol size={28} name="settings.fill" color={color} />,
frontend/app/(tabs)/actions.tsx
frontend/app/(tabs)/history.tsx
frontend/app/(tabs)/insights.tsx
frontend/app/(tabs)/settings.tsx
frontend/app/_layout.tsx
@@ -5,7 +5,7 @@
5 5 import { AuthProvider } from '@/context/AuthContext';
6 6
7 7 export const unstable_settings = {
8 - anchor: '(tabs)/new',
8 + initialRouteName: '(tabs)',
9 9 };
10 10
11 11 export default function RootLayout() {
@@ -15,6 +15,7 @@ return (
15 15 <ThemeProvider value={DefaultTheme}>
16 16 <AuthProvider>
17 17 <Stack>
18 + <Stack.Screen name="index" options={{ headerShown: false }} />
18 19 <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
19 20 <Stack.Screen
20 21 name="auth"
frontend/app/index.tsx
@@ -0,0 +1,17 @@
1 + import { Redirect } from 'expo-router';
2 + import { useAuth } from '@/context/AuthContext';
3 + import { ActivityIndicator, View } from 'react-native';
4 +
5 + export default function Index() {
6 + const { isAuthenticated, isLoading } = useAuth();
7 +
8 + if (isLoading) {
9 + return (
10 + <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
11 + <ActivityIndicator size="large" />
12 + </View>
13 + );
14 + }
15 +
16 + return <Redirect href={isAuthenticated ? '/(tabs)/new' : '/auth/login'} />;
17 + }