diff --git a/lib/pages/interval_page.dart b/lib/pages/interval_page.dart index 1c0d64f..f029f88 100644 --- a/lib/pages/interval_page.dart +++ b/lib/pages/interval_page.dart @@ -2,31 +2,20 @@ import 'package:flutter/material.dart'; import 'package:provider/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/services/pages_service.dart'; import 'package:smoke_cess_app/widgets/mute_button.dart'; +import 'package:smoke_cess_app/widgets/workout_form.dart'; import 'package:smoke_cess_app/widgets/workout_timer_widget.dart'; +import 'package:smoke_cess_app/widgets/workout_view.dart'; + +import '../widgets/view_form_page.dart'; class IntervalTimerPage extends StatelessWidget { const IntervalTimerPage({super.key}); @override Widget build(BuildContext context) { - TimerProvider timerProvider = TimerProvider(); - return MultiProvider( - providers: [ - ChangeNotifierProvider(create: (context) => timerProvider), - ChangeNotifierProvider( - create: (context) => WorkoutProvider(timerProvider)), - ], - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Align( - alignment: Alignment.topLeft, - child: MuteButton(), - ), - WorkoutTimerWidget() - ], - ), - ); + return const ViewFormPage( + form: WorkoutForm(), view: WorkoutView(), page: Pages.timer); } } diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 1caf126..10ff0ec 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -20,7 +20,7 @@ class MyHomePageState extends State { bool _isConfigured = false; void _onItemTapped(int index) { - PageProvider pageProvider = context.watch(); + PageProvider pageProvider = context.read(); setState(() { if (_isConfigured) { pageProvider.showForm = false; diff --git a/lib/widgets/workout_form.dart b/lib/widgets/workout_form.dart new file mode 100644 index 0000000..980c51a --- /dev/null +++ b/lib/widgets/workout_form.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../providers/timer_provider.dart'; +import '../providers/workout_provider.dart'; +import 'mute_button.dart'; +import 'workout_timer_widget.dart'; + +class WorkoutForm extends StatelessWidget { + const WorkoutForm({super.key}); + + @override + Widget build(BuildContext context) { + TimerProvider timerProvider = TimerProvider(); + return MultiProvider( + providers: [ + ChangeNotifierProvider(create: (context) => timerProvider), + ChangeNotifierProvider( + create: (context) => WorkoutProvider(timerProvider)), + ], + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Align( + alignment: Alignment.topLeft, + child: MuteButton(), + ), + WorkoutTimerWidget() + ], + ), + ); + } +} diff --git a/lib/widgets/workout_view.dart b/lib/widgets/workout_view.dart index 7f4f843..fcf88c7 100644 --- a/lib/widgets/workout_view.dart +++ b/lib/widgets/workout_view.dart @@ -27,10 +27,6 @@ class WorkoutView extends StatelessWidget { yValueMapper: (Workout value, _) => value.motivationAfter) ], ), - Column( - children: tasksModel.sleepHistory.map((sleep) { - return Text('${sleep.date}: ${sleep.sleepQualitiyValue}'); - }).toList()) ], ); }