Browse Source

01082025_02

28062025_02
andrymodeste 4 months ago
parent
commit
4b4d9637fd
  1. 210
      lib/Views/Dashboard.dart
  2. 4
      pubspec.yaml
  3. BIN
      windows/runner/resources/app_icon.ico

210
lib/Views/Dashboard.dart

@ -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,56 +2110,40 @@ 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: [ children: [
SizedBox(height: 12), const SizedBox(height: 12),
Divider(color: Colors.grey[300]), Divider(color: Colors.grey[300]),
SizedBox(height: 8), if (commande.commandeurnom?.isNotEmpty ?? false)
Padding(
// Informations du commandeur padding: const EdgeInsets.only(top: 8.0),
if (commande.commandeurnom != null && commande.commandeurnom!.isNotEmpty)
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.blue.shade50,
borderRadius: BorderRadius.circular(6),
),
child: Row( child: Row(
children: [ children: [
Icon(Icons.person, size: 16, color: Colors.blue[600]), Icon(Icons.person,
SizedBox(width: 8), size: 16, color: Colors.blue[600]),
const SizedBox(width: 8),
Text( Text(
'Commandeur: ',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Colors.grey[700],
),
),
Expanded(
child: Text(
'${commande.commandeurnom ?? ''} ${commande.commandeurPrenom ?? ''}', '${commande.commandeurnom ?? ''} ${commande.commandeurPrenom ?? ''}',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
@ -2173,69 +2151,19 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
color: Colors.blue[700], 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: [
Icon(
_getStatutIcon(commande.statut),
size: 16,
color: commande.statut == StatutCommande.annulee
? Colors.red
: 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],
),
),
], ],
), ),
), ),
const SizedBox(height: 8),
SizedBox(height: 8), if (snapshot.hasData && snapshot.data!.isNotEmpty)
Column(
// 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, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
children: [ children: [
Icon(Icons.shopping_cart, size: 16, color: Colors.green[600]), Icon(Icons.shopping_cart,
SizedBox(width: 8), size: 16, color: Colors.green[600]),
const SizedBox(width: 8),
Text( Text(
'Produits commandés:', 'Produits commandés:',
style: TextStyle( style: TextStyle(
@ -2246,20 +2174,14 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
), ),
], ],
), ),
SizedBox(height: 6), const SizedBox(height: 6),
...snapshot.data!.map((detail) => Padding( ...snapshot.data!.map((detail) => Padding(
padding: EdgeInsets.only(left: 24, bottom: 4), padding: const EdgeInsets.only(left: 24, bottom: 4),
child: Row( child: Row(
children: [ children: [
Container( const Icon(Icons.circle,
width: 4, size: 4, color: Colors.green),
height: 4, const SizedBox(width: 8),
decoration: BoxDecoration(
color: Colors.green[600],
borderRadius: BorderRadius.circular(2),
),
),
SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
'${detail.produitNom} (x${detail.quantite})', '${detail.produitNom} (x${detail.quantite})',
@ -2279,13 +2201,12 @@ Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes
), ),
], ],
), ),
)).toList(), ))
], ],
), ),
),
],
], ],
) : SizedBox.shrink(), )
: 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:

4
pubspec.yaml

@ -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

BIN
windows/runner/resources/app_icon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Loading…
Cancel
Save