missing file stat screnn

This commit is contained in:
Thomas Fransolet 2026-03-25 17:41:42 +01:00
parent f90f014f36
commit 634fd8d4d7

View File

@ -431,18 +431,22 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
}
Widget _buildTablesRow(StatsSummaryDTO stats) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (stats.topPois.isNotEmpty) Expanded(child: _buildPoiTable(stats)),
if (stats.topPois.isNotEmpty && stats.topAgendaEvents.isNotEmpty) const SizedBox(width: 12),
if (stats.topAgendaEvents.isNotEmpty) Expanded(child: _buildAgendaTable(stats)),
if ((stats.topPois.isNotEmpty || stats.topAgendaEvents.isNotEmpty) && stats.quizStats.isNotEmpty) const SizedBox(width: 12),
if (stats.quizStats.isNotEmpty) Expanded(child: _buildQuizTable(stats)),
if ((stats.topPois.isNotEmpty || stats.topAgendaEvents.isNotEmpty || stats.quizStats.isNotEmpty) && stats.gameStats.isNotEmpty) const SizedBox(width: 12),
if (stats.gameStats.isNotEmpty) Expanded(child: _buildGameTable(stats)),
],
);
final tables = <Widget>[
if (stats.topPois.isNotEmpty) Expanded(child: _buildPoiTable(stats)),
if (stats.topAgendaEvents.isNotEmpty) Expanded(child: _buildAgendaTable(stats)),
if (stats.quizStats.isNotEmpty) Expanded(child: _buildQuizTable(stats)),
if (stats.gameStats.isNotEmpty) Expanded(child: _buildGameTable(stats)),
if (stats.topArticles.isNotEmpty) Expanded(child: _buildArticleTable(stats)),
if (stats.topMenuItems.isNotEmpty) Expanded(child: _buildMenuTable(stats)),
if (stats.qrScans.totalScans > 0) Expanded(child: _buildQrCard(stats)),
];
if (tables.isEmpty) return const SizedBox();
final spaced = <Widget>[];
for (var i = 0; i < tables.length; i++) {
spaced.add(tables[i]);
if (i < tables.length - 1) spaced.add(const SizedBox(width: 12));
}
return Row(crossAxisAlignment: CrossAxisAlignment.start, children: spaced);
}
Widget _buildPoiTable(StatsSummaryDTO stats) {
@ -475,6 +479,53 @@ class _StatisticsScreenState extends State<StatisticsScreen> {
]).toList());
}
Widget _buildArticleTable(StatsSummaryDTO stats) {
return _tableCard('Articles lus', ['Section', 'Lectures'], stats.topArticles.map((a) => [
a.sectionId ?? '',
'${a.reads}',
]).toList());
}
Widget _buildMenuTable(StatsSummaryDTO stats) {
return _tableCard('Menu', ['Item', 'Taps'], stats.topMenuItems.map((m) => [
m.menuItemTitle ?? m.targetSectionId ?? '',
'${m.taps}',
]).toList());
}
Widget _buildQrCard(StatsSummaryDTO stats) {
final qr = stats.qrScans;
return Card(
elevation: 0,
color: kWhite,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('QR Scans', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: kPrimaryColor)),
const SizedBox(height: 12),
_qrRow(Icons.qr_code_scanner, 'Total', '${qr.totalScans}', kPrimaryColor),
const SizedBox(height: 8),
_qrRow(Icons.check_circle_outline, 'Valides', '${qr.validScans}', Colors.green.shade600),
const SizedBox(height: 8),
_qrRow(Icons.cancel_outlined, 'Invalides', '${qr.invalidScans}', Colors.red.shade400),
],
),
),
);
}
Widget _qrRow(IconData icon, String label, String value, Color color) {
return Row(children: [
Icon(icon, size: 16, color: color),
const SizedBox(width: 6),
Expanded(child: Text(label, style: TextStyle(fontSize: 13, color: kBodyTextColor))),
Text(value, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: color)),
]);
}
Widget _tableCard(String title, List<String> headers, List<List<String>> rows) {
return Card(
elevation: 0,