From 3038efcd2743ee2db84318eb39719260b76f0d5d Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sat, 4 Mar 2023 15:30:21 +0100 Subject: [PATCH 01/20] changed circular progress indicator framerate --- lib/providers/timer_provider.dart | 18 +++++++++++------- lib/providers/workout_provider.dart | 3 +-- lib/widgets/workout_timer_widget.dart | 10 ++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/providers/timer_provider.dart b/lib/providers/timer_provider.dart index f355d7d..298316a 100644 --- a/lib/providers/timer_provider.dart +++ b/lib/providers/timer_provider.dart @@ -5,13 +5,18 @@ import 'package:flutter/material.dart'; class TimerProvider extends ChangeNotifier { Timer? _timer; bool started = false; - int get elapsedSeconds => _timer != null ? _timer!.tick : 0; + Duration _duration = const Duration(); + int get elapsedSeconds => _duration.inSeconds; + int get elapsedMilliseconds => _duration.inMilliseconds; + final Duration _tickRate = const Duration(milliseconds: 20); void startTimer(Duration duration) { + _duration = Duration.zero; started = true; - _timer = Timer.periodic(const Duration(seconds: 1), ((timer) { - if (timer.tick >= duration.inSeconds) { - timer.cancel(); + _timer = Timer.periodic(_tickRate, ((timer) { + _duration += _tickRate; + if (elapsedSeconds >= duration.inSeconds) { + _timer?.cancel(); started = false; } notifyListeners(); @@ -22,13 +27,12 @@ class TimerProvider extends ChangeNotifier { started = false; _timer?.cancel(); _timer = null; + _duration = Duration.zero; } @override void dispose() { - started = false; - _timer?.cancel(); - _timer = null; + stopTimer(); super.dispose(); } } diff --git a/lib/providers/workout_provider.dart b/lib/providers/workout_provider.dart index 0cf3804..15ff39a 100644 --- a/lib/providers/workout_provider.dart +++ b/lib/providers/workout_provider.dart @@ -54,10 +54,9 @@ class WorkoutProvider extends ChangeNotifier { Color get currentPhaseColor => _workoutPhaseSettings[currentPhase]!['color']; AssetSource get currentPhaseSource => _workoutPhaseSettings[currentPhase]!['source']; - /* bool get isWorkoutComplete => - _workoutPhaseIndex == _workoutPhases.length - 1 && isPhaseComplete; */ void nextPhase() { + print('called next phase'); _onCompleteSubscription.cancel(); _audioPlayer.stop(); if (_workoutPhaseIndex < _workoutPhases.length - 1) { diff --git a/lib/widgets/workout_timer_widget.dart b/lib/widgets/workout_timer_widget.dart index c47bbf5..e21719d 100644 --- a/lib/widgets/workout_timer_widget.dart +++ b/lib/widgets/workout_timer_widget.dart @@ -74,10 +74,12 @@ class WorkoutTimerWidget extends StatelessWidget { width: 100, child: CircularProgressIndicator( color: workoutProvider.currentPhaseColor, - value: (workoutProvider.currentPhaseDuration.inSeconds - .toDouble() - - timerProvider.elapsedSeconds) / - workoutProvider.currentPhaseDuration.inSeconds)), + value: + (workoutProvider.currentPhaseDuration.inMilliseconds - + timerProvider.elapsedMilliseconds) + .toDouble() / + workoutProvider.currentPhaseDuration.inMilliseconds + .toDouble())), TimerWidget(duration: workoutProvider.currentPhaseDuration), ], ), From 8143a910200a339df96abc31824289f5685df50a Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sat, 4 Mar 2023 17:58:04 +0100 Subject: [PATCH 02/20] back button to appbar, added round add button to add entries --- lib/pages/main_page.dart | 33 ++++++++++++++++++++-------- lib/widgets/round_button_widget.dart | 21 ++++++++++++++++++ lib/widgets/view_form_page.dart | 22 ++++++++----------- 3 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 lib/widgets/round_button_widget.dart diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 10ff0ec..026d707 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -38,22 +38,37 @@ class MyHomePageState extends State { @override Widget build(BuildContext context) { - var settingsModel = context.watch(); - var tasksModel = context.watch(); - _isConfigured = settingsModel.initialized; + var settingsProvider = context.watch(); + var tasksProvider = context.watch(); + PageProvider pageProvider = context.watch(); + + _isConfigured = settingsProvider.initialized; return Scaffold( appBar: AppBar( - title: Text( - '${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsModel.settings?.group}" : ""}')), - body: SingleChildScrollView( - child: pages.values.elementAt(_selectedIndex)['page'], - ), + title: Row( + children: [ + Stack( + children: [ + const SizedBox( + width: 70, + ), + if (pageProvider.showForm) + IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white), + onPressed: pageProvider.swap), + ], + ), + Text( + '${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}') + ], + )), + body: pages.values.elementAt(_selectedIndex)['page'], bottomNavigationBar: NavigationBar( onDestinationSelected: _onItemTapped, selectedIndex: _selectedIndex, destinations: pages.keys.map((key) { return NavigationDestination( - icon: tasksModel.tasks[key] ?? false + icon: tasksProvider.tasks[key] ?? false ? MyToDoIcon(pages[key]?['icon']) : pages[key]!['icon'], label: pages[key]?['title']); diff --git a/lib/widgets/round_button_widget.dart b/lib/widgets/round_button_widget.dart new file mode 100644 index 0000000..21482bf --- /dev/null +++ b/lib/widgets/round_button_widget.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class RoundAddButton extends StatelessWidget { + final VoidCallback onPressed; + + const RoundAddButton({super.key, required this.onPressed}); + + @override + Widget build(BuildContext context) { + return ElevatedButton( + onPressed: onPressed, + style: ElevatedButton.styleFrom( + shape: const CircleBorder(), + padding: const EdgeInsets.all(20), + backgroundColor: Colors.green, // <-- Button color + foregroundColor: Colors.blue, // <-- Splash color + ), + child: const Icon(Icons.add_outlined, color: Colors.white), + ); + } +} diff --git a/lib/widgets/view_form_page.dart b/lib/widgets/view_form_page.dart index 57b9271..2fa8af3 100644 --- a/lib/widgets/view_form_page.dart +++ b/lib/widgets/view_form_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; +import 'package:smoke_cess_app/widgets/round_button_widget.dart'; import '../providers/input_provider.dart'; import '../providers/page_provider.dart'; import '../providers/tasks_provider.dart'; @@ -17,25 +18,20 @@ class ViewFormPage extends StatelessWidget { Widget build(BuildContext context) { PageProvider pageProvider = context.watch(); TasksProvider tasksProvider = context.watch(); - return Wrap(children: [ - Align( - alignment: Alignment.topLeft, - child: IconButton( - icon: pageProvider.showForm - ? const Icon(Icons.arrow_back, color: Colors.black) - : const Icon(Icons.add_outlined, color: Colors.black), - onPressed: tasksProvider.tasks[page] ?? true - ? pageProvider.swap - : () => showTaskDonePopup(context, page), - ), - ), + return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ pageProvider.showForm ? Center( child: ChangeNotifierProvider( create: (context) => InputProvider(), child: form, )) - : Center(child: view) + : Center(child: view), + if (!pageProvider.showForm) + RoundAddButton( + onPressed: tasksProvider.tasks[page] == true + ? () => pageProvider.swap() + : () => showTaskDonePopup(context, page), + ) ]); } } From c79674eb46fd0960e7d21c8b2bb15a0a6319b83e Mon Sep 17 00:00:00 2001 From: "k.mannweiler" <2012491@stud.hs-mannheim.de> Date: Sat, 4 Mar 2023 18:24:02 +0100 Subject: [PATCH 03/20] deleted old code --- lib/providers/workout_provider.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/providers/workout_provider.dart b/lib/providers/workout_provider.dart index 067ebcb..5d85c18 100644 --- a/lib/providers/workout_provider.dart +++ b/lib/providers/workout_provider.dart @@ -39,8 +39,6 @@ class WorkoutProvider extends ChangeNotifier { _workoutPhaseSettings[currentPhase]!['source']; void nextPhase() { - _onCompleteSubscription.cancel(); - _audioPlayer.stop(); if (_workoutPhaseIndex < _workoutPhases.length - 1) { _workoutPhaseIndex += 1; audioProvider.playSourceAfterBeep(currentPhaseSource); From 40f03ec1776671d63bc5a5185ca2ea0f234e5592 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 17:33:27 +0100 Subject: [PATCH 04/20] wip layout add button --- lib/widgets/round_button_widget.dart | 6 +++++- lib/widgets/view_form_page.dart | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/widgets/round_button_widget.dart b/lib/widgets/round_button_widget.dart index 21482bf..bfe5cc3 100644 --- a/lib/widgets/round_button_widget.dart +++ b/lib/widgets/round_button_widget.dart @@ -15,7 +15,11 @@ class RoundAddButton extends StatelessWidget { backgroundColor: Colors.green, // <-- Button color foregroundColor: Colors.blue, // <-- Splash color ), - child: const Icon(Icons.add_outlined, color: Colors.white), + child: Icon( + Icons.add_outlined, + color: Colors.white, + size: MediaQuery.of(context).size.height * 0.5, + ), ); } } diff --git a/lib/widgets/view_form_page.dart b/lib/widgets/view_form_page.dart index 2fa8af3..6916097 100644 --- a/lib/widgets/view_form_page.dart +++ b/lib/widgets/view_form_page.dart @@ -16,6 +16,7 @@ class ViewFormPage extends StatelessWidget { @override Widget build(BuildContext context) { + final height = MediaQuery.of(context).size.height; PageProvider pageProvider = context.watch(); TasksProvider tasksProvider = context.watch(); return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -27,10 +28,15 @@ class ViewFormPage extends StatelessWidget { )) : Center(child: view), if (!pageProvider.showForm) - RoundAddButton( - onPressed: tasksProvider.tasks[page] == true - ? () => pageProvider.swap() - : () => showTaskDonePopup(context, page), + Container( + height: height / 8, + width: height / 8, + margin: EdgeInsets.only(bottom: height / 10), + child: RoundAddButton( + onPressed: tasksProvider.tasks[page] == true + ? () => pageProvider.swap() + : () => showTaskDonePopup(context, page), + ), ) ]); } From ca10d4566144abb52a8513dff541b66a73358ab5 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 17:43:40 +0100 Subject: [PATCH 05/20] use correct package --- lib/providers/tasks_provider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/providers/tasks_provider.dart b/lib/providers/tasks_provider.dart index d3fc042..2fed9b8 100644 --- a/lib/providers/tasks_provider.dart +++ b/lib/providers/tasks_provider.dart @@ -5,7 +5,7 @@ import 'package:smoke_cess_app/models/workout.dart'; import 'package:smoke_cess_app/providers/settings_provider.dart'; import 'package:smoke_cess_app/services/date_service.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:timezone/browser.dart'; +import 'package:timezone/timezone.dart'; import '../globals.dart' as globals; import '../models/mood.dart'; From aaab126ec8dbf65994329585232813346536a632 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 17:44:10 +0100 Subject: [PATCH 06/20] button size relative to screen size --- lib/widgets/view_form_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/view_form_page.dart b/lib/widgets/view_form_page.dart index 6916097..702374e 100644 --- a/lib/widgets/view_form_page.dart +++ b/lib/widgets/view_form_page.dart @@ -31,7 +31,7 @@ class ViewFormPage extends StatelessWidget { Container( height: height / 8, width: height / 8, - margin: EdgeInsets.only(bottom: height / 10), + margin: EdgeInsets.only(bottom: height * 0.08), child: RoundAddButton( onPressed: tasksProvider.tasks[page] == true ? () => pageProvider.swap() From 669e7032c162fa3060b6e5798dc8eb8f99fd0ea4 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 17:49:12 +0100 Subject: [PATCH 07/20] icon size relative to screensize --- lib/widgets/round_button_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/round_button_widget.dart b/lib/widgets/round_button_widget.dart index bfe5cc3..2af5df4 100644 --- a/lib/widgets/round_button_widget.dart +++ b/lib/widgets/round_button_widget.dart @@ -18,7 +18,7 @@ class RoundAddButton extends StatelessWidget { child: Icon( Icons.add_outlined, color: Colors.white, - size: MediaQuery.of(context).size.height * 0.5, + size: MediaQuery.of(context).size.height * 0.05, ), ); } From 00ae7ae860a63d6ce86c1da66936ed1081b277d3 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 18:17:08 +0100 Subject: [PATCH 08/20] structure widget folder --- lib/pages/interval_page.dart | 7 +++---- lib/pages/mood_page.dart | 6 +++--- lib/pages/relapse_page.dart | 6 +++--- lib/pages/sleep_page.dart | 6 +++--- lib/widgets/{ => buttons}/mute_button.dart | 3 +-- lib/widgets/{ => buttons}/round_button_widget.dart | 0 lib/widgets/{ => buttons}/submit_form_button.dart | 0 lib/widgets/{ => buttons}/timer_button.dart | 0 lib/widgets/{ => popup}/missing_config_popup.dart | 0 .../{ => popup}/popup_for_start_and_stop.dart | 0 lib/widgets/{ => popup}/popup_for_task_done.dart | 4 ++-- lib/widgets/{ => view_form}/mood_form.dart | 7 +++---- lib/widgets/{ => view_form}/mood_view.dart | 4 ++-- lib/widgets/{ => view_form}/relapse_form.dart | 10 +++++----- lib/widgets/{ => view_form}/relapse_view.dart | 2 +- lib/widgets/{ => view_form}/sleep_form.dart | 6 +++--- lib/widgets/{ => view_form}/sleep_view.dart | 2 +- lib/widgets/{ => view_form}/view_form_page.dart | 10 +++++----- lib/widgets/{ => view_form}/workout_form.dart | 8 ++++---- lib/widgets/{ => view_form}/workout_view.dart | 2 +- lib/widgets/workout_timer_widget.dart | 14 +++++++------- 21 files changed, 47 insertions(+), 50 deletions(-) rename lib/widgets/{ => buttons}/mute_button.dart (92%) rename lib/widgets/{ => buttons}/round_button_widget.dart (100%) rename lib/widgets/{ => buttons}/submit_form_button.dart (100%) rename lib/widgets/{ => buttons}/timer_button.dart (100%) rename lib/widgets/{ => popup}/missing_config_popup.dart (100%) rename lib/widgets/{ => popup}/popup_for_start_and_stop.dart (100%) rename lib/widgets/{ => popup}/popup_for_task_done.dart (91%) rename lib/widgets/{ => view_form}/mood_form.dart (85%) rename lib/widgets/{ => view_form}/mood_view.dart (89%) rename lib/widgets/{ => view_form}/relapse_form.dart (78%) rename lib/widgets/{ => view_form}/relapse_view.dart (88%) rename lib/widgets/{ => view_form}/sleep_form.dart (89%) rename lib/widgets/{ => view_form}/sleep_view.dart (94%) rename lib/widgets/{ => view_form}/view_form_page.dart (79%) rename lib/widgets/{ => view_form}/workout_form.dart (79%) rename lib/widgets/{ => view_form}/workout_view.dart (94%) diff --git a/lib/pages/interval_page.dart b/lib/pages/interval_page.dart index 2326168..484ae20 100644 --- a/lib/pages/interval_page.dart +++ b/lib/pages/interval_page.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:smoke_cess_app/widgets/workout_form.dart'; -import 'package:smoke_cess_app/widgets/workout_view.dart'; - -import '../widgets/view_form_page.dart'; +import 'package:smoke_cess_app/widgets/view_form/workout_form.dart'; +import 'package:smoke_cess_app/widgets/view_form/workout_view.dart'; +import 'package:smoke_cess_app/widgets/view_form/view_form_page.dart'; class IntervalTimerPage extends StatelessWidget { const IntervalTimerPage({super.key}); diff --git a/lib/pages/mood_page.dart b/lib/pages/mood_page.dart index 8c2447d..f5b8009 100644 --- a/lib/pages/mood_page.dart +++ b/lib/pages/mood_page.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:smoke_cess_app/widgets/mood_form.dart'; -import 'package:smoke_cess_app/widgets/mood_view.dart'; -import 'package:smoke_cess_app/widgets/view_form_page.dart'; +import 'package:smoke_cess_app/widgets/view_form/mood_form.dart'; +import 'package:smoke_cess_app/widgets/view_form/mood_view.dart'; +import 'package:smoke_cess_app/widgets/view_form/view_form_page.dart'; class MoodPage extends StatelessWidget { const MoodPage({super.key}); diff --git a/lib/pages/relapse_page.dart b/lib/pages/relapse_page.dart index e7b6127..db75e86 100644 --- a/lib/pages/relapse_page.dart +++ b/lib/pages/relapse_page.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:smoke_cess_app/widgets/relapse_form.dart'; -import 'package:smoke_cess_app/widgets/relapse_view.dart'; -import '../widgets/view_form_page.dart'; +import 'package:smoke_cess_app/widgets/view_form/relapse_form.dart'; +import 'package:smoke_cess_app/widgets/view_form/relapse_view.dart'; +import 'package:smoke_cess_app/widgets/view_form/view_form_page.dart'; class RelapsePage extends StatelessWidget { const RelapsePage({super.key}); diff --git a/lib/pages/sleep_page.dart b/lib/pages/sleep_page.dart index 3cf3fd5..8d9842d 100644 --- a/lib/pages/sleep_page.dart +++ b/lib/pages/sleep_page.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:smoke_cess_app/widgets/sleep_form.dart'; -import 'package:smoke_cess_app/widgets/sleep_view.dart'; -import 'package:smoke_cess_app/widgets/view_form_page.dart'; +import 'package:smoke_cess_app/widgets/view_form/sleep_form.dart'; +import 'package:smoke_cess_app/widgets/view_form/sleep_view.dart'; +import 'package:smoke_cess_app/widgets/view_form/view_form_page.dart'; class SleepPage extends StatelessWidget { const SleepPage({super.key}); diff --git a/lib/widgets/mute_button.dart b/lib/widgets/buttons/mute_button.dart similarity index 92% rename from lib/widgets/mute_button.dart rename to lib/widgets/buttons/mute_button.dart index 29bebf7..d74eb97 100644 --- a/lib/widgets/mute_button.dart +++ b/lib/widgets/buttons/mute_button.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - -import '../providers/audio_provider.dart'; +import '../../providers/audio_provider.dart'; class MuteButton extends StatelessWidget { const MuteButton({super.key}); diff --git a/lib/widgets/round_button_widget.dart b/lib/widgets/buttons/round_button_widget.dart similarity index 100% rename from lib/widgets/round_button_widget.dart rename to lib/widgets/buttons/round_button_widget.dart diff --git a/lib/widgets/submit_form_button.dart b/lib/widgets/buttons/submit_form_button.dart similarity index 100% rename from lib/widgets/submit_form_button.dart rename to lib/widgets/buttons/submit_form_button.dart diff --git a/lib/widgets/timer_button.dart b/lib/widgets/buttons/timer_button.dart similarity index 100% rename from lib/widgets/timer_button.dart rename to lib/widgets/buttons/timer_button.dart diff --git a/lib/widgets/missing_config_popup.dart b/lib/widgets/popup/missing_config_popup.dart similarity index 100% rename from lib/widgets/missing_config_popup.dart rename to lib/widgets/popup/missing_config_popup.dart diff --git a/lib/widgets/popup_for_start_and_stop.dart b/lib/widgets/popup/popup_for_start_and_stop.dart similarity index 100% rename from lib/widgets/popup_for_start_and_stop.dart rename to lib/widgets/popup/popup_for_start_and_stop.dart diff --git a/lib/widgets/popup_for_task_done.dart b/lib/widgets/popup/popup_for_task_done.dart similarity index 91% rename from lib/widgets/popup_for_task_done.dart rename to lib/widgets/popup/popup_for_task_done.dart index fbaa65d..cf7f7ed 100644 --- a/lib/widgets/popup_for_task_done.dart +++ b/lib/widgets/popup/popup_for_task_done.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/timer_provider.dart'; import 'package:smoke_cess_app/widgets/timer_widget.dart'; -import '../services/date_service.dart'; -import '../services/pages_service.dart'; +import 'package:smoke_cess_app/services/date_service.dart'; +import 'package:smoke_cess_app/services/pages_service.dart'; void showTaskDonePopup(BuildContext context, Pages page) async { Duration duration = await getTimeTill(page); diff --git a/lib/widgets/mood_form.dart b/lib/widgets/view_form/mood_form.dart similarity index 85% rename from lib/widgets/mood_form.dart rename to lib/widgets/view_form/mood_form.dart index e43e97d..2217682 100644 --- a/lib/widgets/mood_form.dart +++ b/lib/widgets/view_form/mood_form.dart @@ -3,11 +3,10 @@ import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; import 'package:smoke_cess_app/widgets/slider.dart'; -import 'package:smoke_cess_app/widgets/submit_form_button.dart'; +import 'package:smoke_cess_app/widgets/buttons/submit_form_button.dart'; import 'package:smoke_cess_app/widgets/text_formfield.dart'; - -import '../providers/input_provider.dart'; -import 'elevated_card.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; +import 'package:smoke_cess_app/widgets/elevated_card.dart'; class MoodForm extends StatelessWidget { const MoodForm({super.key}); diff --git a/lib/widgets/mood_view.dart b/lib/widgets/view_form/mood_view.dart similarity index 89% rename from lib/widgets/mood_view.dart rename to lib/widgets/view_form/mood_view.dart index 14884b9..b61f8b1 100644 --- a/lib/widgets/mood_view.dart +++ b/lib/widgets/view_form/mood_view.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; -import '../models/mood.dart'; -import '../providers/tasks_provider.dart'; +import 'package:smoke_cess_app/models/mood.dart'; +import 'package:smoke_cess_app/providers/tasks_provider.dart'; class MoodView extends StatelessWidget { const MoodView({super.key}); diff --git a/lib/widgets/relapse_form.dart b/lib/widgets/view_form/relapse_form.dart similarity index 78% rename from lib/widgets/relapse_form.dart rename to lib/widgets/view_form/relapse_form.dart index 9451277..ea7ba11 100644 --- a/lib/widgets/relapse_form.dart +++ b/lib/widgets/view_form/relapse_form.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; import 'package:smoke_cess_app/widgets/drop_down.dart'; -import 'package:smoke_cess_app/widgets/submit_form_button.dart'; +import 'package:smoke_cess_app/widgets/buttons/submit_form_button.dart'; import 'package:smoke_cess_app/widgets/text_formfield.dart'; -import '../providers/input_provider.dart'; -import '../providers/settings_provider.dart'; -import '../services/pages_service.dart'; -import 'elevated_card.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; +import 'package:smoke_cess_app/providers/settings_provider.dart'; +import 'package:smoke_cess_app/services/pages_service.dart'; +import 'package:smoke_cess_app/widgets/elevated_card.dart'; class RelapseForm extends StatelessWidget { const RelapseForm({super.key}); diff --git a/lib/widgets/relapse_view.dart b/lib/widgets/view_form/relapse_view.dart similarity index 88% rename from lib/widgets/relapse_view.dart rename to lib/widgets/view_form/relapse_view.dart index 48c9829..2480640 100644 --- a/lib/widgets/relapse_view.dart +++ b/lib/widgets/view_form/relapse_view.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../providers/tasks_provider.dart'; +import 'package:smoke_cess_app/providers/tasks_provider.dart'; class RelapseView extends StatelessWidget { const RelapseView({super.key}); diff --git a/lib/widgets/sleep_form.dart b/lib/widgets/view_form/sleep_form.dart similarity index 89% rename from lib/widgets/sleep_form.dart rename to lib/widgets/view_form/sleep_form.dart index 4996da7..377aed2 100644 --- a/lib/widgets/sleep_form.dart +++ b/lib/widgets/view_form/sleep_form.dart @@ -3,12 +3,12 @@ import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; import 'package:smoke_cess_app/widgets/elevated_card.dart'; import 'package:smoke_cess_app/widgets/slider.dart'; -import 'package:smoke_cess_app/widgets/submit_form_button.dart'; +import 'package:smoke_cess_app/widgets/buttons/submit_form_button.dart'; import 'package:smoke_cess_app/widgets/text_formfield.dart'; import 'package:smoke_cess_app/widgets/timepicker.dart'; -import '../providers/input_provider.dart'; -import '../services/pages_service.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; +import 'package:smoke_cess_app/services/pages_service.dart'; class SleepForm extends StatelessWidget { const SleepForm({Key? key}) : super(key: key); diff --git a/lib/widgets/sleep_view.dart b/lib/widgets/view_form/sleep_view.dart similarity index 94% rename from lib/widgets/sleep_view.dart rename to lib/widgets/view_form/sleep_view.dart index 90a005c..ffc9514 100644 --- a/lib/widgets/sleep_view.dart +++ b/lib/widgets/view_form/sleep_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/sleep.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; -import '../providers/tasks_provider.dart'; +import 'package:smoke_cess_app/providers/tasks_provider.dart'; class SleepView extends StatelessWidget { const SleepView({super.key}); diff --git a/lib/widgets/view_form_page.dart b/lib/widgets/view_form/view_form_page.dart similarity index 79% rename from lib/widgets/view_form_page.dart rename to lib/widgets/view_form/view_form_page.dart index 702374e..e58d5b0 100644 --- a/lib/widgets/view_form_page.dart +++ b/lib/widgets/view_form/view_form_page.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; -import 'package:smoke_cess_app/widgets/round_button_widget.dart'; -import '../providers/input_provider.dart'; -import '../providers/page_provider.dart'; -import '../providers/tasks_provider.dart'; -import 'popup_for_task_done.dart'; +import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart'; +import 'package:smoke_cess_app/providers/input_provider.dart'; +import 'package:smoke_cess_app/providers/page_provider.dart'; +import 'package:smoke_cess_app/providers/tasks_provider.dart'; +import 'package:smoke_cess_app/widgets/popup/popup_for_task_done.dart'; class ViewFormPage extends StatelessWidget { final Widget form; diff --git a/lib/widgets/workout_form.dart b/lib/widgets/view_form/workout_form.dart similarity index 79% rename from lib/widgets/workout_form.dart rename to lib/widgets/view_form/workout_form.dart index 3e75882..8a678c1 100644 --- a/lib/widgets/workout_form.dart +++ b/lib/widgets/view_form/workout_form.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/providers/audio_provider.dart'; -import '../providers/timer_provider.dart'; -import '../providers/workout_provider.dart'; -import 'mute_button.dart'; -import 'workout_timer_widget.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/buttons/mute_button.dart'; +import 'package:smoke_cess_app/widgets/workout_timer_widget.dart'; class WorkoutForm extends StatelessWidget { WorkoutForm({super.key}); diff --git a/lib/widgets/workout_view.dart b/lib/widgets/view_form/workout_view.dart similarity index 94% rename from lib/widgets/workout_view.dart rename to lib/widgets/view_form/workout_view.dart index d0deb4d..8bc2fef 100644 --- a/lib/widgets/workout_view.dart +++ b/lib/widgets/view_form/workout_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/workout.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; -import '../providers/tasks_provider.dart'; +import 'package:smoke_cess_app/providers/tasks_provider.dart'; class WorkoutView extends StatelessWidget { const WorkoutView({super.key}); diff --git a/lib/widgets/workout_timer_widget.dart b/lib/widgets/workout_timer_widget.dart index 72a8e50..51e7f0c 100644 --- a/lib/widgets/workout_timer_widget.dart +++ b/lib/widgets/workout_timer_widget.dart @@ -4,13 +4,13 @@ import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../providers/page_provider.dart'; -import '../providers/tasks_provider.dart'; -import '../providers/workout_provider.dart'; -import '../services/pages_service.dart'; -import '../widgets/timer_widget.dart'; -import '../providers/timer_provider.dart'; -import 'popup_for_start_and_stop.dart'; +import 'package:smoke_cess_app/providers/page_provider.dart'; +import 'package:smoke_cess_app/providers/tasks_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/timer_widget.dart'; +import 'package:smoke_cess_app/providers/timer_provider.dart'; +import 'package:smoke_cess_app/widgets/popup/popup_for_start_and_stop.dart'; class WorkoutTimerWidget extends StatelessWidget { const WorkoutTimerWidget({super.key}); From a5596b0934cf3f05bf7bd21428dc8f8d3a195a04 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 20:42:39 +0100 Subject: [PATCH 09/20] add intl package --- lib/main.dart | 2 ++ pubspec.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 4a49cd4..33f19bc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:intl/date_symbol_data_local.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/pages/main_page.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; @@ -14,6 +15,7 @@ void main() { //init database globals.databaseService; tz.initializeTimeZones(); + initializeDateFormatting('de'); NotificationService().initNotification(); runApp(const MyApp()); } diff --git a/pubspec.yaml b/pubspec.yaml index 690527f..ac1fafe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,6 +24,7 @@ dependencies: http: ^0.13.5 syncfusion_flutter_charts: ^20.4.52 cupertino_icons: ^1.0.2 + intl: ^0.18.0 dev_dependencies: flutter_test: From d9272bdfb2b8432d32da77baba09818e8d3af708 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 20:43:02 +0100 Subject: [PATCH 10/20] add startedAt Settingsproperty --- lib/models/settings.dart | 6 ++++-- lib/services/settings_service.dart | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 83fad43..dfa79be 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -6,9 +6,10 @@ class Settings { final QueryConfig? moodQuery; final QueryConfig? sleepQuery; final TimeConfig? chessTime; + final DateTime startedAt; Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery, - this.chessTime); + this.chessTime, this.startedAt); Settings.fromJson(Map json) : group = json['group'] as int, @@ -17,7 +18,8 @@ class Settings { sleepQuery = QueryConfig.fromJson(json['sleep_query']), chessTime = json['chess_time'] != null ? TimeConfig.fromJson(json['chess_time']) - : null; + : null, + startedAt = DateTime.parse(json['startedAt']); } class QueryConfig { diff --git a/lib/services/settings_service.dart b/lib/services/settings_service.dart index f28556a..ec8a656 100644 --- a/lib/services/settings_service.dart +++ b/lib/services/settings_service.dart @@ -23,6 +23,8 @@ Future getMoodQueryMinutes() => _getIntSetting('mood_query_minutes'); Future getChessHours() => _getIntSetting('chess_hours'); Future getChessMinutes() => _getIntSetting('chess_minutes'); +Future getStartDay() => _getStringSetting('startedAt'); + void _setIntSetting(String settingKey, int settingValue) => SharedPreferences.getInstance() .then((pref) => pref.setInt(settingKey, settingValue)); @@ -30,6 +32,13 @@ void _setIntSetting(String settingKey, int settingValue) => Future _getIntSetting(String settingKey) => SharedPreferences.getInstance().then((pref) => pref.getInt(settingKey)); +void _setStringSetting(String settingKey, String settingValue) => + SharedPreferences.getInstance() + .then((pref) => pref.setString(settingKey, settingValue)); + +Future _getStringSetting(String settingKey) => + SharedPreferences.getInstance().then((pref) => pref.getString(settingKey)); + void _setStringListSetting(String settingKey, List list) => SharedPreferences.getInstance() .then((pref) => pref.setStringList(settingKey, list)); @@ -40,6 +49,7 @@ Future?> _getStringListSetting(String settingKey) => Future loadSettingsFromLocalJSON() async { Map configJSON = await loadLocalConfigJSON(); + configJSON['startedAt'] = DateTime.now().toIso8601String(); Settings settings = Settings.fromJson(configJSON); saveSettings(settings); } @@ -53,6 +63,7 @@ void saveSettings(Settings settings) { _setStringListSetting('sleep_query_days', settings.sleepQuery!.days!); _setIntSetting('sleep_query_hours', settings.sleepQuery!.hours!); _setIntSetting('sleep_query_minutes', settings.sleepQuery!.minutes!); + _setStringSetting('startedAt', DateTime.now().toIso8601String()); if (settings.chessTime != null) { _setIntSetting('chess_hours', settings.chessTime!.hours!); _setIntSetting('chess_minutes', settings.chessTime!.minutes!); @@ -70,6 +81,8 @@ Future loadSettings() async { List? sleepDays = await getSleepQueryDaysCategories(); int? chessHours = await getChessHours(); int? chessMinutes = await getChessMinutes(); + DateTime startedAt = + DateTime.parse(await getStartDay() ?? DateTime.now().toIso8601String()); if (group != null) { return Settings( @@ -77,7 +90,8 @@ Future loadSettings() async { relapseCategories, QueryConfig(moodHours, moodMinutes, moodDays), QueryConfig(sleepHours, sleepMinutes, sleepDays), - TimeConfig(chessHours, chessMinutes)); + TimeConfig(chessHours, chessMinutes), + startedAt); } return null; } From b23f9ccdc1296f6900e899c81cc72501a03a2f7f Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 20:43:14 +0100 Subject: [PATCH 11/20] widget for line graph --- lib/widgets/line_chart_widget.dart | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/widgets/line_chart_widget.dart diff --git a/lib/widgets/line_chart_widget.dart b/lib/widgets/line_chart_widget.dart new file mode 100644 index 0000000..e03eabd --- /dev/null +++ b/lib/widgets/line_chart_widget.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/providers/settings_provider.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; + +class LineChart extends StatelessWidget { + final List dataSource; + final DateTime? Function(T, int) xValueMapper; + final num? Function(T, int) yValueMapper; + const LineChart( + {super.key, + required this.dataSource, + required this.xValueMapper, + required this.yValueMapper}); + + @override + Widget build(BuildContext context) { + SettingsProvider settingsProvider = context.watch(); + + return SfCartesianChart( + primaryXAxis: DateTimeAxis( + minimum: settingsProvider.settings?.startedAt, + maximum: settingsProvider.settings?.startedAt + .add(const Duration(days: 7 * 6)), + interval: 7, + dateFormat: DateFormat.Md('de'), + ), + primaryYAxis: + NumericAxis(isVisible: false, minimum: 0, maximum: 100, interval: 20), + series: [ + LineSeries( + dataSource: dataSource, + xValueMapper: xValueMapper, + yValueMapper: yValueMapper), + ], + ); + } +} From 54ec18d1fe8ed7560aa897879132cacebb886f32 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 20:54:08 +0100 Subject: [PATCH 12/20] use linechart widget in views --- lib/widgets/line_chart_widget.dart | 20 ++++++----------- lib/widgets/view_form/mood_view.dart | 16 ++++++-------- lib/widgets/view_form/sleep_view.dart | 10 ++++----- lib/widgets/view_form/view_form_page.dart | 3 ++- lib/widgets/view_form/workout_view.dart | 26 +++++++++++------------ 5 files changed, 32 insertions(+), 43 deletions(-) diff --git a/lib/widgets/line_chart_widget.dart b/lib/widgets/line_chart_widget.dart index e03eabd..de24754 100644 --- a/lib/widgets/line_chart_widget.dart +++ b/lib/widgets/line_chart_widget.dart @@ -5,14 +5,11 @@ import 'package:smoke_cess_app/providers/settings_provider.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; class LineChart extends StatelessWidget { - final List dataSource; - final DateTime? Function(T, int) xValueMapper; - final num? Function(T, int) yValueMapper; - const LineChart( - {super.key, - required this.dataSource, - required this.xValueMapper, - required this.yValueMapper}); + final List> series; + const LineChart({ + super.key, + required this.series, + }); @override Widget build(BuildContext context) { @@ -28,12 +25,7 @@ class LineChart extends StatelessWidget { ), primaryYAxis: NumericAxis(isVisible: false, minimum: 0, maximum: 100, interval: 20), - series: [ - LineSeries( - dataSource: dataSource, - xValueMapper: xValueMapper, - yValueMapper: yValueMapper), - ], + series: series, ); } } diff --git a/lib/widgets/view_form/mood_view.dart b/lib/widgets/view_form/mood_view.dart index b61f8b1..02cb557 100644 --- a/lib/widgets/view_form/mood_view.dart +++ b/lib/widgets/view_form/mood_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:smoke_cess_app/models/mood.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; @@ -13,15 +14,12 @@ class MoodView extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SfCartesianChart( - primaryXAxis: DateTimeAxis(), - series: [ - LineSeries( - dataSource: tasksModel.moodHistory, - xValueMapper: (Mood value, _) => value.date, - yValueMapper: (Mood value, _) => value.moodValue) - ], - ), + LineChart(series: [ + LineSeries( + dataSource: tasksModel.moodHistory, + xValueMapper: (Mood value, _) => value.date, + yValueMapper: (Mood value, _) => value.moodValue) + ]), Column( children: tasksModel.moodHistory.map((mood) { return Text('${mood.date}: ${mood.moodValue}'); diff --git a/lib/widgets/view_form/sleep_view.dart b/lib/widgets/view_form/sleep_view.dart index ffc9514..877d756 100644 --- a/lib/widgets/view_form/sleep_view.dart +++ b/lib/widgets/view_form/sleep_view.dart @@ -1,21 +1,21 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/sleep.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; class SleepView extends StatelessWidget { const SleepView({super.key}); @override Widget build(BuildContext context) { - var tasksModel = context.watch(); + TasksProvider tasksModel = context.watch(); return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SfCartesianChart( - primaryXAxis: DateTimeAxis(), - series: [ + LineChart( + series: [ LineSeries( dataSource: tasksModel.sleepHistory, xValueMapper: (Sleep value, _) => value.date, diff --git a/lib/widgets/view_form/view_form_page.dart b/lib/widgets/view_form/view_form_page.dart index e58d5b0..778d21d 100644 --- a/lib/widgets/view_form/view_form_page.dart +++ b/lib/widgets/view_form/view_form_page.dart @@ -35,7 +35,8 @@ class ViewFormPage extends StatelessWidget { child: RoundAddButton( onPressed: tasksProvider.tasks[page] == true ? () => pageProvider.swap() - : () => showTaskDonePopup(context, page), + : () => pageProvider.swap(), + //: () => showTaskDonePopup(context, page), ), ) ]); diff --git a/lib/widgets/view_form/workout_view.dart b/lib/widgets/view_form/workout_view.dart index 8bc2fef..d0787e6 100644 --- a/lib/widgets/view_form/workout_view.dart +++ b/lib/widgets/view_form/workout_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/workout.dart'; +import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; @@ -9,23 +10,20 @@ class WorkoutView extends StatelessWidget { @override Widget build(BuildContext context) { - var tasksModel = context.watch(); + TasksProvider tasksModel = context.watch(); return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SfCartesianChart( - primaryXAxis: DateTimeAxis(), - series: [ - LineSeries( - dataSource: tasksModel.workoutHistory, - xValueMapper: (Workout value, _) => value.date, - yValueMapper: (Workout value, _) => value.motivationBefore), - LineSeries( - dataSource: tasksModel.workoutHistory, - xValueMapper: (Workout value, _) => value.date, - yValueMapper: (Workout value, _) => value.motivationAfter) - ], - ), + LineChart(series: [ + LineSeries( + dataSource: tasksModel.workoutHistory, + xValueMapper: (Workout value, _) => value.date, + yValueMapper: (Workout value, _) => value.motivationBefore), + LineSeries( + dataSource: tasksModel.workoutHistory, + xValueMapper: (Workout value, _) => value.date, + yValueMapper: (Workout value, _) => value.motivationAfter) + ]), ], ); } From 3d0c8d3724bdeaaa3ab95af6d75797bdfda2df29 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 21:37:27 +0100 Subject: [PATCH 13/20] main page stateless, extended pageprovider --- lib/pages/main_page.dart | 48 ++++++++++---------------------- lib/providers/page_provider.dart | 12 ++++++++ lib/services/pages_service.dart | 2 +- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 026d707..ef396ef 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -8,41 +8,16 @@ import 'package:smoke_cess_app/providers/settings_provider.dart'; import '../widgets/todo_icon.dart'; -class MyHomePage extends StatefulWidget { +class MyHomePage extends StatelessWidget { const MyHomePage({super.key}); - @override - MyHomePageState createState() => MyHomePageState(); -} - -class MyHomePageState extends State { - int _selectedIndex = 4; - bool _isConfigured = false; - - void _onItemTapped(int index) { - PageProvider pageProvider = context.read(); - setState(() { - if (_isConfigured) { - pageProvider.showForm = false; - _selectedIndex = index; - return; - } - AwesomeDialog( - context: context, - dialogType: DialogType.info, - title: 'Fehlende Konfiguration', - desc: 'Bitte QR Code Scannen!', - ).show(); - }); - } - @override Widget build(BuildContext context) { - var settingsProvider = context.watch(); - var tasksProvider = context.watch(); + SettingsProvider settingsProvider = context.watch(); + TasksProvider tasksProvider = context.watch(); PageProvider pageProvider = context.watch(); + bool isConfigured = settingsProvider.initialized; - _isConfigured = settingsProvider.initialized; return Scaffold( appBar: AppBar( title: Row( @@ -59,13 +34,20 @@ class MyHomePageState extends State { ], ), Text( - '${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}') + '${pageProvider.currentPageData['title']} ${isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}') ], )), - body: pages.values.elementAt(_selectedIndex)['page'], + body: pageProvider.currentPageData['page'], bottomNavigationBar: NavigationBar( - onDestinationSelected: _onItemTapped, - selectedIndex: _selectedIndex, + onDestinationSelected: isConfigured + ? pageProvider.currentPage + : (value) => AwesomeDialog( + context: context, + dialogType: DialogType.info, + title: 'Fehlende Konfiguration', + desc: 'Bitte QR Code Scannen!', + ).show(), + selectedIndex: pageProvider.currentPageIndex, destinations: pages.keys.map((key) { return NavigationDestination( icon: tasksProvider.tasks[key] ?? false diff --git a/lib/providers/page_provider.dart b/lib/providers/page_provider.dart index a17ff26..ce1741a 100644 --- a/lib/providers/page_provider.dart +++ b/lib/providers/page_provider.dart @@ -1,10 +1,22 @@ import 'package:flutter/material.dart'; +import 'package:smoke_cess_app/services/pages_service.dart'; class PageProvider extends ChangeNotifier { bool showForm = false; + Pages _currentPage = Pages.settings; void swap() { showForm = !showForm; notifyListeners(); } + + Map get currentPageData => pages[_currentPage]!; + + int get currentPageIndex => _currentPage.index; + + void currentPage(int index) { + showForm = false; + _currentPage = Pages.values[index]; + notifyListeners(); + } } diff --git a/lib/services/pages_service.dart b/lib/services/pages_service.dart index 0c19383..9ec00d6 100644 --- a/lib/services/pages_service.dart +++ b/lib/services/pages_service.dart @@ -8,8 +8,8 @@ import '../pages/sleep_page.dart'; enum Pages { mood, sleep, - relapse, timer, + relapse, settings, } From 6c3915b6ab3d4949521ba6e56221b64e77886866 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Sun, 5 Mar 2023 21:44:51 +0100 Subject: [PATCH 14/20] rename function --- lib/pages/main_page.dart | 2 +- lib/providers/page_provider.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index ef396ef..9d6c77b 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -40,7 +40,7 @@ class MyHomePage extends StatelessWidget { body: pageProvider.currentPageData['page'], bottomNavigationBar: NavigationBar( onDestinationSelected: isConfigured - ? pageProvider.currentPage + ? pageProvider.setCurrentPage : (value) => AwesomeDialog( context: context, dialogType: DialogType.info, diff --git a/lib/providers/page_provider.dart b/lib/providers/page_provider.dart index ce1741a..8184ee7 100644 --- a/lib/providers/page_provider.dart +++ b/lib/providers/page_provider.dart @@ -14,7 +14,7 @@ class PageProvider extends ChangeNotifier { int get currentPageIndex => _currentPage.index; - void currentPage(int index) { + void setCurrentPage(int index) { showForm = false; _currentPage = Pages.values[index]; notifyListeners(); From e7dc40a4deb2b1f83056d602814733f680a37f9e Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 00:04:59 +0100 Subject: [PATCH 15/20] util funciton to calculate duration between two times => calc sleepTime --- lib/models/sleep.dart | 2 ++ lib/utils/timer_util.dart | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/models/sleep.dart b/lib/models/sleep.dart index 4447be4..991de20 100644 --- a/lib/models/sleep.dart +++ b/lib/models/sleep.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:smoke_cess_app/interface/db_record.dart'; +import 'package:smoke_cess_app/utils/timer_util.dart'; class Sleep implements DatabaseRecord { final int _sleepQualityValue; @@ -13,6 +14,7 @@ class Sleep implements DatabaseRecord { DateTime get date => _date; int get sleepQualitiyValue => _sleepQualityValue; + TimeOfDay get sleepDuration => _sleptAt.durationBetween(_wokeUpAt); @override factory Sleep.fromDatabase(Map map) { diff --git a/lib/utils/timer_util.dart b/lib/utils/timer_util.dart index a63030f..42a9180 100644 --- a/lib/utils/timer_util.dart +++ b/lib/utils/timer_util.dart @@ -1,3 +1,5 @@ +import 'package:flutter/material.dart'; + String formatTime(int seconds) { Duration duration = Duration(seconds: seconds); String formattedTime = ''; @@ -12,3 +14,12 @@ String formatTime(int seconds) { formattedTime += formattedSeconds; return formattedTime; } + +extension TimeOfDayExtension on TimeOfDay { + TimeOfDay durationBetween(TimeOfDay time) { + int hourOffset = time.minute - minute < 0 ? 1 : 0; + return TimeOfDay( + hour: (time.hour - hour - hourOffset) % 24, + minute: (time.minute - minute) % 60); + } +} From 43723f4ef2b216f5b2b9a23683c639e2010142e9 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 00:05:11 +0100 Subject: [PATCH 16/20] use historylist to display entries --- lib/widgets/entry_detail_widget.dart | 41 +++++++++++++++++++++++ lib/widgets/history_list_widget.dart | 29 ++++++++++++++++ lib/widgets/view_form/sleep_view.dart | 11 +++--- lib/widgets/view_form/view_form_page.dart | 1 - 4 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 lib/widgets/entry_detail_widget.dart create mode 100644 lib/widgets/history_list_widget.dart diff --git a/lib/widgets/entry_detail_widget.dart b/lib/widgets/entry_detail_widget.dart new file mode 100644 index 0000000..efa70cd --- /dev/null +++ b/lib/widgets/entry_detail_widget.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class EntryDetail extends StatelessWidget { + final DateTime date; + final String entryData; + final IconData icon; + + const EntryDetail( + {super.key, + required this.date, + required this.entryData, + required this.icon}); + + @override + Widget build(BuildContext context) { + return Card( + child: ListTile( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + leading: const Icon(Icons.local_airport, color: Colors.white), + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text( + DateFormat.MMMd('de').format(date), + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + Text( + entryData, + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ) + ], + ), + tileColor: Theme.of(context).colorScheme.primary.withOpacity(0.8), + )); + } +} diff --git a/lib/widgets/history_list_widget.dart b/lib/widgets/history_list_widget.dart new file mode 100644 index 0000000..dab25cf --- /dev/null +++ b/lib/widgets/history_list_widget.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:smoke_cess_app/widgets/entry_detail_widget.dart'; + +class HistoryList extends StatelessWidget { + final List history; + final DateTime Function(T) dateSelector; + final String Function(T) entryDataSelector; + + const HistoryList( + {super.key, + required this.history, + required this.dateSelector, + required this.entryDataSelector}); + + @override + Widget build(BuildContext context) { + return Container( + height: MediaQuery.of(context).size.height * 0.25, + margin: const EdgeInsets.only(top: 10), + child: ListView( + children: history.map((T entry) { + return EntryDetail( + date: dateSelector(entry), + entryData: entryDataSelector(entry), + icon: Icons.bedtime_outlined, + ); + }).toList())); + } +} diff --git a/lib/widgets/view_form/sleep_view.dart b/lib/widgets/view_form/sleep_view.dart index 877d756..33b610c 100644 --- a/lib/widgets/view_form/sleep_view.dart +++ b/lib/widgets/view_form/sleep_view.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/sleep.dart'; +import 'package:smoke_cess_app/widgets/entry_detail_widget.dart'; +import 'package:smoke_cess_app/widgets/history_list_widget.dart'; import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; @@ -22,10 +24,11 @@ class SleepView extends StatelessWidget { yValueMapper: (Sleep value, _) => value.sleepQualitiyValue) ], ), - Column( - children: tasksModel.sleepHistory.map((sleep) { - return Text('${sleep.date}: ${sleep.sleepQualitiyValue}'); - }).toList()) + HistoryList( + history: tasksModel.sleepHistory, + dateSelector: (Sleep sleep) => sleep.date, + entryDataSelector: (Sleep sleep) => + '${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}') ], ); } diff --git a/lib/widgets/view_form/view_form_page.dart b/lib/widgets/view_form/view_form_page.dart index 778d21d..099ae07 100644 --- a/lib/widgets/view_form/view_form_page.dart +++ b/lib/widgets/view_form/view_form_page.dart @@ -5,7 +5,6 @@ import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart'; import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/providers/page_provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; -import 'package:smoke_cess_app/widgets/popup/popup_for_task_done.dart'; class ViewFormPage extends StatelessWidget { final Widget form; From e91caaa5ba67e4e74263c3f9c73207b7f6a1f54f Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 00:34:45 +0100 Subject: [PATCH 17/20] display correct icons in historyview, mood icon dependant on moodvalue --- lib/widgets/entry_detail_widget.dart | 2 +- lib/widgets/history_list_widget.dart | 22 +++++++++++++++++----- lib/widgets/view_form/mood_view.dart | 13 +++++++++---- lib/widgets/view_form/relapse_view.dart | 15 +++++++++------ lib/widgets/view_form/sleep_view.dart | 13 +++++++------ 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/widgets/entry_detail_widget.dart b/lib/widgets/entry_detail_widget.dart index efa70cd..10afacc 100644 --- a/lib/widgets/entry_detail_widget.dart +++ b/lib/widgets/entry_detail_widget.dart @@ -19,7 +19,7 @@ class EntryDetail extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), - leading: const Icon(Icons.local_airport, color: Colors.white), + leading: Icon(icon, color: Colors.white), title: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ diff --git a/lib/widgets/history_list_widget.dart b/lib/widgets/history_list_widget.dart index dab25cf..6996f6a 100644 --- a/lib/widgets/history_list_widget.dart +++ b/lib/widgets/history_list_widget.dart @@ -5,12 +5,25 @@ class HistoryList extends StatelessWidget { final List history; final DateTime Function(T) dateSelector; final String Function(T) entryDataSelector; + final IconData Function(T)? iconDataSelector; + final IconData? icon; const HistoryList( {super.key, required this.history, required this.dateSelector, - required this.entryDataSelector}); + required this.entryDataSelector, + this.iconDataSelector, + this.icon}); + + IconData _getIcon(T entry) { + if (icon != null) { + return icon!; + } else if (iconDataSelector != null) { + return iconDataSelector!(entry); + } + return Icons.circle; + } @override Widget build(BuildContext context) { @@ -20,10 +33,9 @@ class HistoryList extends StatelessWidget { child: ListView( children: history.map((T entry) { return EntryDetail( - date: dateSelector(entry), - entryData: entryDataSelector(entry), - icon: Icons.bedtime_outlined, - ); + date: dateSelector(entry), + entryData: entryDataSelector(entry), + icon: _getIcon(entry)); }).toList())); } } diff --git a/lib/widgets/view_form/mood_view.dart b/lib/widgets/view_form/mood_view.dart index 02cb557..92017f0 100644 --- a/lib/widgets/view_form/mood_view.dart +++ b/lib/widgets/view_form/mood_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/widgets/history_list_widget.dart'; import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:smoke_cess_app/models/mood.dart'; @@ -20,10 +21,14 @@ class MoodView extends StatelessWidget { xValueMapper: (Mood value, _) => value.date, yValueMapper: (Mood value, _) => value.moodValue) ]), - Column( - children: tasksModel.moodHistory.map((mood) { - return Text('${mood.date}: ${mood.moodValue}'); - }).toList()) + HistoryList( + history: tasksModel.moodHistory, + dateSelector: (Mood mood) => mood.date, + entryDataSelector: (Mood mood) => 'Stimmung: ${mood.moodValue}', + iconDataSelector: (Mood mood) => mood.moodValue >= 50 + ? Icons.mood_outlined + : Icons.mood_bad_outlined, + ) ], ); } diff --git a/lib/widgets/view_form/relapse_view.dart b/lib/widgets/view_form/relapse_view.dart index 2480640..92072f4 100644 --- a/lib/widgets/view_form/relapse_view.dart +++ b/lib/widgets/view_form/relapse_view.dart @@ -1,17 +1,20 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:smoke_cess_app/models/relapse.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; +import 'package:smoke_cess_app/widgets/history_list_widget.dart'; class RelapseView extends StatelessWidget { const RelapseView({super.key}); @override Widget build(BuildContext context) { - var tasksModel = context.watch(); - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: tasksModel.relapseHistory.map((relapse) { - return Text('${relapse.date}: ${relapse.category}'); - }).toList()); + TasksProvider tasksModel = context.watch(); + return HistoryList( + history: tasksModel.relapseHistory, + dateSelector: (Relapse relapse) => relapse.date, + entryDataSelector: (Relapse relapse) => 'Grund: ${relapse.category}', + icon: Icons.smoke_free_outlined, + ); } } diff --git a/lib/widgets/view_form/sleep_view.dart b/lib/widgets/view_form/sleep_view.dart index 33b610c..4e1e90d 100644 --- a/lib/widgets/view_form/sleep_view.dart +++ b/lib/widgets/view_form/sleep_view.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/sleep.dart'; -import 'package:smoke_cess_app/widgets/entry_detail_widget.dart'; import 'package:smoke_cess_app/widgets/history_list_widget.dart'; import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; @@ -24,11 +23,13 @@ class SleepView extends StatelessWidget { yValueMapper: (Sleep value, _) => value.sleepQualitiyValue) ], ), - HistoryList( - history: tasksModel.sleepHistory, - dateSelector: (Sleep sleep) => sleep.date, - entryDataSelector: (Sleep sleep) => - '${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}') + HistoryList( + history: tasksModel.sleepHistory, + dateSelector: (Sleep sleep) => sleep.date, + entryDataSelector: (Sleep sleep) => + '${sleep.sleepDuration.hour}:${sleep.sleepDuration.minute}', + icon: Icons.bedtime_outlined, + ) ], ); } From 5795b0a4e8a7f23521b80537f0af3e86b0773dbd Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 00:39:50 +0100 Subject: [PATCH 18/20] add Workout historylist --- lib/widgets/view_form/workout_view.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/widgets/view_form/workout_view.dart b/lib/widgets/view_form/workout_view.dart index d0787e6..3e904e6 100644 --- a/lib/widgets/view_form/workout_view.dart +++ b/lib/widgets/view_form/workout_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/workout.dart'; +import 'package:smoke_cess_app/widgets/history_list_widget.dart'; import 'package:smoke_cess_app/widgets/line_chart_widget.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; @@ -24,6 +25,13 @@ class WorkoutView extends StatelessWidget { xValueMapper: (Workout value, _) => value.date, yValueMapper: (Workout value, _) => value.motivationAfter) ]), + HistoryList( + history: tasksModel.workoutHistory, + dateSelector: (Workout workout) => workout.date, + entryDataSelector: (Workout workout) => + '${workout.motivationBefore} : ${workout.motivationAfter}', + icon: Icons.sports_score_outlined, + ) ], ); } From b8d3bc704856c0aa0de02532ef7b2ba2374ec41b Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 11:34:01 +0100 Subject: [PATCH 19/20] redo testing button add functinality --- lib/widgets/view_form/view_form_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/widgets/view_form/view_form_page.dart b/lib/widgets/view_form/view_form_page.dart index 099ae07..e58d5b0 100644 --- a/lib/widgets/view_form/view_form_page.dart +++ b/lib/widgets/view_form/view_form_page.dart @@ -5,6 +5,7 @@ import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart'; import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/providers/page_provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; +import 'package:smoke_cess_app/widgets/popup/popup_for_task_done.dart'; class ViewFormPage extends StatelessWidget { final Widget form; @@ -34,8 +35,7 @@ class ViewFormPage extends StatelessWidget { child: RoundAddButton( onPressed: tasksProvider.tasks[page] == true ? () => pageProvider.swap() - : () => pageProvider.swap(), - //: () => showTaskDonePopup(context, page), + : () => showTaskDonePopup(context, page), ), ) ]); From c12053c2fa0b416941a37883da3c5f1a30bf7039 Mon Sep 17 00:00:00 2001 From: "k.mannweiler" <2012491@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 13:14:42 +0100 Subject: [PATCH 20/20] Fixed Layout for small screens --- lib/widgets/buttons/round_button_widget.dart | 6 +++-- lib/widgets/history_list_widget.dart | 14 +++++----- lib/widgets/view_form/mood_form.dart | 3 +-- lib/widgets/view_form/relapse_form.dart | 3 +-- lib/widgets/view_form/sleep_form.dart | 3 +-- lib/widgets/view_form/view_form_page.dart | 27 ++++++++++---------- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/widgets/buttons/round_button_widget.dart b/lib/widgets/buttons/round_button_widget.dart index 2af5df4..14efe2d 100644 --- a/lib/widgets/buttons/round_button_widget.dart +++ b/lib/widgets/buttons/round_button_widget.dart @@ -2,8 +2,10 @@ import 'package:flutter/material.dart'; class RoundAddButton extends StatelessWidget { final VoidCallback onPressed; + final IconData iconData; - const RoundAddButton({super.key, required this.onPressed}); + const RoundAddButton( + {super.key, required this.onPressed, required this.iconData}); @override Widget build(BuildContext context) { @@ -16,7 +18,7 @@ class RoundAddButton extends StatelessWidget { foregroundColor: Colors.blue, // <-- Splash color ), child: Icon( - Icons.add_outlined, + iconData, color: Colors.white, size: MediaQuery.of(context).size.height * 0.05, ), diff --git a/lib/widgets/history_list_widget.dart b/lib/widgets/history_list_widget.dart index 6996f6a..ff63e49 100644 --- a/lib/widgets/history_list_widget.dart +++ b/lib/widgets/history_list_widget.dart @@ -27,15 +27,13 @@ class HistoryList extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - height: MediaQuery.of(context).size.height * 0.25, - margin: const EdgeInsets.only(top: 10), + return Expanded( child: ListView( children: history.map((T entry) { - return EntryDetail( - date: dateSelector(entry), - entryData: entryDataSelector(entry), - icon: _getIcon(entry)); - }).toList())); + return EntryDetail( + date: dateSelector(entry), + entryData: entryDataSelector(entry), + icon: _getIcon(entry)); + }).toList())); } } diff --git a/lib/widgets/view_form/mood_form.dart b/lib/widgets/view_form/mood_form.dart index 2217682..9985b9b 100644 --- a/lib/widgets/view_form/mood_form.dart +++ b/lib/widgets/view_form/mood_form.dart @@ -15,8 +15,7 @@ class MoodForm extends StatelessWidget { Widget build(BuildContext context) { var inputModel = context.watch(); var tasksModel = context.watch(); - return Column( - mainAxisAlignment: MainAxisAlignment.center, + return ListView( children: [ const ElevatedCard( title: 'Stimmungsbewertung', diff --git a/lib/widgets/view_form/relapse_form.dart b/lib/widgets/view_form/relapse_form.dart index ea7ba11..3d1a1ab 100644 --- a/lib/widgets/view_form/relapse_form.dart +++ b/lib/widgets/view_form/relapse_form.dart @@ -17,8 +17,7 @@ class RelapseForm extends StatelessWidget { var inputModel = context.watch(); var settingsModel = context.watch(); var tasksModel = context.watch(); - return Column( - mainAxisAlignment: MainAxisAlignment.center, + return ListView( children: [ ElevatedCard( title: 'Rückfallkategorie', diff --git a/lib/widgets/view_form/sleep_form.dart b/lib/widgets/view_form/sleep_form.dart index 377aed2..bb01e37 100644 --- a/lib/widgets/view_form/sleep_form.dart +++ b/lib/widgets/view_form/sleep_form.dart @@ -18,8 +18,7 @@ class SleepForm extends StatelessWidget { InputProvider inputModel = context.watch(); TasksProvider tasksModel = context.watch(); - return Column( - mainAxisAlignment: MainAxisAlignment.center, + return ListView( children: [ const ElevatedCard( title: 'Einschlafzeit', diff --git a/lib/widgets/view_form/view_form_page.dart b/lib/widgets/view_form/view_form_page.dart index 099ae07..0b348b6 100644 --- a/lib/widgets/view_form/view_form_page.dart +++ b/lib/widgets/view_form/view_form_page.dart @@ -5,6 +5,7 @@ import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart'; import 'package:smoke_cess_app/providers/input_provider.dart'; import 'package:smoke_cess_app/providers/page_provider.dart'; import 'package:smoke_cess_app/providers/tasks_provider.dart'; +import 'package:smoke_cess_app/widgets/popup/popup_for_task_done.dart'; class ViewFormPage extends StatelessWidget { final Widget form; @@ -19,23 +20,23 @@ class ViewFormPage extends StatelessWidget { PageProvider pageProvider = context.watch(); TasksProvider tasksProvider = context.watch(); return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - pageProvider.showForm - ? Center( - child: ChangeNotifierProvider( - create: (context) => InputProvider(), - child: form, - )) - : Center(child: view), + Expanded( + child: Center( + child: pageProvider.showForm + ? ChangeNotifierProvider( + create: (context) => InputProvider(), + child: form, + ) + : view, + )), if (!pageProvider.showForm) Container( - height: height / 8, - width: height / 8, - margin: EdgeInsets.only(bottom: height * 0.08), + margin: EdgeInsets.symmetric(vertical: height * 0.02), child: RoundAddButton( - onPressed: tasksProvider.tasks[page] == true + iconData: Icons.add_outlined, + onPressed: tasksProvider.tasks[page] ?? true ? () => pageProvider.swap() - : () => pageProvider.swap(), - //: () => showTaskDonePopup(context, page), + : () => showTaskDonePopup(context, page), ), ) ]);