From 4d2ca2c94faae9bbbee4e0dce50c1daec56b43d1 Mon Sep 17 00:00:00 2001 From: qguillaume Date: Wed, 27 May 2026 14:48:57 +0200 Subject: [PATCH] refactor(crop_screen): restrict rotation bounds to 15 degrees with high-precision decimal steps --- lib/features/crop/crop_screen.dart | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/features/crop/crop_screen.dart b/lib/features/crop/crop_screen.dart index fd9fb3d8..974cb670 100644 --- a/lib/features/crop/crop_screen.dart +++ b/lib/features/crop/crop_screen.dart @@ -36,7 +36,7 @@ class _CropScreenState extends State { Offset _startOffset = Offset.zero; Offset _startFocalPoint = Offset.zero; - // CORRECTION : _rotation gère désormais l'angle en degrés pour le Slider (-45.0 à 45.0) + // PRÉCISION MAXIMUM : Amplitude restreinte de -15.0 à 15.0 degrés double _rotation = 0.0; bool _isLoading = false; @@ -143,7 +143,7 @@ class _CropScreenState extends State { const SizedBox(height: 16), - // NOUVELLE JAUGE DE ROTATION CENTRÉE À ZÉRO + // JAUGE DE ROTATION HAUTE PRÉCISION BRIDÉE À 15° Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: Column( @@ -156,7 +156,7 @@ class _CropScreenState extends State { style: TextStyle(color: Colors.white70, fontSize: 13, fontWeight: FontWeight.w600), ), Text( - '${_rotation.round()}°', + '${_rotation.toStringAsFixed(1)}°', // Affiche désormais le dixième de degré pour la précision style: const TextStyle(color: Color(0xFF00FF00), fontWeight: FontWeight.bold), ), ], @@ -167,10 +167,10 @@ class _CropScreenState extends State { Expanded( child: Slider( value: _rotation, - min: -45.0, // Pivot max à gauche - max: 45.0, // Pivot max à droite - divisions: 90, // Un cran précis par degré - label: '${_rotation.round()}°', + min: -15.0, // Pivot maximum à gauche bridé à 15° + max: 15.0, // Pivot maximum à droite bridé à 15° + divisions: 300, // 300 divisions pour obtenir un cran ultra-précis tous les 0,1° + label: '${_rotation.toStringAsFixed(1)}°', activeColor: const Color(0xFF1A73E8), inactiveColor: Colors.white12, onChanged: (double value) { @@ -297,7 +297,7 @@ class _CropScreenState extends State { child: IgnorePointer( child: ColorFiltered( colorFilter: ColorFilter.mode( - const Color(0xFF101214), // Même couleur que le fond de ton écran + const Color(0xFF101214), BlendMode.srcOut, ), child: Stack( @@ -307,7 +307,7 @@ class _CropScreenState extends State { child: Container( width: _cropSize, height: _cropSize, - color: Colors.black, // Pas de decoration ni de borderRadius ici ! + color: Colors.black, ), ), ], @@ -365,7 +365,6 @@ class _CropScreenState extends State { _scale = (_baseScale * details.scale).clamp(0.8, 8.0); final delta = details.focalPoint - _startFocalPoint; _offset = _startOffset + delta; - // SÉCURITÉ : On a retiré le calcul de rotation fou à deux doigts d'ici ! }); } @@ -388,7 +387,7 @@ class _CropScreenState extends State { initialCenterY: targetCenterY, cropScale: _scale, cropOffset: _offset, - cropRotation: _rotation, // <-- On envoie la rotation ici ! + cropRotation: _rotation, ), ), );