From 02c0d449e4e36f0f53300c8c29f938e36aaae41c Mon Sep 17 00:00:00 2001 From: qguillaume Date: Wed, 27 May 2026 00:03:29 +0200 Subject: [PATCH] =?UTF-8?q?fix(calibration):=20application=20du=20crop=20s?= =?UTF-8?q?ur=20l'=C3=A9cran=20de=20calibration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/features/analysis/analysis_screen.dart | 53 ++++++++++++++++++++-- lib/features/crop/crop_screen.dart | 4 +- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/lib/features/analysis/analysis_screen.dart b/lib/features/analysis/analysis_screen.dart index f97d142a..ba79c00f 100644 --- a/lib/features/analysis/analysis_screen.dart +++ b/lib/features/analysis/analysis_screen.dart @@ -215,10 +215,57 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> { ? Stack( fit: StackFit.expand, children: [ - Image.file( - File(provider.imagePath!), - fit: BoxFit.fill, + // 1. L'IMAGE ZOOME ET RECADRE + ClipRect( + child: Builder( + builder: (context) { + const double _currentRotation = 0.0; + + return Transform( + transform: Matrix4.identity() + ..translate(widget.cropOffset?.dx ?? 0.0, widget.cropOffset?.dy ?? 0.0) + ..scale(widget.cropScale ?? 1.0, widget.cropScale ?? 1.0), + alignment: Alignment.center, + child: Image.file( + File(provider.imagePath!), + fit: BoxFit.contain, // Respecte la géométrie du CropScreen + ), + ); + } + ), ), + + // 2. LE MASQUE OPAQUE (Cache tout ce qui dépasse pour simuler le Crop parfait) + Positioned.fill( + child: IgnorePointer( + child: LayoutBuilder( + builder: (context, constraints) { + // On recalcule la taille du carré de calibration (95% du plus petit côté, comme l'écran d'avant) + final double cropSize = math.min(constraints.maxWidth, constraints.maxHeight) * 0.95; + + return ColorFiltered( + colorFilter: const ColorFilter.mode( + Color(0xFF101214), // La couleur sombre de ton fond d'écran + BlendMode.srcOut, + ), + child: Stack( + children: [ + Center( + child: Container( + width: cropSize, + height: cropSize, + color: Colors.black, // Fenêtre visible carrée aux coins droits + ), + ), + ], + ), + ); + }, + ), + ), + ), + + // 3. LA CIBLE ROUGE DE CALIBRATION (Reste au-dessus, parfaitement accessible) TargetCalibration( key: _calibrationKey, initialCenterX: provider.targetCenterX, diff --git a/lib/features/crop/crop_screen.dart b/lib/features/crop/crop_screen.dart index fad93f22..2bdd7183 100644 --- a/lib/features/crop/crop_screen.dart +++ b/lib/features/crop/crop_screen.dart @@ -386,8 +386,8 @@ class _CropScreenState extends State { targetType: widget.targetType, initialCenterX: targetCenterX, initialCenterY: targetCenterY, - cropScale: _scale, - cropOffset: _offset, + cropScale: _scale, // On passe bien le zoom mémorisé + cropOffset: _offset, // On passe bien le décalage mémorisé ), ), );