3 Commits

Author SHA1 Message Date
9ccb149dda désactivation de l'auto analyse au chargement de l'écran d'analyse 2026-01-31 20:55:28 +01:00
972474750f - bouton effacer
- bouton ajouter
+ bouton effacer sur l'image de cible
2026-01-30 20:58:57 +01:00
2f69ff4ecf +changelog
+readme
2026-01-30 20:28:02 +01:00
5 changed files with 700 additions and 461 deletions

25
CHANGELOG.md Normal file
View File

@@ -0,0 +1,25 @@
# Changelog
## [v0.0.1] - 2026-01-29
### Ajouté
- **Interface d'Analyse** :
- Implémentation d'un bouton de sauvegarde "Morphing" : le bouton flottant se transforme en un bouton large en bas de page lors du défilement.
- Ajout de la gestion du défilement et de l'espacement pour une meilleure ergonomie.
- Visualisation des impacts et statistiques de groupement.
- **Support Desktop (Windows)** :
- Configuration de la base de données SQLite pour fonctionner sur Windows via `sqflite_common_ffi`.
- Initialisation conditionnelle selon la plateforme.
### Corrigé
- **Crash Windows** : Résolution du plantage dû à l'initialisation manquante de la factory de base de données FFI.
- **Dépendances** : Fixation de la version de `sqflite_common_ffi` à `2.3.3` pour contourner un problème de cache/corruption avec la version `2.4.0+2`.
- **UI/UX** :
- Correction des débordements de texte ("zebra stripes") dans le bouton de sauvegarde lors de l'animation grâce à `FittedBox`.
- Optimisation de l'affichage du titre "Groupement" dans les statistiques pour éviter les dépassements sur petits écrans.
- Nettoyage des appels redondants (`super.initState`) et correction de la structure des widgets (`Stack` mal fermé).
### Historique des Commits
- `db7160b` - +désactivation (2026-01-29)
- `f1a8eef` - ajout correctif (2026-01-28)
- `031d4a4` - premier app version beta (2026-01-18)

View File

@@ -1,17 +1,35 @@
# bully
# Bully - Analyseur de Cible
A new Flutter project.
Application Flutter multiplateforme pour l'analyse et le suivi de vos séances de tir.
## Getting Started
## Fonctionnalités Principales
This project is a starting point for a Flutter application.
* **Capture et Analyse** : Prenez une photo de votre cible et analysez vos impacts.
* **Détection Automatique** : Utilise des algorithmes pour détecter automatiquement les impacts de balle sur la cible.
* **Calibration** : Outils de calibration précis pour définir la taille et le centre de la cible, assurant des mesures exactes.
* **Statistiques Détaillées** :
* Calcul du score total.
* Analyse du groupement (H+L, diamètre moyen).
* Visualisation graphique de la dispersion.
* **Historique** : Sauvegardez vos sessions avec des notes et consultez votre progression au fil du temps.
* **Interface Intuitive** : Design moderne et fluide, avec un bouton de sauvegarde dynamique qui s'adapte à votre navigation.
A few resources to get you started if this is your first Flutter project:
## Détails Techniques
- [Learn Flutter](https://docs.flutter.dev/get-started/learn-flutter)
- [Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Flutter learning resources](https://docs.flutter.dev/reference/learning-resources)
* **Framework** : Flutter (Compatible Android, iOS, Windows, Linux, macOS).
* **Base de Données** : SQLite (via `sqflite` et `sqflite_common_ffi` pour le support Desktop).
* **Graphiques** : `fl_chart` pour la visualisation des données.
* **Architecture** : Provider pour la gestion d'état.
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Installation
1. Assurez-vous d'avoir Flutter installé.
2. Clonez le dépôt.
3. Installez les dépendances :
```bash
flutter pub get
```
4. Lancez l'application :
```bash
flutter run
```

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,8 +548,7 @@ class AnalysisProvider extends ChangeNotifier {
}
}
/* version deux a tester*/
/* version deux a tester*/
/// Calcule ET applique la correction pour un feedback immédiat
Future<void> calculateAndApplyDistortion() async {
// 1. Calcul des paramètres (votre code actuel)
@@ -566,7 +584,7 @@ class AnalysisProvider extends ChangeNotifier {
notifyListeners();
}
}
/* fin section deux a tester*/
/* fin section deux a tester*/
int _calculateShotScore(double x, double y) {
if (_targetType == TargetType.concentric) {

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,11 +746,25 @@ 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,
),
],
),
),
// Bouton pour effacer les impacts
if (provider.shotCount > 0 && !_isSelectingReferences)
Positioned(
left: 8,
bottom: 8,
child: FloatingActionButton.small(
heroTag: 'clearShots',
onPressed: () => _showClearConfirmation(context, provider),
backgroundColor: Colors.black54,
child: const Icon(Icons.delete, color: Colors.white),
),
),
// Bouton pour passer en mode plein écran d'édition
Positioned(
right: 8,
@@ -637,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: [
@@ -672,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);
},
@@ -702,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),
),
),
],
),
@@ -813,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'),
@@ -864,28 +1020,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
// ),
const SizedBox(height: 12),
],
// Manual actions
Row(
children: [
Expanded(
child: OutlinedButton.icon(
onPressed: _isSelectingReferences ? null : () => _showAddShotHint(context),
icon: const Icon(Icons.add_circle_outline),
label: const Text('Ajouter'),
),
),
const SizedBox(width: 12),
Expanded(
child: OutlinedButton.icon(
onPressed: provider.shotCount > 0 && !_isSelectingReferences
? () => _showClearConfirmation(context, provider)
: null,
icon: const Icon(Icons.clear_all),
label: const Text('Effacer'),
),
),
],
),
],
);
}
@@ -899,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),
@@ -918,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(
@@ -965,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),
),
),
],
),
@@ -1025,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,
@@ -1043,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,
@@ -1118,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...'),
@@ -1148,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,
),
);
}
@@ -1162,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
@@ -1190,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(
@@ -1262,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...'),
@@ -1280,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,
),
);
@@ -1298,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...'),
@@ -1331,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,
),
);
}
@@ -1354,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>(
@@ -1384,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(