Browse Source

commit_02

master
andrymodeste 4 months ago
parent
commit
f29f3084ff
  1. 30
      lib/layouts/main_layout.dart
  2. 13
      lib/main.dart
  3. 24
      lib/pages/menu.dart
  4. 16
      lib/widgets/bottom_navigation.dart
  5. 5
      lib/widgets/mobile_bottom_navigation.dart

30
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<MainLayout> {
@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<MainLayout> {
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,7 +85,7 @@ class _MainLayoutState extends State<MainLayout> {
isDesktop
? null
: MobileBottomNavigation(
currentRoute: widget.currentRoute ?? '/dashboard',
currentRoute: widget.currentRoute ?? '/tables',
selectedIndex: _selectedIndex,
onItemTapped: _onItemTapped,
),

13
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(),

24
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<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),

16
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,
),

5
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,
),
],
),
);

Loading…
Cancel
Save