169 lines
4.5 KiB
Dart
169 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../tokens/unionflow_colors.dart';
|
|
|
|
/// Type d'export disponible
|
|
enum ExportType {
|
|
pdf('PDF', Icons.picture_as_pdf),
|
|
excel('Excel', Icons.table_chart),
|
|
csv('CSV', Icons.description);
|
|
|
|
final String label;
|
|
final IconData icon;
|
|
const ExportType(this.label, this.icon);
|
|
}
|
|
|
|
/// Bouton d'export avec options
|
|
class UnionExportButton extends StatelessWidget {
|
|
final Function(ExportType) onExport;
|
|
final bool isLoading;
|
|
|
|
const UnionExportButton({
|
|
super.key,
|
|
required this.onExport,
|
|
this.isLoading = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopupMenuButton<ExportType>(
|
|
icon: Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
gradient: UnionFlowColors.primaryGradient,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: UnionFlowColors.greenGlowShadow,
|
|
),
|
|
child: isLoading
|
|
? const SizedBox(
|
|
width: 20,
|
|
height: 20,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
),
|
|
)
|
|
: const Icon(
|
|
Icons.download,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
),
|
|
itemBuilder: (context) => ExportType.values.map((type) {
|
|
return PopupMenuItem<ExportType>(
|
|
value: type,
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
type.icon,
|
|
size: 20,
|
|
color: UnionFlowColors.unionGreen,
|
|
),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
'Exporter en ${type.label}',
|
|
style: const TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w600,
|
|
color: UnionFlowColors.textPrimary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
onSelected: onExport,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
elevation: 8,
|
|
color: UnionFlowColors.surface,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Dialog pour confirmer l'export
|
|
class ExportConfirmDialog extends StatelessWidget {
|
|
final ExportType exportType;
|
|
final VoidCallback onConfirm;
|
|
final String? message;
|
|
|
|
const ExportConfirmDialog({
|
|
super.key,
|
|
required this.exportType,
|
|
required this.onConfirm,
|
|
this.message,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
backgroundColor: UnionFlowColors.surface,
|
|
title: Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: UnionFlowColors.unionGreen.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Icon(
|
|
exportType.icon,
|
|
color: UnionFlowColors.unionGreen,
|
|
size: 24,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
'Exporter en ${exportType.label}',
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w700,
|
|
color: UnionFlowColors.textPrimary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
content: Text(
|
|
message ?? 'Voulez-vous exporter le rapport au format ${exportType.label}?',
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: UnionFlowColors.textSecondary,
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text(
|
|
'Annuler',
|
|
style: TextStyle(
|
|
color: UnionFlowColors.textSecondary,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onConfirm();
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: UnionFlowColors.unionGreen,
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
elevation: 0,
|
|
),
|
|
child: const Text(
|
|
'Confirmer',
|
|
style: TextStyle(fontWeight: FontWeight.w700),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|