01082025_01
This commit is contained in:
parent
f509af1716
commit
2eeaeaa4c4
@ -1568,6 +1568,9 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
final pointVenteId = pointVenteData['point_vente_id'] as int;
|
final pointVenteId = pointVenteData['point_vente_id'] as int;
|
||||||
final pointVenteNom = pointVenteData['point_vente_nom'] as String;
|
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(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => StatefulBuilder(
|
builder: (context) => StatefulBuilder(
|
||||||
@ -1575,7 +1578,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
title: Text('Détails - $pointVenteNom'),
|
title: Text('Détails - $pointVenteNom'),
|
||||||
content: Container(
|
content: Container(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
height: 600, // Augmenté pour inclure les commandes
|
height: 600,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -1595,7 +1598,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
_showOnlyToday = !_showOnlyToday;
|
_showOnlyToday = !_showOnlyToday;
|
||||||
if (_showOnlyToday) _dateRange = null;
|
if (_showOnlyToday) _dateRange = null;
|
||||||
});
|
});
|
||||||
setState(() {});
|
setState(() {}); // Pour rafraîchir le dashboard principal aussi
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_showOnlyToday ? Icons.today : Icons.calendar_today,
|
_showOnlyToday ? Icons.today : Icons.calendar_today,
|
||||||
@ -1633,7 +1636,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
_dateRange = picked;
|
_dateRange = picked;
|
||||||
_showOnlyToday = false;
|
_showOnlyToday = false;
|
||||||
});
|
});
|
||||||
setState(() {});
|
setState(() {}); // Pour rafraîchir le dashboard principal aussi
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.date_range, size: 20),
|
icon: const Icon(Icons.date_range, size: 20),
|
||||||
@ -1658,7 +1661,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
_showOnlyToday = false;
|
_showOnlyToday = false;
|
||||||
_dateRange = null;
|
_dateRange = null;
|
||||||
});
|
});
|
||||||
setState(() {});
|
setState(() {}); // Pour rafraîchir le dashboard principal aussi
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.clear, size: 20),
|
icon: const Icon(Icons.clear, size: 20),
|
||||||
label: Text('Reset', style: TextStyle(fontSize: 12)),
|
label: Text('Reset', style: TextStyle(fontSize: 12)),
|
||||||
@ -1742,8 +1745,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
|
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
|
|
||||||
|
// SECTION: Liste des commandes
|
||||||
// NOUVELLE SECTION: Liste des commandes
|
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Divider(),
|
Divider(),
|
||||||
|
|
||||||
@ -1786,10 +1788,13 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: commandes.map(_buildCommandeCardForDialog).toList(),
|
children: commandes.map((commande) =>
|
||||||
|
_buildCommandeCardForDialog(commande, dialogExpandedCommandes, setDialogState)
|
||||||
|
).toList(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
// Section des sorties personnelles
|
// Section des sorties personnelles
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Divider(),
|
Divider(),
|
||||||
@ -1799,7 +1804,6 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
|
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
|
|
||||||
// ... (reste du code pour les sorties, inchangé)
|
|
||||||
FutureBuilder<List<Map<String, dynamic>>>(
|
FutureBuilder<List<Map<String, dynamic>>>(
|
||||||
future: _database.getHistoriqueSortiesPersonnelles(
|
future: _database.getHistoriqueSortiesPersonnelles(
|
||||||
pointDeVenteId: pointVenteId,
|
pointDeVenteId: pointVenteId,
|
||||||
@ -1827,6 +1831,7 @@ void _showPointVenteDetails(Map<String, dynamic> pointVenteData) async {
|
|||||||
}
|
}
|
||||||
return Text(message, style: TextStyle(color: Colors.grey));
|
return Text(message, style: TextStyle(color: Colors.grey));
|
||||||
}
|
}
|
||||||
|
|
||||||
final sorties = snapshot.data!;
|
final sorties = snapshot.data!;
|
||||||
return Column(
|
return Column(
|
||||||
children: sorties.map((sortie) => Card(
|
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 :
|
// NOUVELLE VERSION de _buildCommandeCardForDialog qui utilise les paramètres du dialog
|
||||||
Widget _buildCommandeCardForDialog(Commande commande) {
|
Widget _buildCommandeCardForDialog(Commande commande, Set<int> expandedCommandes, StateSetter setDialogState) {
|
||||||
final bool isExpanded = _expandedCommandes.contains(commande.id);
|
final bool isExpanded = expandedCommandes.contains(commande.id);
|
||||||
|
|
||||||
return FutureBuilder<List<DetailCommande>>(
|
return FutureBuilder<List<DetailCommande>>(
|
||||||
future: _database.getDetailsCommande(commande.id!),
|
future: _database.getDetailsCommande(commande.id!),
|
||||||
@ -1957,26 +1960,37 @@ Widget _buildCommandeCardForDialog(Commande commande) {
|
|||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOut,
|
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(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
print('Card tapped! Current state: $isExpanded');
|
||||||
|
// UTILISER setDialogState au lieu de setState
|
||||||
|
setDialogState(() {
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
_expandedCommandes.remove(commande.id);
|
expandedCommandes.remove(commande.id);
|
||||||
|
print('Removed commande ${commande.id}');
|
||||||
} else {
|
} else {
|
||||||
_expandedCommandes.add(commande.id!);
|
expandedCommandes.add(commande.id!);
|
||||||
|
print('Added commande ${commande.id}');
|
||||||
}
|
}
|
||||||
|
print('Current expanded: $expandedCommandes');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(8),
|
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(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -2119,14 +2133,11 @@ Widget _buildCommandeCardForDialog(Commande commande) {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// Détails étendus (visibles seulement si expanded)
|
// Détails étendus avec AnimatedSize
|
||||||
AnimatedCrossFade(
|
AnimatedSize(
|
||||||
duration: Duration(milliseconds: 300),
|
duration: Duration(milliseconds: 300),
|
||||||
crossFadeState: isExpanded
|
curve: Curves.easeInOut,
|
||||||
? CrossFadeState.showSecond
|
child: isExpanded ? Column(
|
||||||
: CrossFadeState.showFirst,
|
|
||||||
firstChild: SizedBox.shrink(),
|
|
||||||
secondChild: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
@ -2274,18 +2285,18 @@ Widget _buildCommandeCardForDialog(Commande commande) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
) : SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getStatutColor(StatutCommande statut) {
|
Color _getStatutColor(StatutCommande statut) {
|
||||||
switch (statut) {
|
switch (statut) {
|
||||||
case StatutCommande.enAttente:
|
case StatutCommande.enAttente:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user