fix(ui): popup de confirmation d'ajout d'exercice (ticket #24)
Corrige le popup de confirmation quand un exercice est ajouté sur program_screen.dart. flutter analyze propre, 43/43 tests verts, build APK debug validé. Ticket laissé en QA : validation manuelle sur APK par l'utilisateur avant clôture. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../application/application.dart';
|
||||
@ -121,6 +123,7 @@ final class _ProgramFormScreenState extends State<ProgramFormScreen> {
|
||||
late final TextEditingController _nameController;
|
||||
late final TextEditingController _defaultRestController;
|
||||
late final List<_ProgramExerciseDraft> _exercises;
|
||||
Timer? _addedSnackBarTimer;
|
||||
var _saving = false;
|
||||
|
||||
bool get _isEditing => widget.program != null;
|
||||
@ -145,6 +148,7 @@ final class _ProgramFormScreenState extends State<ProgramFormScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_addedSnackBarTimer?.cancel();
|
||||
_nameController.dispose();
|
||||
_defaultRestController.dispose();
|
||||
super.dispose();
|
||||
@ -253,12 +257,25 @@ final class _ProgramFormScreenState extends State<ProgramFormScreen> {
|
||||
setState(() {
|
||||
_exercises.add(draft);
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
_addedSnackBarTimer?.cancel();
|
||||
_addedSnackBarTimer = Timer(const Duration(seconds: 3), () {
|
||||
if (mounted) {
|
||||
messenger.hideCurrentSnackBar();
|
||||
}
|
||||
});
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
duration: const Duration(seconds: 3),
|
||||
content: const Text('Exercice ajouté'),
|
||||
action: SnackBarAction(
|
||||
label: 'Personnaliser',
|
||||
onPressed: () => _customizeExercise(draft.key),
|
||||
onPressed: () {
|
||||
_addedSnackBarTimer?.cancel();
|
||||
_addedSnackBarTimer = null;
|
||||
messenger.hideCurrentSnackBar();
|
||||
_customizeExercise(draft.key);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user