feat(session): ajout du sélecteur de date et persistance dans l'historique de tir
This commit is contained in:
@@ -174,7 +174,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
x: impact.x,
|
||||
y: impact.y,
|
||||
score: impact.suggestedScore,
|
||||
analysisId: '', // Will be set when saving
|
||||
analysisId: '',
|
||||
);
|
||||
}).toList();
|
||||
|
||||
@@ -537,8 +537,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
_imagePath = correctedPath;
|
||||
_correctedImagePath = correctedPath;
|
||||
_distortionCorrectionEnabled = true;
|
||||
_imageAspectRatio =
|
||||
1.0; // The corrected image is always square (side x side)
|
||||
_imageAspectRatio = 1.0;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -616,18 +615,18 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
// 3. Application immédiate de la transformation (méthode asynchrone)
|
||||
await applyDistortionCorrection();
|
||||
} else {
|
||||
notifyListeners(); // On prévient quand même si pas de correction
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> runFullDistortionWorkflow() async {
|
||||
_state = AnalysisState.loading; // Affiche un spinner sur votre UI
|
||||
_state = AnalysisState.loading;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
calculateDistortion(); // Calcule les paramètres
|
||||
await applyDistortionCorrection(); // Génère le fichier corrigé
|
||||
_distortionCorrectionEnabled = true; // Active l'affichage
|
||||
calculateDistortion();
|
||||
await applyDistortionCorrection();
|
||||
_distortionCorrectionEnabled = true;
|
||||
_state = AnalysisState.success;
|
||||
} catch (e) {
|
||||
_errorMessage = "Erreur de rendu : $e";
|
||||
@@ -688,12 +687,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Identifiant d'analyse temporaire
|
||||
final analysisId = _shots.isNotEmpty && _shots.first.analysisId.isNotEmpty
|
||||
? _shots.first.analysisId
|
||||
: 'analysis_${DateTime.now().millisecondsSinceEpoch}';
|
||||
|
||||
final service = AiExportService(); // Local instanciation for simplicity
|
||||
final service = AiExportService();
|
||||
|
||||
_state = AnalysisState.loading;
|
||||
notifyListeners();
|
||||
@@ -716,13 +710,14 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
return success;
|
||||
}
|
||||
|
||||
/// Save the session (legacy standalone flow)
|
||||
/// Save the session (Refactorisé pour appliquer le paramètre de date personnalisé)
|
||||
Future<TargetAnalysis> saveSession({
|
||||
String? notes,
|
||||
String? sessionId,
|
||||
String? weaponName,
|
||||
String? weaponId,
|
||||
int? distance,
|
||||
DateTime? date, // <-- REÇOIT PROPREMENT LA DATE DE DEBUT DE SESSION
|
||||
}) async {
|
||||
if (_imagePath == null || _targetType == null) {
|
||||
throw Exception('Cannot save: missing image or target type');
|
||||
@@ -748,6 +743,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
if (existingSession != null) {
|
||||
await _sessionRepository.addAnalysisToSession(sessionId, targetAnalysis);
|
||||
} else {
|
||||
// CORRECTION : Utilise la date injectée plutôt que DateTime.now()
|
||||
await _sessionRepository.createSession(
|
||||
id: sessionId,
|
||||
weapon: weaponName ?? 'Inconnue',
|
||||
@@ -756,9 +752,11 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
analyses: [targetAnalysis],
|
||||
notes: notes,
|
||||
distance: distance ?? 25,
|
||||
date: date ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// CORRECTION : S'applique aussi au flux alternatif sans ID préalable
|
||||
await _sessionRepository.createSession(
|
||||
weapon: weaponName ?? 'Inconnue',
|
||||
weaponId: weaponId,
|
||||
@@ -766,6 +764,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
analyses: [targetAnalysis],
|
||||
notes: notes,
|
||||
distance: distance ?? 25,
|
||||
date: date ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -568,7 +568,6 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showSaveSessionDialog(BuildContext context, AnalysisProvider provider) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -614,6 +613,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
weaponName: sessionProvider.currentWeapon,
|
||||
weaponId: sessionProvider.currentWeaponId,
|
||||
distance: sessionProvider.distance,
|
||||
date: sessionProvider.sessionDate,
|
||||
);
|
||||
|
||||
sessionProvider.addAnalysis(analysis);
|
||||
@@ -645,6 +645,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
weaponName: sessionProvider.currentWeapon,
|
||||
weaponId: sessionProvider.currentWeaponId,
|
||||
distance: sessionProvider.distance,
|
||||
date: sessionProvider.sessionDate, // <-- CORRECTION : Prise en compte de la date ici aussi !
|
||||
);
|
||||
|
||||
if (context.mounted) {
|
||||
@@ -666,4 +667,4 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user