diff --git a/lib/pages/interval_page.dart b/lib/pages/interval_page.dart index 5a78b48..bf26c40 100644 --- a/lib/pages/interval_page.dart +++ b/lib/pages/interval_page.dart @@ -1,7 +1,6 @@ -import 'dart:async'; -import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/providers/timer_provider.dart'; import 'package:smoke_cess_app/providers/workout_provider.dart'; import 'package:smoke_cess_app/widgets/mute_button.dart'; @@ -17,7 +16,7 @@ class IntervalTimerPage extends StatelessWidget { providers: [ ChangeNotifierProvider(create: (context) => timerProvider), ChangeNotifierProvider( - create: (context) => WorkoutProvider(timerProvider)) + create: (context) => WorkoutProvider(timerProvider)), ], child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/widgets/popup_for_start_and_stop.dart b/lib/widgets/popup_for_start_and_stop.dart index e1af268..d79a83f 100644 --- a/lib/widgets/popup_for_start_and_stop.dart +++ b/lib/widgets/popup_for_start_and_stop.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/widgets/slider.dart'; import 'package:smoke_cess_app/widgets/text_formfield.dart'; @@ -9,18 +11,24 @@ class TimerStartStopPopup extends StatelessWidget { @override Widget build(BuildContext context) { + InputProvider inputProvider = context.watch(); + return AlertDialog( title: Text(title), content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - Padding( - padding: const EdgeInsets.only(top: 8), + children: [ + const Padding( + padding: EdgeInsets.only(top: 8), child: MySlider(), ), - SizedBox(height: 16), - MyTextFormField('Beschreibe deinen Motivation'), + const SizedBox(height: 16), + const MyTextFormField('Beschreibe deinen Motivation'), + ElevatedButton( + onPressed: () => + Navigator.pop(context, inputProvider.sliderValue), + child: const Text('Speichern')) ], ), ); diff --git a/lib/widgets/workout_timer_widget.dart b/lib/widgets/workout_timer_widget.dart index df9fae4..5a14911 100644 --- a/lib/widgets/workout_timer_widget.dart +++ b/lib/widgets/workout_timer_widget.dart @@ -5,11 +5,15 @@ import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/workout_provider.dart'; import 'package:smoke_cess_app/widgets/timer_widget.dart'; +import '../providers/input_provider.dart'; import '../providers/timer_provider.dart'; +import 'popup_for_start_and_stop.dart'; class WorkoutTimerWidget extends StatelessWidget { const WorkoutTimerWidget({super.key}); + void _onStartButtonPressed(BuildContext context) {} + @override Widget build(BuildContext context) { TimerProvider timerProvider = context.watch(); @@ -46,7 +50,21 @@ class WorkoutTimerWidget extends StatelessWidget { ), ElevatedButton( onPressed: !workoutProvider.isWorkoutStarted - ? () => workoutProvider.startWorkout() + ? () async { + double sliderValue = await showDialog( + context: context, + builder: (BuildContext context) { + return ChangeNotifierProvider( + create: (context) => InputProvider(), + child: const TimerStartStopPopup( + title: 'Motivation vor dem Training', + ), + ); + }, + ); + print(sliderValue); + workoutProvider.startWorkout(); + } : () => workoutProvider.stopWorkout(), child: Text(timerProvider.started ? 'Stop' : 'Start')) ],