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] 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), ), ) ]);