feat: Enhance container management UI with new management components and improved QR code generation flow
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:em2rp/services/qr_code_service.dart';
|
||||
@@ -122,14 +123,42 @@ class QRCodeDialog<T> extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<void> _downloadQRCode(BuildContext context, String id) 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 {
|
||||
// Générer l'image QR code en haute résolution
|
||||
final qrImage = await QRCodeService.generateQRCode(
|
||||
// Exécuter la génération dans un isolate séparé
|
||||
final qrImage = await compute(
|
||||
_generateQRCodeIsolate,
|
||||
id,
|
||||
size: 1024,
|
||||
useCache: false,
|
||||
);
|
||||
|
||||
// Fermer le dialog de chargement
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
// Utiliser la bibliothèque printing pour sauvegarder l'image
|
||||
await Printing.sharePdf(
|
||||
bytes: qrImage,
|
||||
@@ -145,6 +174,11 @@ class QRCodeDialog<T> extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
// Fermer le dialog de chargement en cas d'erreur
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@@ -156,6 +190,15 @@ class QRCodeDialog<T> extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Fonction statique pour exécuter la génération QR code dans un isolate
|
||||
static Future<Uint8List> _generateQRCodeIsolate(String id) async {
|
||||
return await QRCodeService.generateQRCode(
|
||||
id,
|
||||
size: 1024,
|
||||
useCache: false,
|
||||
);
|
||||
}
|
||||
|
||||
/// Factory pour équipement
|
||||
static QRCodeDialog forEquipment(dynamic equipment) {
|
||||
return QRCodeDialog(
|
||||
|
||||
Reference in New Issue
Block a user