Feat: Ajout du double-tap sur l'écran d'analyse pour l'édition rapide des impacts
This commit is contained in:
@@ -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,25 +436,63 @@ 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: Stack(
|
child: GestureDetector(
|
||||||
children: [
|
// CORRECTION : Utilisation de onDoubleTapDown (compatible toutes versions Flutter)
|
||||||
Image.file(
|
onDoubleTapDown: (TapDownDetails details) {
|
||||||
File(provider.imagePath!),
|
final RenderBox? box = _imageKey.currentContext?.findRenderObject() as RenderBox?;
|
||||||
key: _imageKey,
|
if (box == null) return;
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
final localOffset = box.globalToLocal(details.globalPosition);
|
||||||
TargetOverlay(
|
|
||||||
targetCenterX: provider.targetCenterX,
|
// Coordonnées relatives (entre 0.0 et 1.0) sous le doigt
|
||||||
targetCenterY: provider.targetCenterY,
|
final relX = localOffset.dx / box.size.width;
|
||||||
targetRadius: provider.targetRadius,
|
final relY = localOffset.dy / box.size.height;
|
||||||
targetType: provider.targetType!,
|
|
||||||
shots: provider.shots,
|
if (provider.shots.isEmpty) return;
|
||||||
showRings: true,
|
|
||||||
zoomScale: _currentZoomScale,
|
// Recherche de l'impact le plus proche du double-clic
|
||||||
onShotTapped: (shot) => _showShotDetails(context, provider, shot),
|
Shot? closestShot;
|
||||||
onAddShot: (relX, relY) => provider.addShot(relX, relY),
|
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(
|
||||||
|
children: [
|
||||||
|
Image.file(
|
||||||
|
File(provider.imagePath!),
|
||||||
|
key: _imageKey,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
TargetOverlay(
|
||||||
|
targetCenterX: provider.targetCenterX,
|
||||||
|
targetCenterY: provider.targetCenterY,
|
||||||
|
targetRadius: provider.targetRadius,
|
||||||
|
targetType: provider.targetType!,
|
||||||
|
shots: provider.shots,
|
||||||
|
showRings: true,
|
||||||
|
zoomScale: _currentZoomScale,
|
||||||
|
onShotTapped: (shot) => _showShotDetails(context, provider, shot),
|
||||||
|
onAddShot: (relX, relY) => provider.addShot(relX, relY),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user