Browse Source

reectification

master
andrymodeste 1 month ago
parent
commit
7d2c6f5965
  1. 9
      lib/pages/caisse_screen.dart
  2. 9
      lib/pages/commande_item_validation.dart
  3. 6
      lib/pages/facture_screen.dart
  4. 22
      lib/widgets/command_card.dart

9
lib/pages/caisse_screen.dart

@ -111,8 +111,8 @@ class _CaisseScreenState extends State<CaisseScreen> {
return;
}
// 🔄 Redirige vers la facture
Navigator.of(context).pushReplacement(
// 🔄 Redirige vers la facture et attend le retour
final result = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => FactureScreen(
commande: commande!,
@ -121,6 +121,11 @@ class _CaisseScreenState extends State<CaisseScreen> {
),
),
);
// Quand on revient de la facture, on retourne à la page précédente avec succès
if (mounted) {
Navigator.of(context).pop(true);
}
} else {
_showErrorDialog('Le paiement a échoué. Veuillez réessayer.');
}

9
lib/pages/commande_item_validation.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:intl/intl.dart';
import '../layouts/main_layout.dart';
import '../services/pdf_impression_commande.dart';
import 'commandes_screen.dart';
@ -425,11 +426,15 @@ void _navigateBackWithSuccess() {
// Fermer toutes les pages précédentes et rediriger vers OrdersManagementScreen
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => OrdersManagementScreen(),
builder: (context) => MainLayout(
currentRoute: '/commandes', // ou '/tables' selon ton besoin
child: OrdersManagementScreen(),
),
(Route<dynamic> route) => false, // Supprime toutes les pages précédentes
),
(Route<dynamic> route) => false,
);
// Optionnel : petit délai pour laisser le temps à la navigation
Future.delayed(Duration(milliseconds: 300), () {
ScaffoldMessenger.of(context).showSnackBar(

6
lib/pages/facture_screen.dart

@ -58,7 +58,11 @@ class _FactureScreenState extends State<FactureScreen> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
onPressed: () {
// Retourner 2 fois en arrière (facture -> caisse -> liste commandes)
Navigator.of(context).pop();
Navigator.of(context).pop(true); // true pour indiquer le succès
},
),
title: const Text(
'Retour',

22
lib/widgets/command_card.dart

@ -4,12 +4,14 @@ import 'package:itrimobe/models/tables_order.dart';
class CommandeCard extends StatelessWidget {
final TableOrder commande;
final VoidCallback onAllerCaisse;
final Future<void> Function() onAllerCaisse; // Changé en Future<void> Function()
final VoidCallback? onRefresh;
const CommandeCard({
super.key,
required this.commande,
required this.onAllerCaisse,
this.onRefresh,
});
String _formatTime(DateTime dateTime) {
@ -18,7 +20,6 @@ class CommandeCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
@ -38,7 +39,6 @@ class CommandeCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header avec numéro de table et badge
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -62,7 +62,7 @@ class CommandeCard extends StatelessWidget {
Icon(Icons.check_circle, color: Colors.white, size: 16),
SizedBox(width: 4),
Text(
'Près à encaisser',
'Prêt à encaisser',
style: TextStyle(
color: Colors.white,
fontSize: 12,
@ -77,13 +77,11 @@ class CommandeCard extends StatelessWidget {
SizedBox(height: 12),
// Informations détaillées
Row(
children: [
Icon(Icons.access_time, size: 16, color: Colors.grey[600]),
SizedBox(width: 6),
Text(
// Fixed: Pass DateTime directly, not as string
commande.date != null ? _formatTime(commande.date!) : 'Date non disponible',
style: TextStyle(color: Colors.grey[600], fontSize: 14),
),
@ -92,10 +90,8 @@ class CommandeCard extends StatelessWidget {
SizedBox(height: 16),
// Total et bouton
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// alignItems: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -115,7 +111,15 @@ class CommandeCard extends StatelessWidget {
],
),
ElevatedButton.icon(
onPressed: onAllerCaisse,
onPressed: () async {
// Attendre que la navigation soit terminée
await onAllerCaisse();
// Rafraîchir la page
if (onRefresh != null) {
onRefresh!();
}
},
icon: Icon(Icons.point_of_sale, size: 18),
label: Text('Aller à la caisse'),
style: ElevatedButton.styleFrom(

Loading…
Cancel
Save