fix(calibration): application du crop sur l'écran de calibration

This commit is contained in:
qguillaume
2026-05-27 00:03:29 +02:00
parent eabe7511bd
commit 02c0d449e4
2 changed files with 52 additions and 5 deletions

View File

@@ -215,10 +215,57 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
? Stack( ? Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
Image.file( // 1. L'IMAGE ZOOME ET RECADRE
File(provider.imagePath!), ClipRect(
fit: BoxFit.fill, 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( TargetCalibration(
key: _calibrationKey, key: _calibrationKey,
initialCenterX: provider.targetCenterX, initialCenterX: provider.targetCenterX,

View File

@@ -386,8 +386,8 @@ class _CropScreenState extends State<CropScreen> {
targetType: widget.targetType, targetType: widget.targetType,
initialCenterX: targetCenterX, initialCenterX: targetCenterX,
initialCenterY: targetCenterY, initialCenterY: targetCenterY,
cropScale: _scale, cropScale: _scale, // On passe bien le zoom mémorisé
cropOffset: _offset, cropOffset: _offset, // On passe bien le décalage mémorisé
), ),
), ),
); );