commit_02
This commit is contained in:
parent
914d336f73
commit
f29f3084ff
@ -10,7 +10,6 @@ class MainLayout extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.child,
|
required this.child,
|
||||||
this.currentRoute,
|
this.currentRoute,
|
||||||
// Remove the currentIndex parameter - it's not needed
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -23,21 +22,18 @@ class _MainLayoutState extends State<MainLayout> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/dashboard');
|
_selectedIndex = _getIndexFromRoute(widget.currentRoute ?? '/tables');
|
||||||
}
|
}
|
||||||
|
|
||||||
int _getIndexFromRoute(String route) {
|
int _getIndexFromRoute(String route) {
|
||||||
switch (route) {
|
switch (route) {
|
||||||
case '/dashboard':
|
|
||||||
return 0;
|
|
||||||
case '/menu':
|
|
||||||
return 1;
|
|
||||||
case '/tables':
|
case '/tables':
|
||||||
return 2;
|
return 0;
|
||||||
|
case '/commandes':
|
||||||
case '/orders':
|
case '/orders':
|
||||||
return 3;
|
return 1;
|
||||||
case '/profile':
|
case '/categories':
|
||||||
return 4;
|
return 2;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -51,22 +47,16 @@ class _MainLayoutState extends State<MainLayout> {
|
|||||||
String route;
|
String route;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
route = '/dashboard';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
route = '/menu';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
route = '/tables';
|
route = '/tables';
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 1:
|
||||||
route = '/orders';
|
route = '/commandes'; // ou '/orders' selon votre configuration
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 2:
|
||||||
route = '/profile';
|
route = '/categories';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
route = '/dashboard';
|
route = '/tables';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route != widget.currentRoute) {
|
if (route != widget.currentRoute) {
|
||||||
@ -95,10 +85,10 @@ class _MainLayoutState extends State<MainLayout> {
|
|||||||
isDesktop
|
isDesktop
|
||||||
? null
|
? null
|
||||||
: MobileBottomNavigation(
|
: MobileBottomNavigation(
|
||||||
currentRoute: widget.currentRoute ?? '/dashboard',
|
currentRoute: widget.currentRoute ?? '/tables',
|
||||||
selectedIndex: _selectedIndex,
|
selectedIndex: _selectedIndex,
|
||||||
onItemTapped: _onItemTapped,
|
onItemTapped: _onItemTapped,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'layouts/main_layout.dart';
|
import 'layouts/main_layout.dart';
|
||||||
import 'pages/tables.dart';
|
import 'pages/tables.dart';
|
||||||
|
import 'pages/categorie.dart'; // Import de votre page de catégories
|
||||||
// import 'pages/commandes_screen.dart';
|
// import 'pages/commandes_screen.dart';
|
||||||
// import 'pages/categories_screen.dart';
|
|
||||||
// import 'pages/menus_screen.dart';
|
// import 'pages/menus_screen.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -22,20 +22,19 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
initialRoute: '/tables',
|
initialRoute: '/tables',
|
||||||
routes: {
|
routes: {
|
||||||
'/tables':
|
'/tables': (context) => const MainLayout(
|
||||||
(context) => const MainLayout(
|
|
||||||
currentRoute: '/tables',
|
currentRoute: '/tables',
|
||||||
child: TablesScreen(),
|
child: TablesScreen(),
|
||||||
),
|
),
|
||||||
|
'/categories': (context) => const MainLayout(
|
||||||
|
currentRoute: '/categories',
|
||||||
|
child: CategoriesPage(),
|
||||||
|
),
|
||||||
// Uncomment and update these as needed:
|
// Uncomment and update these as needed:
|
||||||
// '/commandes': (context) => const MainLayout(
|
// '/commandes': (context) => const MainLayout(
|
||||||
// currentRoute: '/commandes',
|
// currentRoute: '/commandes',
|
||||||
// child: CommandesScreen(),
|
// child: CommandesScreen(),
|
||||||
// ),
|
// ),
|
||||||
// '/categories': (context) => const MainLayout(
|
|
||||||
// currentRoute: '/categories',
|
|
||||||
// child: CategoriesScreen(),
|
|
||||||
// ),
|
|
||||||
// '/menus': (context) => const MainLayout(
|
// '/menus': (context) => const MainLayout(
|
||||||
// currentRoute: '/menus',
|
// currentRoute: '/menus',
|
||||||
// child: MenusScreen(),
|
// 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 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
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 {
|
class MenuPage extends StatefulWidget {
|
||||||
final int tableId;
|
final int tableId;
|
||||||
final int personne;
|
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
|
/// Conversion sécurisée du prix en string avec 2 décimales
|
||||||
String formatPrix(dynamic prix) {
|
String formatPrix(dynamic prix) {
|
||||||
if (prix == null) return "";
|
if (prix == null) return "";
|
||||||
@ -197,9 +217,7 @@ class _MenuPageState extends State<MenuPage> {
|
|||||||
color: Colors.green[700],
|
color: Colors.green[700],
|
||||||
child: Center(
|
child: Center(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {
|
onPressed: _navigateToCart, // Navigation vers la page panier
|
||||||
// TODO: Naviguer vers la page panier
|
|
||||||
},
|
|
||||||
child: Text(
|
child: Text(
|
||||||
"Voir le panier (${_cart.length})",
|
"Voir le panier (${_cart.length})",
|
||||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||||
|
|||||||
@ -109,14 +109,14 @@ class AppBottomNavigation extends StatelessWidget {
|
|||||||
|
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
|
|
||||||
// Commandes Tab
|
// Catégories Tab (Corrigé)
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onItemTapped(1),
|
onTap: () => onItemTapped(2), // Index 2 pour catégories
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color:
|
color:
|
||||||
selectedIndex == 1
|
selectedIndex == 2 // Index 2 pour catégories
|
||||||
? Colors.green.shade700
|
? Colors.green.shade700
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
@ -125,23 +125,23 @@ class AppBottomNavigation extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.receipt_long_outlined,
|
Icons.category_outlined, // Icône plus appropriée pour catégories
|
||||||
color:
|
color:
|
||||||
selectedIndex == 1
|
selectedIndex == 2
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.grey.shade600,
|
: Colors.grey.shade600,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Text(
|
Text(
|
||||||
'Categories',
|
'Catégories',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color:
|
||||||
selectedIndex == 1
|
selectedIndex == 2
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.grey.shade600,
|
: Colors.grey.shade600,
|
||||||
fontWeight:
|
fontWeight:
|
||||||
selectedIndex == 1
|
selectedIndex == 2
|
||||||
? FontWeight.w500
|
? FontWeight.w500
|
||||||
: FontWeight.normal,
|
: FontWeight.normal,
|
||||||
),
|
),
|
||||||
@ -171,4 +171,4 @@ class AppBottomNavigation extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,6 +29,11 @@ class MobileBottomNavigation extends StatelessWidget {
|
|||||||
label: 'Commandes',
|
label: 'Commandes',
|
||||||
index: 1,
|
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