feat: score de session en plotting + guidage pour placer le premier impact

This commit is contained in:
qlionbleusam
2026-08-04 16:25:44 +02:00
parent 058bd5ff71
commit 3a9e393a20
2 changed files with 127 additions and 22 deletions
+81 -20
View File
@@ -297,6 +297,74 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
);
}
/// Indication affichée sous le titre en mode Plotting.
///
/// Rien n'indiquait comment ajouter un impact une fois la calibration
/// validée : ce rappel pointe vers le geste (toucher la cible).
Widget _buildPlottingHint(AnalysisProvider provider) {
final hasShots = provider.shotCount > 0;
return Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
hasShots ? Icons.touch_app : Icons.add_location_alt,
size: 16,
color: AppTheme.primaryColor,
),
const SizedBox(width: 6),
Flexible(
child: Text(
hasShots
? 'Touchez la cible pour modifier vos impacts'
: 'Touchez la cible pour placer vos impacts',
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
),
),
],
),
);
}
/// Bouton flottant du bas de l'écran.
///
/// En calibration : VALIDER. En plotting : tant qu'aucun impact n'est placé,
/// on ne propose pas de terminer la session mais de placer un impact (le
/// bouton ouvre l'éditeur, comme un tap sur la cible).
Widget _buildBottomAction(BuildContext context, AnalysisProvider provider) {
if (_isCalibrating) {
return FloatingActionButton.extended(
// Même bouton bleu flottant que « TERMINER LA SESSION » :
// on fige la calibration puis on bascule sur le Plotting.
onPressed: () {
_calibrationKey.currentState?.commitCalibration();
setState(() => _isCalibrating = false);
},
backgroundColor: AppTheme.primaryColor,
icon: const Icon(Icons.check),
label: const Text('VALIDER'),
);
}
if (provider.shotCount == 0) {
return FloatingActionButton.extended(
onPressed: () => _openImpactEditor(provider),
backgroundColor: AppTheme.primaryColor,
icon: const Icon(Icons.add_location_alt),
label: const Text('PLACER UN IMPACT'),
);
}
return FloatingActionButton.extended(
onPressed: () => _showSaveSessionDialog(context, provider),
backgroundColor: AppTheme.primaryColor,
icon: const Icon(Icons.save),
label: const Text('TERMINER LA SESSION'),
);
}
@override
Widget build(BuildContext context) {
final provider = context.watch<AnalysisProvider>();
@@ -355,7 +423,10 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
// Réglages de calibration : au-dessus de la photo pour ne rien
// masquer de la cible.
if (_isCalibrating) _buildCalibrationSettings(provider),
if (_isCalibrating)
_buildCalibrationSettings(provider)
else
_buildPlottingHint(provider),
AspectRatio(
aspectRatio: provider.imageAspectRatio,
@@ -450,6 +521,14 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
shotCount: provider.shotCount,
scoreResult: provider.scoreResult,
targetType: provider.targetType!,
// Cumul de la session : cibles déjà validées + cible
// en cours (absent hors session).
sessionTotalScore: sessionProvider.isSessionActive
? sessionProvider.totalSessionScore +
provider.totalScore
: null,
sessionTargetCount:
sessionProvider.targetCount + 1,
),
const SizedBox(height: 12),
if (provider.groupingResult != null &&
@@ -562,25 +641,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
padding: _isAtBottom
? EdgeInsets.zero
: const EdgeInsets.all(16.0),
child: _isCalibrating
? FloatingActionButton.extended(
// Même bouton bleu flottant que « TERMINER LA SESSION » :
// on fige la calibration puis on bascule sur le Plotting.
onPressed: () {
_calibrationKey.currentState?.commitCalibration();
setState(() => _isCalibrating = false);
},
backgroundColor: AppTheme.primaryColor,
icon: const Icon(Icons.check),
label: const Text('VALIDER'),
)
: FloatingActionButton.extended(
onPressed: () =>
_showSaveSessionDialog(context, provider),
backgroundColor: AppTheme.primaryColor,
icon: const Icon(Icons.save),
label: const Text('TERMINER LA SESSION'),
),
child: _buildBottomAction(context, provider),
),
),
),