From 634fd8d4d776a33cd823f0d1d576b06af2ceb9e9 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 25 Mar 2026 17:41:42 +0100 Subject: [PATCH] missing file stat screnn --- lib/Screens/Statistics/statistics_screen.dart | 75 ++++++++++++++++--- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/lib/Screens/Statistics/statistics_screen.dart b/lib/Screens/Statistics/statistics_screen.dart index 684cae0..ccb4ba3 100644 --- a/lib/Screens/Statistics/statistics_screen.dart +++ b/lib/Screens/Statistics/statistics_screen.dart @@ -431,18 +431,22 @@ class _StatisticsScreenState extends State { } 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 = [ + 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 = []; + 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 { ]).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 headers, List> rows) { return Card( elevation: 0,