Browse Source

01082025_01

28062025_02
andrymodeste 4 months ago
parent
commit
2eeaeaa4c4
  1. 79
      lib/Views/Dashboard.dart

79
lib/Views/Dashboard.dart

@ -1568,6 +1568,9 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
final pointVenteId = pointVenteData['point_vente_id'] as int;
final pointVenteNom = pointVenteData['point_vente_nom'] as String;
// VARIABLE LOCALE pour gérer l'expansion des cartes dans ce dialog uniquement
Set<int> dialogExpandedCommandes = <int>{};
showDialog(
context: context,
builder: (context) => StatefulBuilder(
@ -1575,7 +1578,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
title: Text('Détails - $pointVenteNom'),
content: Container(
width: double.maxFinite,
height: 600, // Augmenté pour inclure les commandes
height: 600,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -1595,7 +1598,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
_showOnlyToday = !_showOnlyToday;
if (_showOnlyToday) _dateRange = null;
});
setState(() {});
setState(() {}); // Pour rafraîchir le dashboard principal aussi
},
icon: Icon(
_showOnlyToday ? Icons.today : Icons.calendar_today,
@ -1633,7 +1636,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
_dateRange = picked;
_showOnlyToday = false;
});
setState(() {});
setState(() {}); // Pour rafraîchir le dashboard principal aussi
}
},
icon: const Icon(Icons.date_range, size: 20),
@ -1658,7 +1661,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
_showOnlyToday = false;
_dateRange = null;
});
setState(() {});
setState(() {}); // Pour rafraîchir le dashboard principal aussi
},
icon: const Icon(Icons.clear, size: 20),
label: Text('Reset', style: TextStyle(fontSize: 12)),
@ -1742,8 +1745,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
SizedBox(height: 12),
// NOUVELLE SECTION: Liste des commandes
// SECTION: Liste des commandes
SizedBox(height: 16),
Divider(),
@ -1786,10 +1788,13 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
.toList();
return Column(
children: commandes.map(_buildCommandeCardForDialog).toList(),
children: commandes.map((commande) =>
_buildCommandeCardForDialog(commande, dialogExpandedCommandes, setDialogState)
).toList(),
);
},
),
// Section des sorties personnelles
SizedBox(height: 16),
Divider(),
@ -1799,7 +1804,6 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
SizedBox(height: 8),
// ... (reste du code pour les sorties, inchangé)
FutureBuilder<List<Map<String, dynamic>>>(
future: _database.getHistoriqueSortiesPersonnelles(
pointDeVenteId: pointVenteId,
@ -1827,6 +1831,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
}
return Text(message, style: TextStyle(color: Colors.grey));
}
final sorties = snapshot.data!;
return Column(
children: sorties.map((sortie) => Card(
@ -1934,12 +1939,10 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
),
);
}
// Ajoutez cette variable d'état dans votre classe _DashboardPageState
Set<int> _expandedCommandes = <int>{};
// Remplacez votre méthode _buildCommandeCardForDialog par celle-ci :
Widget _buildCommandeCardForDialog(Commande commande) {
final bool isExpanded = _expandedCommandes.contains(commande.id);
// NOUVELLE VERSION de _buildCommandeCardForDialog qui utilise les paramètres du dialog
Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes, StateSetter setDialogState) {
final bool isExpanded = expandedCommandes.contains(commande.id);
return FutureBuilder<List<DetailCommande>>(
future: _database.getDetailsCommande(commande.id!),
@ -1957,26 +1960,37 @@ Widget _buildCommandeCardForDialog(Commande commande) {
return AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
margin: EdgeInsets.symmetric(vertical: 4),
child: Material(
elevation: isExpanded ? 4 : 2,
borderRadius: BorderRadius.circular(8),
child: Container(
decoration: BoxDecoration(
color: isExpanded
? Colors.grey.shade100
: Colors.grey.shade200,
borderRadius: BorderRadius.circular(8),
border: aDesRemises
? Border.all(color: Colors.orange.shade300, width: 1)
: null,
),
child: InkWell(
onTap: () {
setState(() {
print('Card tapped! Current state: $isExpanded');
// UTILISER setDialogState au lieu de setState
setDialogState(() {
if (isExpanded) {
_expandedCommandes.remove(commande.id);
expandedCommandes.remove(commande.id);
print('Removed commande ${commande.id}');
} else {
_expandedCommandes.add(commande.id!);
expandedCommandes.add(commande.id!);
print('Added commande ${commande.id}');
}
print('Current expanded: $expandedCommandes');
});
},
borderRadius: BorderRadius.circular(8),
child: Card(
margin: EdgeInsets.symmetric(vertical: 4),
elevation: isExpanded ? 4 : 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: aDesRemises
? BorderSide(color: Colors.orange.shade300, width: 1)
: BorderSide.none,
),
child: Padding(
padding: EdgeInsets.all(12),
child: Column(
@ -2119,14 +2133,11 @@ Widget _buildCommandeCardForDialog(Commande commande) {
],
),
// Détails étendus (visibles seulement si expanded)
AnimatedCrossFade(
// Détails étendus avec AnimatedSize
AnimatedSize(
duration: Duration(milliseconds: 300),
crossFadeState: isExpanded
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
firstChild: SizedBox.shrink(),
secondChild: Column(
curve: Curves.easeInOut,
child: isExpanded ? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 12),
@ -2274,18 +2285,18 @@ Widget _buildCommandeCardForDialog(Commande commande) {
),
],
],
),
) : SizedBox.shrink(),
),
],
),
),
),
),
),
);
},
);
}
Color _getStatutColor(StatutCommande statut) {
switch (statut) {
case StatutCommande.enAttente:

Loading…
Cancel
Save