diff --git a/lib/providers/workout_provider.dart b/lib/providers/workout_provider.dart index add88de..5c0a80b 100644 --- a/lib/providers/workout_provider.dart +++ b/lib/providers/workout_provider.dart @@ -35,13 +35,13 @@ class WorkoutProvider extends ChangeNotifier { final List _workoutPhases = [ 'Warm-Up', - /*'High Intensity', - 'Low Intensity', 'High Intensity', 'Low Intensity', 'High Intensity', 'Low Intensity', - 'High Intensity', */ + 'High Intensity', + 'Low Intensity', + 'High Intensity', 'Cool-down' ]; int _workoutPhaseIndex = 0; @@ -89,7 +89,7 @@ class WorkoutProvider extends ChangeNotifier { isWorkoutComplete = true; _audioPlayer.stop(); timerProvider.stopTimer(); - //notifyListeners(); + notifyListeners(); } void saveWorkout() { diff --git a/lib/widgets/popup_for_start_and_stop.dart b/lib/widgets/popup_for_start_and_stop.dart index 4883737..77411a4 100644 --- a/lib/widgets/popup_for_start_and_stop.dart +++ b/lib/widgets/popup_for_start_and_stop.dart @@ -4,8 +4,8 @@ import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/widgets/slider.dart'; Future showMotivationPopup( - BuildContext context, Function onSave, String title) async { - return await showDialog( + BuildContext context, Function onSave, String title) { + return showDialog( context: context, builder: (BuildContext context) { return ChangeNotifierProvider( diff --git a/lib/widgets/workout_timer_widget.dart b/lib/widgets/workout_timer_widget.dart index 8023770..59f67d4 100644 --- a/lib/widgets/workout_timer_widget.dart +++ b/lib/widgets/workout_timer_widget.dart @@ -20,16 +20,24 @@ class WorkoutTimerWidget extends StatelessWidget { Timer(const Duration(milliseconds: 1), () => workoutProvider.nextPhase()); } - void handleStartStopWorkout() async { + if (workoutProvider.isWorkoutComplete) { + Timer( + const Duration(milliseconds: 1), + () => showMotivationPopup(context, (double value) { + workoutProvider.motivationAfter = value.toInt(); + workoutProvider.saveWorkout(); + }, 'Motivation nach dem Training')); + } + + void handleStartStopWorkout() { if (!workoutProvider.isWorkoutStarted) { - await showMotivationPopup( - context, - (double value) => workoutProvider.motivationBefore = value.toInt(), - 'Motivation vor dem Training'); - workoutProvider.startWorkout(); + showMotivationPopup(context, (double value) { + workoutProvider.motivationBefore = value.toInt(); + workoutProvider.startWorkout(); + }, 'Motivation vor dem Training'); } else { workoutProvider.stopWorkout(); - await showMotivationPopup( + showMotivationPopup( context, (double value) => workoutProvider.motivationAfter = value.toInt(), 'Motivation nach dem Training');