first commit
This commit is contained in:
59
src/navigation/AppNavigator.tsx
Normal file
59
src/navigation/AppNavigator.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import React from 'react';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { useApp } from '../context/AppContext';
|
||||
import Landing from '../pages/Landing';
|
||||
import AuthLogin from '../pages/AuthLogin';
|
||||
import AuthRegister from '../pages/AuthRegister';
|
||||
import Explore from '../pages/Explore';
|
||||
import ShopDetails from '../pages/ShopDetails';
|
||||
import Booking from '../pages/Booking';
|
||||
import Cart from '../pages/Cart';
|
||||
import Profile from '../pages/Profile';
|
||||
import Dashboard from '../pages/Dashboard';
|
||||
import { RootStackParamList } from './types';
|
||||
|
||||
const Stack = createNativeStackNavigator<RootStackParamList>();
|
||||
|
||||
export default function AppNavigator() {
|
||||
const { user } = useApp();
|
||||
|
||||
return (
|
||||
<NavigationContainer>
|
||||
<Stack.Navigator
|
||||
screenOptions={{
|
||||
headerStyle: { backgroundColor: '#f59e0b' },
|
||||
headerTintColor: '#fff',
|
||||
headerTitleStyle: { fontWeight: 'bold' },
|
||||
}}
|
||||
>
|
||||
{!user ? (
|
||||
<>
|
||||
<Stack.Screen name="Landing" component={Landing} options={{ headerShown: false }} />
|
||||
<Stack.Screen name="Login" component={AuthLogin} options={{ title: 'Entrar' }} />
|
||||
<Stack.Screen name="Register" component={AuthRegister} options={{ title: 'Criar Conta' }} />
|
||||
<Stack.Screen name="Explore" component={Explore} options={{ title: 'Explorar' }} />
|
||||
<Stack.Screen name="ShopDetails" component={ShopDetails} options={{ title: 'Detalhes' }} />
|
||||
<Stack.Screen name="Booking" component={Booking} options={{ title: 'Agendar' }} />
|
||||
<Stack.Screen name="Cart" component={Cart} options={{ title: 'Carrinho' }} />
|
||||
</>
|
||||
) : user.role === 'barbearia' ? (
|
||||
<>
|
||||
<Stack.Screen name="Dashboard" component={Dashboard} options={{ title: 'Painel', headerShown: false }} />
|
||||
<Stack.Screen name="Profile" component={Profile} options={{ title: 'Perfil' }} />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Stack.Screen name="Explore" component={Explore} options={{ title: 'Explorar' }} />
|
||||
<Stack.Screen name="ShopDetails" component={ShopDetails} options={{ title: 'Detalhes' }} />
|
||||
<Stack.Screen name="Booking" component={Booking} options={{ title: 'Agendar' }} />
|
||||
<Stack.Screen name="Cart" component={Cart} options={{ title: 'Carrinho' }} />
|
||||
<Stack.Screen name="Profile" component={Profile} options={{ title: 'Perfil' }} />
|
||||
</>
|
||||
)}
|
||||
</Stack.Navigator>
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
19
src/navigation/types.ts
Normal file
19
src/navigation/types.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export type RootStackParamList = {
|
||||
Landing: undefined;
|
||||
Login: undefined;
|
||||
Register: undefined;
|
||||
Explore: undefined;
|
||||
ShopDetails: { shopId: string };
|
||||
Booking: { shopId: string };
|
||||
Cart: undefined;
|
||||
Profile: undefined;
|
||||
Dashboard: undefined;
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace ReactNavigation {
|
||||
interface RootParamList extends RootStackParamList {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user