fix: trying to avoid conflict first with tap and pin on plotting screen
This commit is contained in:
@@ -530,6 +530,46 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
..rotateZ((provider.cropRotation) * (math.pi / 180)),
|
||||
alignment: Alignment.center,
|
||||
child: GestureDetector(
|
||||
// AJOUT D'IMPACT : géré ici, sur le GestureDetector parent, par un
|
||||
// simple tap. Un seul détecteur de tap -> plus de couche concurrente
|
||||
// avec l'InteractiveViewer, donc le pinch/zoom redevient fiable.
|
||||
//
|
||||
// Flutter ne déclenche onTapUp que si le doigt n'a pas bougé au-delà
|
||||
// du seuil (touch slop) : un déplacement part en pan via
|
||||
// l'InteractiveViewer, un toucher bref pose un impact.
|
||||
onTapUp: (TapUpDetails details) {
|
||||
// Pendant le déplacement d'un impact, on n'ajoute rien.
|
||||
if (_movingShotId != null) return;
|
||||
|
||||
final RenderBox? box =
|
||||
_imageKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (box == null) return;
|
||||
|
||||
final localOffset = box.globalToLocal(details.globalPosition);
|
||||
final relX = (localOffset.dx / box.size.width).clamp(0.0, 1.0);
|
||||
final relY = (localOffset.dy / box.size.height).clamp(0.0, 1.0);
|
||||
|
||||
// Si le tap tombe sur un impact existant, on l'ouvre plutôt que
|
||||
// d'en empiler un nouveau par-dessus.
|
||||
Shot? hitShot;
|
||||
double minDistance = double.infinity;
|
||||
const double hitTolerance = 0.04;
|
||||
for (final shot in provider.shots) {
|
||||
final dx = shot.x - relX;
|
||||
final dy = shot.y - relY;
|
||||
final distance = math.sqrt(dx * dx + dy * dy);
|
||||
if (distance < minDistance && distance < hitTolerance) {
|
||||
minDistance = distance;
|
||||
hitShot = shot;
|
||||
}
|
||||
}
|
||||
|
||||
if (hitShot != null) {
|
||||
_showShotDetails(context, provider, hitShot);
|
||||
} else {
|
||||
provider.addShot(relX, relY);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
final RenderBox? box =
|
||||
_imageKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
@@ -632,7 +672,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
zoomScale: _currentZoomScale,
|
||||
onShotTapped: (shot) =>
|
||||
_showShotDetails(context, provider, shot),
|
||||
onAddShot: (relX, relY) => provider.addShot(relX, relY),
|
||||
// onAddShot retiré : l'ajout est géré par le GestureDetector
|
||||
// parent (onTapUp) pour ne pas concurrencer le pinch/zoom.
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user