From f82cd65acfc97ca20d7f1a3b6db05ac3126c0be3 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 28 Apr 2021 12:24:02 +0200 Subject: [PATCH] Improve detail view of meals The header and values are now better centered, making this a bit more visually pleasing --- lib/widgets/core/core.dart | 15 +++++++-- lib/widgets/nutrition/meal.dart | 60 ++++++++++++++++++++++++++------- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/lib/widgets/core/core.dart b/lib/widgets/core/core.dart index 8a8382412..7c1ca0835 100644 --- a/lib/widgets/core/core.dart +++ b/lib/widgets/core/core.dart @@ -21,14 +21,25 @@ import 'package:wger/theme/theme.dart'; class MutedText extends StatelessWidget { String _text; + TextAlign _textAlign = TextAlign.left; + MutedText( this._text, { Key? key, - }) : super(key: key); + TextAlign? textAlign, + }) : super(key: key) { + if (textAlign != null) { + this._textAlign = textAlign; + } + } @override Widget build(BuildContext context) { - return Text(_text, style: TextStyle(color: wgerTextMuted)); + return Text( + _text, + style: TextStyle(color: wgerTextMuted), + textAlign: _textAlign, + ); } } diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index 1363debc9..7a54f09cd 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -59,12 +59,31 @@ class _MealWidgetState extends State { Padding( padding: const EdgeInsets.all(5), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - MutedText(AppLocalizations.of(context)!.energy), - MutedText(AppLocalizations.of(context)!.protein), - MutedText(AppLocalizations.of(context)!.carbohydrates), - MutedText(AppLocalizations.of(context)!.fat), + Expanded( + child: MutedText( + AppLocalizations.of(context)!.energy, + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + AppLocalizations.of(context)!.protein, + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + AppLocalizations.of(context)!.carbohydrates, + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + AppLocalizations.of(context)!.fat, + textAlign: TextAlign.center, + ), + ), ], ), ), @@ -141,14 +160,31 @@ class MealItemWidget extends StatelessWidget { ), if (_expanded) Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - MutedText( - '${values.energy.toStringAsFixed(0)} ${AppLocalizations.of(context)!.kcal}'), - MutedText('${values.protein.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}'), - MutedText( - '${values.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}'), - MutedText('${values.fat.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}'), + Expanded( + child: MutedText( + '${values.energy.toStringAsFixed(0)} ${AppLocalizations.of(context)!.kcal}', + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + '${values.protein.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + '${values.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + textAlign: TextAlign.center, + ), + ), + Expanded( + child: MutedText( + '${values.fat.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + textAlign: TextAlign.center, + ), + ), ], ), ],