feat: Enhance container management UI with new management components and improved QR code generation flow

This commit is contained in:
ElPoyo
2025-10-30 20:06:13 +01:00
parent 6abb8f1d14
commit e59e3e6316
11 changed files with 815 additions and 485 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart';
import 'package:em2rp/models/equipment_model.dart';
import 'package:em2rp/models/maintenance_model.dart';
@@ -293,17 +294,49 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
}
Future<void> _exportQRCode() async {
// Afficher le dialog de chargement
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Dialog(
child: Container(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(AppColors.rouge),
),
const SizedBox(height: 16),
const Text(
'Génération du QR Code...',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
],
),
),
),
);
try {
final qrImage = await QRCodeService.generateQRCode(
// Exécuter la génération dans un isolate séparé pour éviter le freeze
final qrImage = await compute(
_generateQRCodeIsolate,
widget.equipment.id,
size: 1024,
useCache: false,
);
await Printing.sharePdf(
bytes: qrImage,
filename: 'QRCode_${widget.equipment.id}.png',
);
// Fermer le dialog de chargement
if (mounted) {
Navigator.pop(context);
}
// Partager le fichier
if (mounted) {
await Printing.sharePdf(
bytes: qrImage,
filename: 'QRCode_${widget.equipment.id}.png',
);
}
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
@@ -314,14 +347,28 @@ class _EquipmentDetailPageState extends State<EquipmentDetailPage> {
);
}
} catch (e) {
// Fermer le dialog de chargement en cas d'erreur
if (mounted) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Erreur lors de l\'export: $e')),
SnackBar(
content: Text('Erreur lors de l\'export: $e'),
backgroundColor: Colors.red,
),
);
}
}
}
/// Fonction statique pour exécuter la génération QR code dans un isolate
static Future<Uint8List> _generateQRCodeIsolate(String equipmentId) async {
return await QRCodeService.generateQRCode(
equipmentId,
size: 1024,
useCache: false,
);
}
void _editEquipment() {
Navigator.push(
context,