save workout when completed

main
Julian Gegner 2023-03-02 16:06:24 +01:00
parent fa8d2f6314
commit d1600b174e
3 changed files with 21 additions and 13 deletions

View File

@ -35,13 +35,13 @@ class WorkoutProvider extends ChangeNotifier {
final List<String> _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() {

View File

@ -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(

View File

@ -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');