Improve detail view of meals

The header and values are now better centered, making this a bit more visually
pleasing
This commit is contained in:
Roland Geider
2021-04-28 12:24:02 +02:00
parent 4c7452e634
commit f82cd65acf
2 changed files with 61 additions and 14 deletions

View File

@@ -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,
);
}
}

View File

@@ -59,12 +59,31 @@ class _MealWidgetState extends State<MealWidget> {
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,
),
),
],
),
],