From f29f3084ffd5342bdef64d2aaaeee80e7d7a959b Mon Sep 17 00:00:00 2001 From: andrymodeste Date: Sat, 2 Aug 2025 03:19:39 +0200 Subject: [PATCH] commit_02 --- lib/layouts/main_layout.dart | 32 ++++++++--------------- lib/main.dart | 15 +++++------ lib/pages/menu.dart | 24 ++++++++++++++--- lib/widgets/bottom_navigation.dart | 18 ++++++------- lib/widgets/mobile_bottom_navigation.dart | 7 ++++- 5 files changed, 54 insertions(+), 42 deletions(-) diff --git a/lib/layouts/main_layout.dart b/lib/layouts/main_layout.dart index d0aec98..5d8664a 100644 --- a/lib/layouts/main_layout.dart +++ b/lib/layouts/main_layout.dart @@ -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 { @override void initState() { super.initState(); - _selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/dashboard'); + _selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/tables'); } int _getIndexFromRoute(String route) { switch (route) { - case '/dashboard': + case '/tables': return 0; - case '/menu': + case '/commandes': + case '/orders': return 1; - case '/tables': + case '/categories': return 2; - case '/orders': - return 3; - case '/profile': - return 4; default: return 0; } @@ -51,22 +47,16 @@ class _MainLayoutState extends State { String route; switch (index) { case 0: - route = '/dashboard'; + route = '/tables'; break; case 1: - route = '/menu'; + route = '/commandes'; // ou '/orders' selon votre configuration break; case 2: - route = '/tables'; - break; - case 3: - route = '/orders'; - break; - case 4: - route = '/profile'; + route = '/categories'; break; default: - route = '/dashboard'; + route = '/tables'; } if (route != widget.currentRoute) { @@ -95,10 +85,10 @@ class _MainLayoutState extends State { isDesktop ? null : MobileBottomNavigation( - currentRoute: widget.currentRoute ?? '/dashboard', + currentRoute: widget.currentRoute ?? '/tables', selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ), ); } -} +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 74436f6..38c01ed 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 { }, ); } -} +} \ No newline at end of file diff --git a/lib/pages/menu.dart b/lib/pages/menu.dart index fcb25df..f4cb0f6 100644 --- a/lib/pages/menu.dart +++ b/lib/pages/menu.dart @@ -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 { ); } + // 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 { 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), diff --git a/lib/widgets/bottom_navigation.dart b/lib/widgets/bottom_navigation.dart index 28c997f..67db7af 100644 --- a/lib/widgets/bottom_navigation.dart +++ b/lib/widgets/bottom_navigation.dart @@ -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 { ], ); } -} +} \ No newline at end of file diff --git a/lib/widgets/mobile_bottom_navigation.dart b/lib/widgets/mobile_bottom_navigation.dart index fd566bc..8330620 100644 --- a/lib/widgets/mobile_bottom_navigation.dart +++ b/lib/widgets/mobile_bottom_navigation.dart @@ -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 { ), ); } -} + }