Archived
- Add mobile/ directory with Expo React Native project - Create API client with JWT auth and token refresh using AsyncStorage - Implement AuthContext for login/register/logout flow - Add screens: Login, Register, Library, Search, Settings - Set up React Navigation with AuthStack and MainTabs - Create packages/shared/ with shared types and utilities - Add shared validation utilities (email, password strength) - Update root package.json workspaces to include mobile + shared - Add spec document docs/backend/009-expo-integration.md
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { type ReactNode } from "react";
|
|
import { NavigationContainer } from "@react-navigation/native";
|
|
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
|
import { useAuth } from "../context/AuthContext";
|
|
import LoginScreen from "../screens/LoginScreen";
|
|
import RegisterScreen from "../screens/RegisterScreen";
|
|
import MainTabs from "./MainTabs";
|
|
|
|
export type AuthStackParamList = {
|
|
Login: undefined;
|
|
Register: undefined;
|
|
};
|
|
|
|
export type RootStackParamList = {
|
|
Auth: undefined;
|
|
Main: undefined;
|
|
};
|
|
|
|
const RootStack = createNativeStackNavigator<RootStackParamList>();
|
|
const AuthStack = createNativeStackNavigator<AuthStackParamList>();
|
|
|
|
function AuthNavigator(): ReactNode {
|
|
return (
|
|
<AuthStack.Navigator screenOptions={{ headerShown: false }}>
|
|
<AuthStack.Screen name="Login" component={LoginScreen} />
|
|
<AuthStack.Screen name="Register" component={RegisterScreen} />
|
|
</AuthStack.Navigator>
|
|
);
|
|
}
|
|
|
|
export default function AppNavigator(): ReactNode {
|
|
const { state } = useAuth();
|
|
|
|
return (
|
|
<NavigationContainer>
|
|
<RootStack.Navigator screenOptions={{ headerShown: false }}>
|
|
{state.isAuthenticated ? (
|
|
<RootStack.Screen name="Main" component={MainTabs} />
|
|
) : (
|
|
<RootStack.Screen name="Auth" component={AuthNavigator} />
|
|
)}
|
|
</RootStack.Navigator>
|
|
</NavigationContainer>
|
|
);
|
|
} |