CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
RootNavigator.tsx
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 9d7a803 | 1 | import React from 'react'; |
| c53cf00 | 2 | import { NavigationContainer } from '@react-navigation/native'; |
| 3 | import { createNativeStackNavigator } from '@react-navigation/native-stack'; | |
| 4 | import { View, ActivityIndicator } from 'react-native'; | |
| 5 | import { colors } from '../theme/colors'; | |
| 6 | import { AuthScreen } from '../screens/AuthScreen'; | |
| 7 | import { MainTabNavigator } from './MainTabNavigator'; | |
| 8 | import { useAuth } from '../hooks/useAuth'; | |
| 9d7a803 | 9 | import { AuthContext } from './AuthContext'; |
| c53cf00 | 10 | |
| 9d7a803 | 11 | // Re-export AuthContext so callers can do: import { AuthContext } from '../navigation/RootNavigator' |
| 12 | export { AuthContext }; | |
| 13 | export type { AuthContextValue } from './AuthContext'; | |
| c53cf00 | 14 | |
| 15 | // ─── Root param list ────────────────────────────────────────────────────────── | |
| 16 | ||
| 17 | type RootStackParamList = { | |
| 18 | Auth: undefined; | |
| 19 | Main: undefined; | |
| 20 | }; | |
| 21 | ||
| 22 | const Stack = createNativeStackNavigator<RootStackParamList>(); | |
| 23 | ||
| 24 | // ─── Navigator ──────────────────────────────────────────────────────────────── | |
| 25 | ||
| 26 | export function RootNavigator() { | |
| 27 | const auth = useAuth(); | |
| 28 | ||
| 29 | if (auth.loading) { | |
| 30 | return ( | |
| 31 | <View style={{ flex: 1, backgroundColor: colors.bg, alignItems: 'center', justifyContent: 'center' }}> | |
| 32 | <ActivityIndicator size="large" color={colors.accent} /> | |
| 33 | </View> | |
| 34 | ); | |
| 35 | } | |
| 36 | ||
| 37 | return ( | |
| 9d7a803 | 38 | <AuthContext.Provider |
| 39 | value={{ | |
| 40 | user: auth.user, | |
| 41 | token: auth.token, | |
| 42 | login: auth.login, | |
| 43 | logout: auth.logout, | |
| 44 | }} | |
| 45 | > | |
| c53cf00 | 46 | <NavigationContainer |
| 47 | theme={{ | |
| 48 | dark: true, | |
| 49 | colors: { | |
| 50 | primary: colors.accent, | |
| 51 | background: colors.bg, | |
| 52 | card: colors.bgSecondary, | |
| 53 | text: colors.text, | |
| 54 | border: colors.border, | |
| 55 | notification: colors.accent, | |
| 56 | }, | |
| 57 | }} | |
| 58 | > | |
| 59 | <Stack.Navigator screenOptions={{ headerShown: false }}> | |
| 60 | {auth.isAuthenticated ? ( | |
| 61 | <Stack.Screen name="Main" component={MainTabNavigator} /> | |
| 62 | ) : ( | |
| 63 | <Stack.Screen name="Auth" component={AuthScreen} /> | |
| 64 | )} | |
| 65 | </Stack.Navigator> | |
| 66 | </NavigationContainer> | |
| 67 | </AuthContext.Provider> | |
| 68 | ); | |
| 69 | } |