- Mise à jour de la version de l'application à `1.1.17` dans `app_version.dart` et `version.json`. - Création d'un module complet de statistiques (`EventStatisticsPage`, `EventStatisticsService`, `EventStatisticsTab`) permettant de filtrer et visualiser les KPI d'événements (montants HT/TTC, panier moyen, répartition par type, top options). - Ajout d'une entrée "Statistiques événements" dans le menu latéral (`MainDrawer`) protégée par la permission `generate_reports`. - Migration exclusive vers Google Cloud TTS dans `SmartTextToSpeechService` et suppression de `TextToSpeechService` (Web Speech API native) pour garantir une compatibilité maximale sur tous les navigateurs. - Mise à jour des dépendances dans `pubspec.yaml` (`google_fonts`, `flutter_secure_storage`, `mobile_scanner`, `flutter_local_notifications`). - Migration du code d'export ICS vers `package:web` pour remplacer l'utilisation de `dart:html` obsolète. - Mise à jour du `CHANGELOG.md` documentant les statistiques et l'évolution du service de synthèse vocale.
227 lines
7.1 KiB
Dart
227 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:em2rp/utils/colors.dart';
|
|
import 'package:em2rp/views/widgets/data_management/event_types_management.dart';
|
|
import 'package:em2rp/views/widgets/data_management/options_management.dart';
|
|
import 'package:em2rp/views/widgets/data_management/events_export.dart';
|
|
import 'package:em2rp/views/widgets/data_management/event_statistics_tab.dart';
|
|
import 'package:em2rp/views/widgets/nav/main_drawer.dart';
|
|
import 'package:em2rp/views/widgets/nav/custom_app_bar.dart';
|
|
import 'package:em2rp/utils/permission_gate.dart';
|
|
class DataManagementPage extends StatefulWidget {
|
|
const DataManagementPage({super.key});
|
|
|
|
@override
|
|
State<DataManagementPage> createState() => _DataManagementPageState();
|
|
}
|
|
|
|
class _DataManagementPageState extends State<DataManagementPage> {
|
|
int _selectedIndex = 0;
|
|
|
|
final List<DataCategory> _categories = [
|
|
DataCategory(
|
|
title: 'Types d\'événements',
|
|
icon: Icons.category,
|
|
widget: const EventTypesManagement(),
|
|
),
|
|
DataCategory(
|
|
title: 'Options',
|
|
icon: Icons.tune,
|
|
widget: const OptionsManagement(),
|
|
),
|
|
DataCategory(
|
|
title: 'Exporter les événements',
|
|
icon: Icons.file_download,
|
|
widget: const EventsExport(),
|
|
),
|
|
DataCategory(
|
|
title: 'Statistiques evenements',
|
|
icon: Icons.bar_chart,
|
|
widget: const PermissionGate(
|
|
requiredPermissions: ['generate_reports'],
|
|
fallback: Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16),
|
|
child: Text(
|
|
'Vous n\'avez pas les permissions necessaires pour voir les statistiques.',
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
child: EventStatisticsTab(),
|
|
),
|
|
),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isMobile = MediaQuery.of(context).size.width < 800;
|
|
|
|
return PermissionGate(
|
|
requiredPermissions: const ['view_all_users'],
|
|
fallback: const Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: 'Accès refusé',
|
|
),
|
|
body: Center(
|
|
child: Text(
|
|
'Vous n\'avez pas les permissions nécessaires pour accéder à cette page.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
),
|
|
child: Scaffold(
|
|
appBar: CustomAppBar(title: 'Gestion des données'),
|
|
drawer: const MainDrawer(currentPage: '/data_management'), // Ajout du drawer
|
|
body: isMobile ? _buildMobileLayout() : _buildDesktopLayout(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMobileLayout() {
|
|
return PermissionGate(
|
|
requiredPermissions: const ['view_all_users'],
|
|
fallback: const Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: 'Accès refusé',
|
|
),
|
|
body: Center(
|
|
child: Text(
|
|
'Vous n\'avez pas les permissions nécessaires pour accéder à cette page.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
// Menu horizontal en mobile
|
|
SizedBox(
|
|
height: 60,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: _categories.length,
|
|
itemBuilder: (context, index) {
|
|
final isSelected = index == _selectedIndex;
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
|
child: ChoiceChip(
|
|
label: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
_categories[index].icon,
|
|
size: 16,
|
|
color: isSelected ? Colors.white : AppColors.rouge,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(_categories[index].title),
|
|
],
|
|
),
|
|
selected: isSelected,
|
|
onSelected: (selected) {
|
|
if (selected) {
|
|
setState(() => _selectedIndex = index);
|
|
}
|
|
},
|
|
selectedColor: AppColors.rouge,
|
|
labelStyle: TextStyle(
|
|
color: isSelected ? Colors.white : AppColors.rouge,
|
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
const Divider(),
|
|
// Contenu
|
|
Expanded(
|
|
child: _categories[_selectedIndex].widget,
|
|
),
|
|
],
|
|
)
|
|
);
|
|
}
|
|
|
|
Widget _buildDesktopLayout() {
|
|
return Row(
|
|
children: [
|
|
// Sidebar gauche
|
|
Container(
|
|
width: 280,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[100],
|
|
border: const Border(
|
|
right: BorderSide(color: Colors.grey, width: 1),
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.rouge.withValues(alpha: 0.1),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.settings, color: AppColors.rouge),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
'Catégories de données',
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColors.rouge,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
itemCount: _categories.length,
|
|
itemBuilder: (context, index) {
|
|
final isSelected = index == _selectedIndex;
|
|
return ListTile(
|
|
leading: Icon(
|
|
_categories[index].icon,
|
|
color: isSelected ? AppColors.rouge : Colors.grey[600],
|
|
),
|
|
title: Text(
|
|
_categories[index].title,
|
|
style: TextStyle(
|
|
color: isSelected ? AppColors.rouge : Colors.black87,
|
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
selected: isSelected,
|
|
selectedTileColor: AppColors.rouge.withValues(alpha: 0.1),
|
|
onTap: () => setState(() => _selectedIndex = index),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Contenu principal
|
|
Expanded(
|
|
child: _categories[_selectedIndex].widget,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class DataCategory {
|
|
final String title;
|
|
final IconData icon;
|
|
final Widget widget;
|
|
|
|
DataCategory({
|
|
required this.title,
|
|
required this.icon,
|
|
required this.widget,
|
|
});
|
|
}
|