commit_02
This commit is contained in:
parent
914d336f73
commit
f29f3084ff
@ -10,7 +10,6 @@ class MainLayout extends StatefulWidget {
|
||||
super.key,
|
||||
required this.child,
|
||||
this.currentRoute,
|
||||
// Remove the currentIndex parameter - it's not needed
|
||||
});
|
||||
|
||||
@override
|
||||
@ -23,21 +22,18 @@ class _MainLayoutState extends State<MainLayout> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/dashboard');
|
||||
_selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/tables');
|
||||
}
|
||||
|
||||
int _getIndexFromRoute(String route) {
|
||||
switch (route) {
|
||||
case '/dashboard':
|
||||
return 0;
|
||||
case '/menu':
|
||||
return 1;
|
||||
case '/tables':
|
||||
return 2;
|
||||
return 0;
|
||||
case '/commandes':
|
||||
case '/orders':
|
||||
return 3;
|
||||
case '/profile':
|
||||
return 4;
|
||||
return 1;
|
||||
case '/categories':
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -51,22 +47,16 @@ class _MainLayoutState extends State<MainLayout> {
|
||||
String route;
|
||||
switch (index) {
|
||||
case 0:
|
||||
route = '/dashboard';
|
||||
break;
|
||||
case 1:
|
||||
route = '/menu';
|
||||
break;
|
||||
case 2:
|
||||
route = '/tables';
|
||||
break;
|
||||
case 3:
|
||||
route = '/orders';
|
||||
case 1:
|
||||
route = '/commandes'; // ou '/orders' selon votre configuration
|
||||
break;
|
||||
case 4:
|
||||
route = '/profile';
|
||||
case 2:
|
||||
route = '/categories';
|
||||
break;
|
||||
default:
|
||||
route = '/dashboard';
|
||||
route = '/tables';
|
||||
}
|
||||
|
||||
if (route != widget.currentRoute) {
|
||||
@ -95,10 +85,10 @@ class _MainLayoutState extends State<MainLayout> {
|
||||
isDesktop
|
||||
? null
|
||||
: MobileBottomNavigation(
|
||||
currentRoute: widget.currentRoute ?? '/dashboard',
|
||||
currentRoute: widget.currentRoute ?? '/tables',
|
||||
selectedIndex: _selectedIndex,
|
||||
onItemTapped: _onItemTapped,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'layouts/main_layout.dart';
|
||||
import 'pages/tables.dart';
|
||||
import 'pages/categorie.dart'; // Import de votre page de catégories
|
||||
// import 'pages/commandes_screen.dart';
|
||||
// import 'pages/categories_screen.dart';
|
||||
// import 'pages/menus_screen.dart';
|
||||
|
||||
void main() {
|
||||
@ -22,20 +22,19 @@ class MyApp extends StatelessWidget {
|
||||
),
|
||||
initialRoute: '/tables',
|
||||
routes: {
|
||||
'/tables':
|
||||
(context) => const MainLayout(
|
||||
'/tables': (context) => const MainLayout(
|
||||
currentRoute: '/tables',
|
||||
child: TablesScreen(),
|
||||
),
|
||||
'/categories': (context) => const MainLayout(
|
||||
currentRoute: '/categories',
|
||||
child: CategoriesPage(),
|
||||
),
|
||||
// Uncomment and update these as needed:
|
||||
// '/commandes': (context) => const MainLayout(
|
||||
// currentRoute: '/commandes',
|
||||
// child: CommandesScreen(),
|
||||
// ),
|
||||
// '/categories': (context) => const MainLayout(
|
||||
// currentRoute: '/categories',
|
||||
// child: CategoriesScreen(),
|
||||
// ),
|
||||
// '/menus': (context) => const MainLayout(
|
||||
// currentRoute: '/menus',
|
||||
// child: MenusScreen(),
|
||||
@ -43,4 +42,4 @@ class MyApp extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
// Ajoutez cet import pour la page panier
|
||||
import 'cart_page.dart'; // Assurez-vous que le fichier cart_page.dart est dans le même dossier
|
||||
|
||||
class MenuPage extends StatefulWidget {
|
||||
final int tableId;
|
||||
final int personne;
|
||||
@ -104,6 +107,23 @@ class _MenuPageState extends State<MenuPage> {
|
||||
);
|
||||
}
|
||||
|
||||
// Fonction pour naviguer vers la page panier
|
||||
void _navigateToCart() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CartPage(
|
||||
tableId: widget.tableId,
|
||||
personne: widget.personne,
|
||||
cartItems: List.from(_cart), // Copie de la liste pour éviter les modifications
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Optionnel: actualiser le panier au retour de la page panier
|
||||
// Vous pourriez implémenter une logique pour synchroniser les modifications
|
||||
});
|
||||
}
|
||||
|
||||
/// Conversion sécurisée du prix en string avec 2 décimales
|
||||
String formatPrix(dynamic prix) {
|
||||
if (prix == null) return "";
|
||||
@ -197,9 +217,7 @@ class _MenuPageState extends State<MenuPage> {
|
||||
color: Colors.green[700],
|
||||
child: Center(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
// TODO: Naviguer vers la page panier
|
||||
},
|
||||
onPressed: _navigateToCart, // Navigation vers la page panier
|
||||
child: Text(
|
||||
"Voir le panier (${_cart.length})",
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
|
||||
@ -109,14 +109,14 @@ class AppBottomNavigation extends StatelessWidget {
|
||||
|
||||
const SizedBox(width: 20),
|
||||
|
||||
// Commandes Tab
|
||||
// Catégories Tab (Corrigé)
|
||||
GestureDetector(
|
||||
onTap: () => onItemTapped(1),
|
||||
onTap: () => onItemTapped(2), // Index 2 pour catégories
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
selectedIndex == 1
|
||||
selectedIndex == 2 // Index 2 pour catégories
|
||||
? Colors.green.shade700
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@ -125,23 +125,23 @@ class AppBottomNavigation extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.receipt_long_outlined,
|
||||
Icons.category_outlined, // Icône plus appropriée pour catégories
|
||||
color:
|
||||
selectedIndex == 1
|
||||
selectedIndex == 2
|
||||
? Colors.white
|
||||
: Colors.grey.shade600,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'Categories',
|
||||
'Catégories',
|
||||
style: TextStyle(
|
||||
color:
|
||||
selectedIndex == 1
|
||||
selectedIndex == 2
|
||||
? Colors.white
|
||||
: Colors.grey.shade600,
|
||||
fontWeight:
|
||||
selectedIndex == 1
|
||||
selectedIndex == 2
|
||||
? FontWeight.w500
|
||||
: FontWeight.normal,
|
||||
),
|
||||
@ -171,4 +171,4 @@ class AppBottomNavigation extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,11 @@ class MobileBottomNavigation extends StatelessWidget {
|
||||
label: 'Commandes',
|
||||
index: 1,
|
||||
),
|
||||
_buildBottomNavItem(
|
||||
icon: Icons.category_outlined,
|
||||
label: 'Catégories',
|
||||
index: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -64,4 +69,4 @@ class MobileBottomNavigation extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user