désactivation de l'auto analyse au chargement de l'écran d'analyse

This commit is contained in:
2026-01-31 20:55:28 +01:00
parent 972474750f
commit 9ccb149dda
3 changed files with 634 additions and 430 deletions

3
devtools_options.yaml Normal file
View File

@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:

View File

@@ -80,7 +80,8 @@ class AnalysisProvider extends ChangeNotifier {
double get targetCenterY => _targetCenterY;
double get targetRadius => _targetRadius;
int get ringCount => _ringCount;
List<double>? get ringRadii => _ringRadii != null ? List.unmodifiable(_ringRadii!) : null;
List<double>? get ringRadii =>
_ringRadii != null ? List.unmodifiable(_ringRadii!) : null;
double get imageAspectRatio => _imageAspectRatio;
List<Shot> get shots => List.unmodifiable(_shots);
ScoreResult? get scoreResult => _scoreResult;
@@ -97,13 +98,22 @@ class AnalysisProvider extends ChangeNotifier {
DistortionParameters? get distortionParams => _distortionParams;
String? get correctedImagePath => _correctedImagePath;
bool get hasDistortion => _distortionParams?.needsCorrection ?? false;
/// Retourne le chemin de l'image à afficher (corrigée si activée, originale sinon)
String? get displayImagePath => _distortionCorrectionEnabled && _correctedImagePath != null
String? get displayImagePath =>
_distortionCorrectionEnabled && _correctedImagePath != null
? _correctedImagePath
: _imagePath;
/// Analyze an image
Future<void> analyzeImage(String imagePath, TargetType targetType) async {
///
/// [autoAnalyze] determines if we should run automatic detection immediately.
/// If false, only the image is loaded and default target parameters are set.
Future<void> analyzeImage(
String imagePath,
TargetType targetType, {
bool autoAnalyze = true,
}) async {
_state = AnalysisState.loading;
_imagePath = imagePath;
_targetType = targetType;
@@ -119,6 +129,20 @@ class AnalysisProvider extends ChangeNotifier {
_imageAspectRatio = frame.image.width / frame.image.height;
frame.image.dispose();
if (!autoAnalyze) {
// Just setup default values without running detection
_targetCenterX = 0.5;
_targetCenterY = 0.5;
_targetRadius = 0.4;
// Initialize empty shots list
_shots = [];
_state = AnalysisState.success;
notifyListeners();
return;
}
// Detect target and impacts
final result = _detectionService.detectTarget(imagePath, targetType);
@@ -162,13 +186,7 @@ class AnalysisProvider extends ChangeNotifier {
/// Add a manual shot
void addShot(double x, double y) {
final score = _calculateShotScore(x, y);
final shot = Shot(
id: _uuid.v4(),
x: x,
y: y,
score: score,
sessionId: '',
);
final shot = Shot(id: _uuid.v4(), x: x, y: y, score: score, sessionId: '');
_shots.add(shot);
_recalculateScores();
@@ -190,11 +208,7 @@ class AnalysisProvider extends ChangeNotifier {
if (index == -1) return;
final newScore = _calculateShotScore(newX, newY);
_shots[index] = _shots[index].copyWith(
x: newX,
y: newY,
score: newScore,
);
_shots[index] = _shots[index].copyWith(x: newX, y: newY, score: newScore);
_recalculateScores();
_recalculateGrouping();
@@ -334,7 +348,9 @@ class AnalysisProvider extends ChangeNotifier {
double tolerance = 2.0,
bool clearExisting = false,
}) async {
if (_imagePath == null || _targetType == null || _referenceImpacts.length < 2) {
if (_imagePath == null ||
_targetType == null ||
_referenceImpacts.length < 2) {
return 0;
}
@@ -343,7 +359,8 @@ class AnalysisProvider extends ChangeNotifier {
.map((shot) => ReferenceImpact(x: shot.x, y: shot.y))
.toList();
final detectedImpacts = _detectionService.detectImpactsWithOpenCVFromReferences(
final detectedImpacts = _detectionService
.detectImpactsWithOpenCVFromReferences(
_imagePath!,
_targetType!,
_targetCenterX,
@@ -381,13 +398,7 @@ class AnalysisProvider extends ChangeNotifier {
/// Add a reference impact for calibrated detection
void addReferenceImpact(double x, double y) {
final score = _calculateShotScore(x, y);
final shot = Shot(
id: _uuid.v4(),
x: x,
y: y,
score: score,
sessionId: '',
);
final shot = Shot(id: _uuid.v4(), x: x, y: y, score: score, sessionId: '');
_referenceImpacts.add(shot);
notifyListeners();
}
@@ -428,7 +439,9 @@ class AnalysisProvider extends ChangeNotifier {
double tolerance = 2.0,
bool clearExisting = false,
}) async {
if (_imagePath == null || _targetType == null || _learnedCharacteristics == null) {
if (_imagePath == null ||
_targetType == null ||
_learnedCharacteristics == null) {
return 0;
}
@@ -468,7 +481,13 @@ class AnalysisProvider extends ChangeNotifier {
}
/// Adjust target position
void adjustTargetPosition(double centerX, double centerY, double radius, {int? ringCount, List<double>? ringRadii}) {
void adjustTargetPosition(
double centerX,
double centerY,
double radius, {
int? ringCount,
List<double>? ringRadii,
}) {
_targetCenterX = centerX;
_targetCenterY = centerY;
_targetRadius = radius;
@@ -529,7 +548,6 @@ class AnalysisProvider extends ChangeNotifier {
}
}
/* version deux a tester*/
/// Calcule ET applique la correction pour un feedback immédiat
Future<void> calculateAndApplyDistortion() async {

View File

@@ -39,7 +39,7 @@ class AnalysisScreen extends StatelessWidget {
scoreCalculatorService: context.read<ScoreCalculatorService>(),
groupingAnalyzerService: context.read<GroupingAnalyzerService>(),
sessionRepository: context.read<SessionRepository>(),
)..analyzeImage(imagePath, targetType),
)..analyzeImage(imagePath, targetType, autoAnalyze: false),
child: const _AnalysisScreenContent(),
);
}
@@ -58,7 +58,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
bool _isFullscreenEditMode = false;
bool _isAtBottom = false;
final ScrollController _scrollController = ScrollController();
final TransformationController _transformationController = TransformationController();
final TransformationController _transformationController =
TransformationController();
final GlobalKey _imageKey = GlobalKey();
double _currentZoomScale = 1.0;
@@ -72,7 +73,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
void _onScroll() {
if (!_scrollController.hasClients) return;
// Detect if we are near the bottom (within 20 pixels of the specific spacing we added)
final isBottom = _scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 20;
final isBottom =
_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 20;
if (isBottom != _isAtBottom) {
setState(() {
_isAtBottom = isBottom;
@@ -115,13 +118,16 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
actions: [
Consumer<AnalysisProvider>(
builder: (context, provider, _) {
if (provider.state != AnalysisState.success) return const SizedBox.shrink();
if (provider.state != AnalysisState.success)
return const SizedBox.shrink();
return IconButton(
icon: Icon(_isCalibrating ? Icons.check : Icons.tune),
onPressed: () {
setState(() => _isCalibrating = !_isCalibrating);
},
tooltip: _isCalibrating ? 'Terminer calibration' : 'Calibrer la cible',
tooltip: _isCalibrating
? 'Terminer calibration'
: 'Calibrer la cible',
color: _isCalibrating ? AppTheme.successColor : null,
);
},
@@ -155,7 +161,11 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, size: 64, color: AppTheme.errorColor),
Icon(
Icons.error_outline,
size: 64,
color: AppTheme.errorColor,
),
const SizedBox(height: 16),
Text(
provider.errorMessage ?? 'Une erreur est survenue',
@@ -195,7 +205,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
if (_isCalibrating)
Container(
color: AppTheme.warningColor,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 16,
),
child: const Row(
children: [
Icon(Icons.tune, color: Colors.white, size: 20),
@@ -203,7 +216,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
Expanded(
child: Text(
'Mode Calibration - Ajustez le centre et la taille de la cible',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
@@ -214,21 +230,34 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
if (_isSelectingReferences)
Container(
color: Colors.deepPurple,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 16,
),
child: Row(
children: [
const Icon(Icons.touch_app, color: Colors.white, size: 20),
const Icon(
Icons.touch_app,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'Selectionnez ${provider.referenceImpacts.length}/3-4 impacts de reference',
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
if (provider.referenceImpacts.isNotEmpty)
TextButton(
onPressed: () => provider.clearReferenceImpacts(),
child: const Text('Effacer', style: TextStyle(color: Colors.white)),
child: const Text(
'Effacer',
style: TextStyle(color: Colors.white),
),
),
],
),
@@ -238,15 +267,25 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
if (_isCalibrating)
Container(
color: Colors.black87,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
child: Column(
children: [
// Ring count slider
Row(
children: [
const Icon(Icons.radio_button_unchecked, color: Colors.white, size: 20),
const Icon(
Icons.radio_button_unchecked,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
const Text('Anneaux:', style: TextStyle(color: Colors.white)),
const Text(
'Anneaux:',
style: TextStyle(color: Colors.white),
),
Expanded(
child: Slider(
value: provider.ringCount.toDouble(),
@@ -266,14 +305,20 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
decoration: BoxDecoration(
color: AppTheme.primaryColor,
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${provider.ringCount}',
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
@@ -281,15 +326,23 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
// Target size slider
Row(
children: [
const Icon(Icons.zoom_out_map, color: Colors.white, size: 20),
const Icon(
Icons.zoom_out_map,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
const Text('Taille:', style: TextStyle(color: Colors.white)),
const Text(
'Taille:',
style: TextStyle(color: Colors.white),
),
Expanded(
child: Slider(
value: provider.targetRadius.clamp(0.05, 3.0),
min: 0.05,
max: 3.0,
label: '${(provider.targetRadius * 100).toStringAsFixed(0)}%',
label:
'${(provider.targetRadius * 100).toStringAsFixed(0)}%',
activeColor: AppTheme.warningColor,
onChanged: (value) {
provider.adjustTargetPosition(
@@ -302,14 +355,20 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
decoration: BoxDecoration(
color: AppTheme.warningColor,
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${(provider.targetRadius * 100).toStringAsFixed(0)}%',
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
@@ -318,10 +377,17 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
// Distortion correction row
Row(
children: [
const Icon(Icons.lens_blur, color: Colors.white, size: 20),
const Icon(
Icons.lens_blur,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
const Expanded(
child: Text('Correction distorsion:', style: TextStyle(color: Colors.white)),
child: Text(
'Correction distorsion:',
style: TextStyle(color: Colors.white),
),
),
if (provider.distortionParams == null)
ElevatedButton.icon(
@@ -333,7 +399,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
),
)
else ...[
@@ -347,21 +416,36 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
),
)
else
Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.check_circle, color: Colors.green, size: 16),
const Icon(
Icons.check_circle,
color: Colors.green,
size: 16,
),
const SizedBox(width: 4),
const Text('Corrigée', style: TextStyle(color: Colors.green, fontSize: 12)),
const Text(
'Corrigée',
style: TextStyle(
color: Colors.green,
fontSize: 12,
),
),
const SizedBox(width: 8),
Switch(
value: provider.distortionCorrectionEnabled,
onChanged: (value) => provider.setDistortionCorrectionEnabled(value),
activeTrackColor: AppTheme.primaryColor.withValues(alpha: 0.5),
onChanged: (value) => provider
.setDistortionCorrectionEnabled(value),
activeTrackColor: AppTheme.primaryColor
.withValues(alpha: 0.5),
activeThumbColor: AppTheme.primaryColor,
),
],
@@ -391,8 +475,21 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
initialRingCount: provider.ringCount,
initialRingRadii: provider.ringRadii,
targetType: provider.targetType!,
onCalibrationChanged: (centerX, centerY, radius, ringCount, {List<double>? ringRadii}) {
provider.adjustTargetPosition(centerX, centerY, radius, ringCount: ringCount, ringRadii: ringRadii);
onCalibrationChanged:
(
centerX,
centerY,
radius,
ringCount, {
List<double>? ringRadii,
}) {
provider.adjustTargetPosition(
centerX,
centerY,
radius,
ringCount: ringCount,
ringRadii: ringRadii,
);
},
),
],
@@ -410,10 +507,18 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
Card(
color: AppTheme.primaryColor.withValues(alpha: 0.1),
child: ListTile(
leading: const Icon(Icons.tune, color: AppTheme.primaryColor),
leading: const Icon(
Icons.tune,
color: AppTheme.primaryColor,
),
title: const Text('Calibrer la cible'),
subtitle: const Text('Ajustez le centre et la taille'),
trailing: const Icon(Icons.arrow_forward_ios, size: 16),
subtitle: const Text(
'Ajustez le centre et la taille',
),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 16,
),
onTap: () => setState(() => _isCalibrating = true),
),
),
@@ -429,7 +534,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const SizedBox(height: 12),
// Grouping stats
if (provider.groupingResult != null && provider.shotCount > 1)
if (provider.groupingResult != null &&
provider.shotCount > 1)
GroupingStats(
groupingResult: provider.groupingResult!,
targetCenterX: provider.targetCenterX,
@@ -446,7 +552,6 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
],
),
)
else
// Calibration info
Padding(
@@ -459,7 +564,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
children: [
const Text(
'Instructions de calibration',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
const SizedBox(height: 12),
_buildInstructionItem(
@@ -480,7 +588,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const Text('Centre: '),
Text(
'(${(provider.targetCenterX * 100).toStringAsFixed(1)}%, ${(provider.targetCenterY * 100).toStringAsFixed(1)}%)',
style: const TextStyle(fontWeight: FontWeight.bold),
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
@@ -489,7 +599,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const Text('Rayon: '),
Text(
'${(provider.targetRadius * 100).toStringAsFixed(1)}%',
style: const TextStyle(fontWeight: FontWeight.bold),
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
@@ -506,9 +618,13 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
left: 0,
right: 0,
child: Align(
alignment: _isAtBottom ? Alignment.bottomCenter : Alignment.bottomRight,
alignment: _isAtBottom
? Alignment.bottomCenter
: Alignment.bottomRight,
child: Padding(
padding: _isAtBottom ? EdgeInsets.zero : const EdgeInsets.all(16.0),
padding: _isAtBottom
? EdgeInsets.zero
: const EdgeInsets.all(16.0),
child: _isCalibrating
? FloatingActionButton.extended(
onPressed: () => setState(() => _isCalibrating = false),
@@ -519,11 +635,15 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
: AnimatedContainer(
duration: const Duration(milliseconds: 260),
curve: Curves.easeInOut,
width: _isAtBottom ? MediaQuery.of(context).size.width : 180,
width: _isAtBottom
? MediaQuery.of(context).size.width
: 180,
height: 56,
decoration: BoxDecoration(
color: AppTheme.primaryColor,
borderRadius: BorderRadius.circular(_isAtBottom ? 0 : 16),
borderRadius: BorderRadius.circular(
_isAtBottom ? 0 : 16,
),
boxShadow: [
if (!_isAtBottom)
BoxShadow(
@@ -537,9 +657,14 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
color: Colors.transparent,
child: InkWell(
onTap: () => _saveSession(context, provider),
borderRadius: BorderRadius.circular(_isAtBottom ? 0 : 16),
borderRadius: BorderRadius.circular(
_isAtBottom ? 0 : 16,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
@@ -549,11 +674,13 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const Icon(Icons.save, color: Colors.white),
const SizedBox(width: 8),
Text(
_isAtBottom ? 'SAUVEGARDER LA SESSION' : 'Sauvegarder',
_isAtBottom
? 'SAUVEGARDER LA SESSION'
: 'Sauvegarder',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16
fontSize: 16,
),
),
],
@@ -570,7 +697,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
Widget _buildZoomableImageWithOverlay(BuildContext context, AnalysisProvider provider) {
Widget _buildZoomableImageWithOverlay(
BuildContext context,
AnalysisProvider provider,
) {
return ClipRect(
child: Stack(
fit: StackFit.expand,
@@ -616,7 +746,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
groupingCenterX: provider.groupingResult?.centerX,
groupingCenterY: provider.groupingResult?.centerY,
groupingDiameter: provider.groupingResult?.diameter,
referenceImpacts: _isSelectingReferences ? provider.referenceImpacts : null,
referenceImpacts: _isSelectingReferences
? provider.referenceImpacts
: null,
),
],
),
@@ -649,7 +781,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
Widget _buildFullscreenEditContent(BuildContext context, AnalysisProvider provider) {
Widget _buildFullscreenEditContent(
BuildContext context,
AnalysisProvider provider,
) {
return Stack(
fit: StackFit.expand,
children: [
@@ -684,7 +819,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
ringCount: provider.ringCount,
ringRadii: provider.ringRadii,
zoomScale: _currentZoomScale,
onShotTapped: (shot) => _showShotOptions(context, provider, shot.id),
onShotTapped: (shot) =>
_showShotOptions(context, provider, shot.id),
onAddShot: (x, y) {
provider.addShot(x, y);
},
@@ -714,12 +850,17 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const Expanded(
child: Text(
'Mode édition - Touchez pour ajouter des impacts',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
Text(
'${provider.shotCount} impacts',
style: TextStyle(color: Colors.white.withValues(alpha: 0.8)),
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
),
),
],
),
@@ -825,7 +966,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
Expanded(
child: ElevatedButton.icon(
onPressed: provider.referenceImpacts.length >= 2
? () => _showCalibratedDetectionDialog(context, provider)
? () => _showCalibratedDetectionDialog(
context,
provider,
)
: null,
icon: const Icon(Icons.auto_fix_high),
label: const Text('Detecter'),
@@ -876,8 +1020,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
// ),
const SizedBox(height: 12),
],
// Manual actions
// Manual actions
],
);
}
@@ -891,7 +1035,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('1. Calibrez d\'abord la cible en utilisant le bouton de calibration'),
Text(
'1. Calibrez d\'abord la cible en utilisant le bouton de calibration',
),
SizedBox(height: 8),
Text('2. Appuyez sur l\'image pour ajouter un impact manuellement'),
SizedBox(height: 8),
@@ -910,7 +1056,11 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
void _showShotOptions(BuildContext context, AnalysisProvider provider, String shotId) {
void _showShotOptions(
BuildContext context,
AnalysisProvider provider,
String shotId,
) {
showModalBottomSheet(
context: context,
builder: (context) => SafeArea(
@@ -957,7 +1107,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
}
Navigator.pop(context);
},
child: const Text('Effacer', style: TextStyle(color: AppTheme.errorColor)),
child: const Text(
'Effacer',
style: TextStyle(color: AppTheme.errorColor),
),
),
],
),
@@ -1017,7 +1170,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const SizedBox(height: 12),
// Circularity slider
Text('Circularite minimum: ${(minCircularity * 100).toStringAsFixed(0)}%'),
Text(
'Circularite minimum: ${(minCircularity * 100).toStringAsFixed(0)}%',
),
Slider(
value: minCircularity,
min: 0.3,
@@ -1035,7 +1190,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
const SizedBox(height: 12),
// Fill ratio slider
Text('Remplissage minimum: ${(minFillRatio * 100).toStringAsFixed(0)}%'),
Text(
'Remplissage minimum: ${(minFillRatio * 100).toStringAsFixed(0)}%',
),
Slider(
value: minFillRatio,
min: 0.3,
@@ -1110,7 +1267,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
),
SizedBox(width: 12),
Text('Detection en cours...'),
@@ -1140,7 +1300,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
? '$count impact(s) detecte(s)'
: 'Aucun impact detecte. Essayez d\'ajuster les parametres.',
),
backgroundColor: count > 0 ? AppTheme.successColor : AppTheme.warningColor,
backgroundColor: count > 0
? AppTheme.successColor
: AppTheme.warningColor,
),
);
}
@@ -1154,7 +1316,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
void _showCalibratedDetectionDialog(BuildContext context, AnalysisProvider provider) {
void _showCalibratedDetectionDialog(
BuildContext context,
AnalysisProvider provider,
) {
double tolerance = 2.0;
bool clearExisting = true;
// NOTE: OpenCV désactivé - problèmes de build Windows
@@ -1182,7 +1347,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
padding: const EdgeInsets.all(12),
child: Row(
children: [
const Icon(Icons.info_outline, color: Colors.deepPurple),
const Icon(
Icons.info_outline,
color: Colors.deepPurple,
),
const SizedBox(width: 8),
Expanded(
child: Text(
@@ -1254,7 +1422,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
),
SizedBox(width: 12),
Text('Apprentissage des references...'),
@@ -1272,7 +1443,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Impossible d\'analyser les references. Essayez de selectionner d\'autres impacts.'),
content: Text(
'Impossible d\'analyser les references. Essayez de selectionner d\'autres impacts.',
),
backgroundColor: AppTheme.errorColor,
),
);
@@ -1290,7 +1463,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
),
SizedBox(width: 12),
Text('Detection en cours...'),
@@ -1323,7 +1499,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
? '$count impact(s) detecte(s) a partir des references'
: 'Aucun impact detecte. Essayez d\'augmenter la tolerance.',
),
backgroundColor: count > 0 ? AppTheme.successColor : AppTheme.warningColor,
backgroundColor: count > 0
? AppTheme.successColor
: AppTheme.warningColor,
),
);
}
@@ -1346,7 +1524,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
Future<void> _saveSession(BuildContext context, AnalysisProvider provider) async {
Future<void> _saveSession(
BuildContext context,
AnalysisProvider provider,
) async {
final notesController = TextEditingController();
final shouldSave = await showDialog<bool>(
@@ -1376,7 +1557,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
if (shouldSave == true) {
try {
await provider.saveSession(notes: notesController.text.isEmpty ? null : notesController.text);
await provider.saveSession(
notes: notesController.text.isEmpty ? null : notesController.text,
);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(