01082025_02
This commit is contained in:
parent
2eeaeaa4c4
commit
4b4d9637fd
@ -1939,13 +1939,16 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Widget _buildCommandeCardForDialog(
|
||||||
// NOUVELLE VERSION de _buildCommandeCardForDialog qui utilise les paramètres du dialog
|
Commande commande,
|
||||||
Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes, StateSetter setDialogState) {
|
Set<int> expandedCommandes,
|
||||||
final bool isExpanded = expandedCommandes.contains(commande.id);
|
StateSetter setDialogState,
|
||||||
|
) {
|
||||||
|
final int commandeId = commande.id ?? -1; // fallback si null
|
||||||
|
final bool isExpanded = expandedCommandes.contains(commandeId);
|
||||||
|
|
||||||
return FutureBuilder<List<DetailCommande>>(
|
return FutureBuilder<List<DetailCommande>>(
|
||||||
future: _database.getDetailsCommande(commande.id!),
|
future: _database.getDetailsCommande(commandeId),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
double totalRemises = 0;
|
double totalRemises = 0;
|
||||||
bool aDesRemises = false;
|
bool aDesRemises = false;
|
||||||
@ -1958,45 +1961,37 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
margin: EdgeInsets.symmetric(vertical: 4),
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
child: Material(
|
child: Material(
|
||||||
elevation: isExpanded ? 4 : 2,
|
elevation: isExpanded ? 4 : 2,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isExpanded
|
color: isExpanded ? Colors.grey.shade100 : Colors.grey.shade200,
|
||||||
? Colors.grey.shade100
|
|
||||||
: Colors.grey.shade200,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: aDesRemises
|
border: aDesRemises
|
||||||
? Border.all(color: Colors.orange.shade300, width: 1)
|
? Border.all(color: Colors.orange.shade300, width: 1)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
print('Card tapped! Current state: $isExpanded');
|
|
||||||
// UTILISER setDialogState au lieu de setState
|
|
||||||
setDialogState(() {
|
setDialogState(() {
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
expandedCommandes.remove(commande.id);
|
expandedCommandes.remove(commandeId);
|
||||||
print('Removed commande ${commande.id}');
|
|
||||||
} else {
|
} else {
|
||||||
expandedCommandes.add(commande.id!);
|
expandedCommandes.add(commandeId);
|
||||||
print('Added commande ${commande.id}');
|
|
||||||
}
|
}
|
||||||
print('Current expanded: $expandedCommandes');
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// En-tête de la commande (toujours visible)
|
// En-tête
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@ -2006,7 +2001,7 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
color: _getStatutColor(commande.statut).withOpacity(0.1),
|
color: _getStatutColor(commande.statut).withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
border: aDesRemises
|
border: aDesRemises
|
||||||
? Border.all(color: Colors.orange.shade300, width: 1)
|
? Border.all(color: Colors.orange.shade300)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -2024,8 +2019,8 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
: Colors.blue.shade600,
|
: Colors.blue.shade600,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'#${commande.id}',
|
'#$commandeId',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 8,
|
fontSize: 8,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@ -2033,31 +2028,32 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
commande.clientNomComplet,
|
commande.clientNomComplet,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.calendar_today, size: 12, color: Colors.grey),
|
const Icon(Icons.calendar_today,
|
||||||
SizedBox(width: 4),
|
size: 12, color: Colors.grey),
|
||||||
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
DateFormat('dd/MM/yyyy').format(commande.dateCommande),
|
DateFormat('dd/MM/yyyy').format(commande.dateCommande),
|
||||||
style: TextStyle(fontSize: 11, color: Colors.grey),
|
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
),
|
),
|
||||||
SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _getStatutColor(commande.statut).withOpacity(0.2),
|
color: _getStatutColor(commande.statut).withOpacity(0.2),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
@ -2078,10 +2074,9 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Icône d'expansion
|
|
||||||
AnimatedRotation(
|
AnimatedRotation(
|
||||||
turns: isExpanded ? 0.5 : 0,
|
turns: isExpanded ? 0.5 : 0,
|
||||||
duration: Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.expand_more,
|
Icons.expand_more,
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
@ -2089,14 +2084,13 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
SizedBox(height: 8),
|
// Montant
|
||||||
|
|
||||||
// Montant (toujours visible)
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.attach_money, size: 14, color: Colors.green.shade600),
|
Icon(Icons.attach_money,
|
||||||
SizedBox(width: 4),
|
size: 14, color: Colors.green.shade600),
|
||||||
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
'${NumberFormat('#,##0', 'fr_FR').format(commande.montantTotal)} MGA',
|
'${NumberFormat('#,##0', 'fr_FR').format(commande.montantTotal)} MGA',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@ -2106,9 +2100,9 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (totalRemises > 0) ...[
|
if (totalRemises > 0) ...[
|
||||||
SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.orange.shade100,
|
color: Colors.orange.shade100,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
@ -2116,176 +2110,103 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.discount, size: 10, color: Colors.teal.shade700),
|
Icon(Icons.discount,
|
||||||
SizedBox(width: 2),
|
size: 10, color: Colors.teal.shade700),
|
||||||
|
const SizedBox(width: 2),
|
||||||
Text(
|
Text(
|
||||||
'-${NumberFormat('#,##0', 'fr_FR').format(totalRemises)}',
|
'-${NumberFormat('#,##0', 'fr_FR').format(totalRemises)}',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.teal.shade700,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// Contenu étendu
|
||||||
// Détails étendus avec AnimatedSize
|
|
||||||
AnimatedSize(
|
AnimatedSize(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
child: isExpanded ? Column(
|
child: isExpanded
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
? Column(
|
||||||
children: [
|
|
||||||
SizedBox(height: 12),
|
|
||||||
Divider(color: Colors.grey[300]),
|
|
||||||
SizedBox(height: 8),
|
|
||||||
|
|
||||||
// Informations du commandeur
|
|
||||||
if (commande.commandeurnom != null && commande.commandeurnom!.isNotEmpty)
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.blue.shade50,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.person, size: 16, color: Colors.blue[600]),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
'Commandeur: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.grey[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'${commande.commandeurnom ?? ''} ${commande.commandeurPrenom ?? ''}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.blue[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(height: 8),
|
|
||||||
|
|
||||||
// Statut détaillé
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: _getStatutColor(commande.statut).withOpacity(0.1),
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
const SizedBox(height: 12),
|
||||||
_getStatutIcon(commande.statut),
|
Divider(color: Colors.grey[300]),
|
||||||
size: 16,
|
if (commande.commandeurnom?.isNotEmpty ?? false)
|
||||||
color: commande.statut == StatutCommande.annulee
|
Padding(
|
||||||
? Colors.red
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
: Colors.blue[600],
|
|
||||||
),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
'Statut: ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.grey[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
commande.statutLibelle,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: commande.statut == StatutCommande.annulee
|
|
||||||
? Colors.red
|
|
||||||
: Colors.blue[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(height: 8),
|
|
||||||
|
|
||||||
// Liste des produits commandés
|
|
||||||
if (snapshot.hasData && snapshot.data!.isNotEmpty) ...[
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.green.shade50,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.shopping_cart, size: 16, color: Colors.green[600]),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
'Produits commandés:',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.green[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 6),
|
|
||||||
...snapshot.data!.map((detail) => Padding(
|
|
||||||
padding: EdgeInsets.only(left: 24, bottom: 4),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Icon(Icons.person,
|
||||||
width: 4,
|
size: 16, color: Colors.blue[600]),
|
||||||
height: 4,
|
const SizedBox(width: 8),
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.green[600],
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'${detail.produitNom} (x${detail.quantite})',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 11,
|
|
||||||
color: Colors.green[700],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
'${NumberFormat('#,##0', 'fr_FR').format(detail.sousTotal)} MGA',
|
'${commande.commandeurnom ?? ''} ${commande.commandeurPrenom ?? ''}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.green[700],
|
color: Colors.blue[700],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)).toList(),
|
),
|
||||||
],
|
const SizedBox(height: 8),
|
||||||
),
|
if (snapshot.hasData && snapshot.data!.isNotEmpty)
|
||||||
),
|
Column(
|
||||||
],
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
],
|
children: [
|
||||||
) : SizedBox.shrink(),
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.shopping_cart,
|
||||||
|
size: 16, color: Colors.green[600]),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Produits commandés:',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.green[700],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
...snapshot.data!.map((detail) => Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 24, bottom: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.circle,
|
||||||
|
size: 4, color: Colors.green),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'${detail.produitNom} (x${detail.quantite})',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
color: Colors.green[700],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${NumberFormat('#,##0', 'fr_FR').format(detail.sousTotal)} MGA',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.green[700],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -2297,6 +2218,7 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getStatutColor(StatutCommande statut) {
|
Color _getStatutColor(StatutCommande statut) {
|
||||||
switch (statut) {
|
switch (statut) {
|
||||||
case StatutCommande.enAttente:
|
case StatutCommande.enAttente:
|
||||||
|
|||||||
@ -63,8 +63,8 @@ dependencies:
|
|||||||
path_provider: ^2.0.15
|
path_provider: ^2.0.15
|
||||||
shared_preferences: ^2.2.2
|
shared_preferences: ^2.2.2
|
||||||
excel: ^2.0.1
|
excel: ^2.0.1
|
||||||
mobile_scanner: ^5.0.0 # ou la version la plus récente
|
mobile_scanner: ^5.0.0
|
||||||
fl_chart: ^0.65.0 # Version la plus récente au moment de cette répons
|
fl_chart: ^0.65.0
|
||||||
numbers_to_letters: ^1.0.0
|
numbers_to_letters: ^1.0.0
|
||||||
qr_code_scanner_plus: ^2.0.10+1
|
qr_code_scanner_plus: ^2.0.10+1
|
||||||
window_manager: ^0.3.7
|
window_manager: ^0.3.7
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 74 KiB |
Loading…
Reference in New Issue
Block a user