Feat: Ajout du double-tap sur l'écran d'analyse pour l'édition rapide des impacts

This commit is contained in:
qguillaume
2026-05-26 16:47:37 +02:00
parent 18c01c3767
commit b721583e98

View File

@@ -5,6 +5,7 @@
library; library;
import 'dart:io'; import 'dart:io';
import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../core/constants/app_constants.dart'; import '../../core/constants/app_constants.dart';
@@ -182,6 +183,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
), ),
body: Stack( body: Stack(
children: [ children: [
Navigator.canPop(context) ? const SizedBox.shrink() : const SizedBox.shrink(), // Garde structurellement invisible
SingleChildScrollView( SingleChildScrollView(
controller: _scrollController, controller: _scrollController,
child: Column( child: Column(
@@ -434,6 +436,43 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
minScale: 1.0, minScale: 1.0,
maxScale: 10.0, maxScale: 10.0,
boundaryMargin: const EdgeInsets.all(double.infinity), boundaryMargin: const EdgeInsets.all(double.infinity),
child: GestureDetector(
// CORRECTION : Utilisation de onDoubleTapDown (compatible toutes versions Flutter)
onDoubleTapDown: (TapDownDetails details) {
final RenderBox? box = _imageKey.currentContext?.findRenderObject() as RenderBox?;
if (box == null) return;
final localOffset = box.globalToLocal(details.globalPosition);
// Coordonnées relatives (entre 0.0 et 1.0) sous le doigt
final relX = localOffset.dx / box.size.width;
final relY = localOffset.dy / box.size.height;
if (provider.shots.isEmpty) return;
// Recherche de l'impact le plus proche du double-clic
Shot? closestShot;
double minDistance = double.infinity;
// Seuil de tolérance de détection (environ 5% de la taille de la cible)
const double clickTolerance = 0.05;
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 < clickTolerance) {
minDistance = distance;
closestShot = shot;
}
}
// Si un impact est détecté sous le double-clic, on ouvre ses options !
if (closestShot != null) {
_showShotDetails(context, provider, closestShot);
}
},
child: Stack( child: Stack(
children: [ children: [
Image.file( Image.file(
@@ -454,6 +493,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
), ),
], ],
), ),
),
); );
} }