|
|
|
@ -25,13 +25,14 @@ class _ScanQRPageState extends State<ScanQRPage> { |
|
|
|
} |
|
|
|
|
|
|
|
void _initializeController() { |
|
|
|
if (!isMobile) { |
|
|
|
setState(() { |
|
|
|
_hasError = true; |
|
|
|
_errorMessage = "Le scanner QR n'est pas disponible sur cette plateforme."; |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
// if (!isMobile) { |
|
|
|
// setState(() { |
|
|
|
// _hasError = true; |
|
|
|
// _errorMessage = |
|
|
|
// "Le scanner QR n'est pas disponible sur cette plateforme."; |
|
|
|
// }); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
try { |
|
|
|
cameraController = MobileScannerController( |
|
|
|
detectionSpeed: DetectionSpeed.noDuplicates, |
|
|
|
@ -61,7 +62,9 @@ class _ScanQRPageState extends State<ScanQRPage> { |
|
|
|
return Scaffold( |
|
|
|
appBar: AppBar( |
|
|
|
title: const Text('Scanner QR Code'), |
|
|
|
actions: _hasError ? [] : [ |
|
|
|
actions: _hasError |
|
|
|
? [] |
|
|
|
: [ |
|
|
|
if (cameraController != null) ...[ |
|
|
|
IconButton( |
|
|
|
color: Colors.white, |
|
|
|
@ -71,7 +74,8 @@ class _ScanQRPageState extends State<ScanQRPage> { |
|
|
|
), |
|
|
|
IconButton( |
|
|
|
color: Colors.white, |
|
|
|
icon: const Icon(Icons.flip_camera_ios, color: Colors.white), |
|
|
|
icon: |
|
|
|
const Icon(Icons.flip_camera_ios, color: Colors.white), |
|
|
|
iconSize: 32.0, |
|
|
|
onPressed: () => cameraController!.switchCamera(), |
|
|
|
), |
|
|
|
@ -150,7 +154,8 @@ class _ScanQRPageState extends State<ScanQRPage> { |
|
|
|
children: [ |
|
|
|
const Icon(Icons.error, size: 64, color: Colors.red), |
|
|
|
const SizedBox(height: 16), |
|
|
|
Text('Erreur: ${error.errorDetails?.message ?? 'Erreur inconnue'}'), |
|
|
|
Text( |
|
|
|
'Erreur: ${error.errorDetails?.message ?? 'Erreur inconnue'}'), |
|
|
|
const SizedBox(height: 16), |
|
|
|
ElevatedButton( |
|
|
|
onPressed: () => _initializeController(), |
|
|
|
@ -236,19 +241,25 @@ class QrScannerOverlay extends CustomPainter { |
|
|
|
..style = PaintingStyle.stroke; |
|
|
|
|
|
|
|
// Coins du scanner |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft, areaTop, borderLength, true, true); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop, borderLength, false, true); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft, areaTop + areaSize, borderLength, true, false); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop + areaSize, borderLength, false, false); |
|
|
|
_drawCorner( |
|
|
|
canvas, borderPaint, areaLeft, areaTop, borderLength, true, true); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop, borderLength, |
|
|
|
false, true); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft, areaTop + areaSize, borderLength, |
|
|
|
true, false); |
|
|
|
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop + areaSize, |
|
|
|
borderLength, false, false); |
|
|
|
} |
|
|
|
|
|
|
|
void _drawCorner(Canvas canvas, Paint paint, double x, double y, double length, bool isLeft, bool isTop) { |
|
|
|
void _drawCorner(Canvas canvas, Paint paint, double x, double y, |
|
|
|
double length, bool isLeft, bool isTop) { |
|
|
|
final double horizontalStart = isLeft ? x : x - length; |
|
|
|
final double horizontalEnd = isLeft ? x + length : x; |
|
|
|
final double verticalStart = isTop ? y : y - length; |
|
|
|
final double verticalEnd = isTop ? y + length : y; |
|
|
|
|
|
|
|
canvas.drawLine(Offset(horizontalStart, y), Offset(horizontalEnd, y), paint); |
|
|
|
canvas.drawLine( |
|
|
|
Offset(horizontalStart, y), Offset(horizontalEnd, y), paint); |
|
|
|
canvas.drawLine(Offset(x, verticalStart), Offset(x, verticalEnd), paint); |
|
|
|
} |
|
|
|
|
|
|
|
|