Fixed Paddings

main
Kai Mannweiler 2023-03-06 15:46:40 +01:00
parent 30c798c15f
commit 56acb1e84c
10 changed files with 66 additions and 62 deletions

View File

@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
class RoundAddButton extends StatelessWidget {
class RoundIconButton extends StatelessWidget {
final VoidCallback onPressed;
final IconData iconData;
const RoundAddButton(
const RoundIconButton(
{super.key, required this.onPressed, required this.iconData});
@override

View File

@ -2,6 +2,7 @@ import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/page_provider.dart';
import 'package:smoke_cess_app/widgets/buttons/round_button_widget.dart';
class SubmitFormButton extends StatelessWidget {
final Future<int> Function() submitCallback;
@ -14,7 +15,7 @@ class SubmitFormButton extends StatelessWidget {
PageProvider pageProvider = context.watch<PageProvider>();
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
child: RoundIconButton(
onPressed: () async {
int success = await submitCallback();
if (context.mounted) {
@ -37,7 +38,7 @@ class SubmitFormButton extends StatelessWidget {
}
}
},
child: const Text('Speichern'),
iconData: Icons.check_outlined,
),
);
}

View File

@ -11,18 +11,22 @@ class EntryDetailTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
DateFormat.MMMd('de').format(date),
style:
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
Text(
Flexible(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Text(
entryData,
style:
const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
)
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
)))
],
);
}

View File

@ -22,8 +22,7 @@ class EntryDetail extends StatelessWidget {
);
final Color color = Theme.of(context).colorScheme.primary.withOpacity(0.8);
final Widget title = EntryDetailTitle(date: date, entryData: entryData);
return Card(
child: entryComment != null
return entryComment != null
? ExpansionTile(
iconColor: Colors.white,
collapsedIconColor: Colors.white,
@ -36,11 +35,16 @@ class EntryDetail extends StatelessWidget {
Theme.of(context).colorScheme.secondary.withOpacity(0.8),
children: entryComment != null
? [
Text(
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
child: Text(
entryComment ?? '',
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
)
color: Colors.white,
fontWeight: FontWeight.bold),
))
])
]
: [],
)
@ -49,6 +53,6 @@ class EntryDetail extends StatelessWidget {
leading: icon,
title: title,
tileColor: color,
));
);
}
}

View File

@ -39,11 +39,13 @@ class HistoryList<T> extends StatelessWidget {
return Expanded(
child: ListView(
children: history.map((T entry) {
return EntryDetail(
return Padding(
padding: const EdgeInsets.only(bottom: 5),
child: EntryDetail(
date: dateSelector(entry),
entryData: entryDataSelector(entry),
entryComment: _getComment(entry),
iconData: _getIcon(entry));
iconData: _getIcon(entry)));
}).toList()));
}
}

View File

@ -26,9 +26,6 @@ class MoodForm extends StatelessWidget {
title: 'Beschreibe deine Stimmung',
child: MyTextFormField('Beschreibe deine Stimmung'),
),
const SizedBox(
height: 80,
),
SubmitFormButton(
submitCallback: inputModel.saveMood,
updateTasks: () => tasksModel.setTaskDone(Pages.mood),

View File

@ -27,9 +27,6 @@ class RelapseForm extends StatelessWidget {
title: 'Beschreibe deinen Rückfall',
child: MyTextFormField('Beschreibe deinen Rückfall'),
),
const SizedBox(
height: 80,
),
SubmitFormButton(
submitCallback: inputModel.saveRelapse,
updateTasks: () => tasksModel.setTaskDone(Pages.mood),

View File

@ -14,7 +14,7 @@ class RelapseView extends StatelessWidget {
HistoryList<Relapse>(
history: tasksModel.relapseHistory,
dateSelector: (Relapse relapse) => relapse.date,
entryDataSelector: (Relapse relapse) => 'Grund: ${relapse.category}',
entryDataSelector: (Relapse relapse) => relapse.category,
entryCommentSelector: (Relapse relapse) =>
'Kommentar: ${relapse.comment}',
icon: Icons.smoke_free_outlined,

View File

@ -39,9 +39,6 @@ class SleepForm extends StatelessWidget {
title: 'Schlafbeschreibung',
child: MyTextFormField('Beschreibe deinen Schlaf'),
),
const SizedBox(
height: 80,
),
SubmitFormButton(
submitCallback: () =>
inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt),

View File

@ -21,6 +21,8 @@ class ViewFormPage extends StatelessWidget {
TasksProvider tasksProvider = context.watch<TasksProvider>();
return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Center(
child: pageProvider.showForm
? ChangeNotifierProvider(
@ -28,11 +30,11 @@ class ViewFormPage extends StatelessWidget {
child: form,
)
: view,
)),
))),
if (!pageProvider.showForm)
Container(
margin: EdgeInsets.symmetric(vertical: height * 0.02),
child: RoundAddButton(
child: RoundIconButton(
iconData: Icons.add_outlined,
onPressed: tasksProvider.tasks[page] ?? true
? () => pageProvider.swap()