refactor(crop_screen): restrict rotation bounds to 15 degrees with high-precision decimal steps
This commit is contained in:
@@ -36,7 +36,7 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
Offset _startOffset = Offset.zero;
|
Offset _startOffset = Offset.zero;
|
||||||
Offset _startFocalPoint = 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;
|
double _rotation = 0.0;
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
@@ -143,7 +143,7 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// NOUVELLE JAUGE DE ROTATION CENTRÉE À ZÉRO
|
// JAUGE DE ROTATION HAUTE PRÉCISION BRIDÉE À 15°
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -156,7 +156,7 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
style: TextStyle(color: Colors.white70, fontSize: 13, fontWeight: FontWeight.w600),
|
style: TextStyle(color: Colors.white70, fontSize: 13, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
Text(
|
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),
|
style: const TextStyle(color: Color(0xFF00FF00), fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -167,10 +167,10 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Slider(
|
child: Slider(
|
||||||
value: _rotation,
|
value: _rotation,
|
||||||
min: -45.0, // Pivot max à gauche
|
min: -15.0, // Pivot maximum à gauche bridé à 15°
|
||||||
max: 45.0, // Pivot max à droite
|
max: 15.0, // Pivot maximum à droite bridé à 15°
|
||||||
divisions: 90, // Un cran précis par degré
|
divisions: 300, // 300 divisions pour obtenir un cran ultra-précis tous les 0,1°
|
||||||
label: '${_rotation.round()}°',
|
label: '${_rotation.toStringAsFixed(1)}°',
|
||||||
activeColor: const Color(0xFF1A73E8),
|
activeColor: const Color(0xFF1A73E8),
|
||||||
inactiveColor: Colors.white12,
|
inactiveColor: Colors.white12,
|
||||||
onChanged: (double value) {
|
onChanged: (double value) {
|
||||||
@@ -297,7 +297,7 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: ColorFiltered(
|
child: ColorFiltered(
|
||||||
colorFilter: ColorFilter.mode(
|
colorFilter: ColorFilter.mode(
|
||||||
const Color(0xFF101214), // Même couleur que le fond de ton écran
|
const Color(0xFF101214),
|
||||||
BlendMode.srcOut,
|
BlendMode.srcOut,
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
@@ -307,7 +307,7 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: _cropSize,
|
width: _cropSize,
|
||||||
height: _cropSize,
|
height: _cropSize,
|
||||||
color: Colors.black, // Pas de decoration ni de borderRadius ici !
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -365,7 +365,6 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
_scale = (_baseScale * details.scale).clamp(0.8, 8.0);
|
_scale = (_baseScale * details.scale).clamp(0.8, 8.0);
|
||||||
final delta = details.focalPoint - _startFocalPoint;
|
final delta = details.focalPoint - _startFocalPoint;
|
||||||
_offset = _startOffset + delta;
|
_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<CropScreen> {
|
|||||||
initialCenterY: targetCenterY,
|
initialCenterY: targetCenterY,
|
||||||
cropScale: _scale,
|
cropScale: _scale,
|
||||||
cropOffset: _offset,
|
cropOffset: _offset,
|
||||||
cropRotation: _rotation, // <-- On envoie la rotation ici !
|
cropRotation: _rotation,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user