import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; import '../models/client.dart'; import '../services/reglages.dart'; import '../theme.dart'; /// Affiche le QR code d'un client dans une boîte de dialogue. Le client peut le /// prendre en photo (ou plus tard on l'imprimera) : c'est sa carte de fidélité. Future afficherQrClient(BuildContext context, Client client) { final magasin = Reglages.instance.nomMagasin; return showDialog( context: context, builder: (ctx) => Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), child: Padding( padding: const EdgeInsets.fromLTRB(28, 28, 28, 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ if (magasin.isNotEmpty) Text( magasin, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w600, color: AppTheme.grisTexte), ), const SizedBox(height: 4), Text( client.nomComplet, textAlign: TextAlign.center, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w700), ), const SizedBox(height: 20), Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), border: Border.all(color: const Color(0xFFE0E0E4)), ), child: QrImageView( data: client.code, version: QrVersions.auto, size: 220, gapless: false, eyeStyle: const QrEyeStyle( eyeShape: QrEyeShape.square, color: AppTheme.noir, ), dataModuleStyle: const QrDataModuleStyle( dataModuleShape: QrDataModuleShape.square, color: AppTheme.noir, ), ), ), const SizedBox(height: 14), Text( client.code, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w700, letterSpacing: 2, ), ), const SizedBox(height: 8), const Text( 'Présentez ce code en caisse pour cumuler des points.', textAlign: TextAlign.center, style: TextStyle(fontSize: 12, color: AppTheme.grisTexte), ), const SizedBox(height: 12), TextButton( onPressed: () => Navigator.of(ctx).pop(), child: const Text('Fermer'), ), ], ), ), ), ); }