From 1cf1cff93a272f7451dedcdc586124397ad1dc9d Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 24 Dec 2020 23:51:21 +0100 Subject: [PATCH] Mute the text for the nutritional values The user should not see a spreadsheet when he opens the plan --- lib/theme/theme.dart | 1 + lib/widgets/core/core.dart | 33 ++++++++++++++++++++++++++ lib/widgets/nutrition/meal.dart | 41 +++++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 lib/widgets/core/core.dart diff --git a/lib/theme/theme.dart b/lib/theme/theme.dart index 09f33d676..67e44b832 100644 --- a/lib/theme/theme.dart +++ b/lib/theme/theme.dart @@ -22,6 +22,7 @@ import 'package:flutter/material.dart'; const Color wgerPrimaryColor = Color(0xff2a4c7d); const Color wgerPrimaryButtonColor = Color(0xff266dd3); const Color wgerSecondaryColor = Color(0xffe63946); +const Color wgerTextMuted = Colors.black38; // Chart colors const charts.Color wgerChartPrimaryColor = charts.Color(r: 0x2a, g: 0x4c, b: 0x7d); diff --git a/lib/widgets/core/core.dart b/lib/widgets/core/core.dart new file mode 100644 index 000000000..690df39ce --- /dev/null +++ b/lib/widgets/core/core.dart @@ -0,0 +1,33 @@ +/* + * This file is part of wger Workout Manager . + * Copyright (C) 2020 wger Team + * + * wger Workout Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wger Workout Manager is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import 'package:flutter/material.dart'; +import 'package:wger/theme/theme.dart'; + +class MutedText extends StatelessWidget { + String _text; + MutedText( + this._text, { + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Text(_text, style: TextStyle(color: wgerTextMuted)); + } +} diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index 962b89002..1b40932b1 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -23,6 +23,7 @@ import 'package:wger/models/nutrition/meal.dart'; import 'package:wger/models/nutrition/meal_item.dart'; import 'package:wger/providers/nutrition.dart'; import 'package:wger/widgets/core/bottom_sheet.dart'; +import 'package:wger/widgets/core/core.dart'; import 'package:wger/widgets/nutrition/forms.dart'; class MealWidget extends StatelessWidget { @@ -35,10 +36,23 @@ class MealWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Container( + padding: EdgeInsets.all(3), child: Card( child: Column( children: [ DismissibleMealHeader(meal: _meal), + Padding( + padding: const EdgeInsets.all(5), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + MutedText('Energy'), + MutedText("protein"), + MutedText("carbohydrates"), + MutedText("fat"), + ], + ), + ), ..._meal.mealItems.map((item) => MealItemWidget(item)).toList(), OutlinedButton( child: Text('Add ingredient'), @@ -65,20 +79,23 @@ class MealItemWidget extends StatelessWidget { return Container( padding: EdgeInsets.all(5), - child: Table( - columnWidths: { - 0: FlexColumnWidth(5), - 1: FlexColumnWidth(2), - }, + child: Column( children: [ - TableRow( + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 5), + child: Text( + '${_item.amount.toStringAsFixed(0)}$unit ${_item.ingredientObj.name}', + textAlign: TextAlign.left, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('${_item.amount.toStringAsFixed(0)}$unit ${_item.ingredientObj.name}'), - Text( - '${values["energy"].toStringAsFixed(0)} kcal / ${values["energyKj"].toStringAsFixed(0)} kJ'), - Text('${values["protein"].toStringAsFixed(0)}g'), - Text('${values["carbohydrates"].toStringAsFixed(0)}g'), - Text('${values["fat"].toStringAsFixed(0)}g'), + MutedText('${values["energy"].toStringAsFixed(0)} kcal'), + MutedText('${values["protein"].toStringAsFixed(0)}g'), + MutedText('${values["carbohydrates"].toStringAsFixed(0)}g'), + MutedText('${values["fat"].toStringAsFixed(0)}g'), ], ), ],