From a6cd87c3dbdd54db1e7a26cbf63c4329e91c03d3 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 11 Jul 2024 21:17:15 +0300 Subject: [PATCH] todo's --- lib/providers/nutrition.dart | 7 +++++-- lib/widgets/nutrition/forms.dart | 1 + lib/widgets/nutrition/helpers.dart | 1 + lib/widgets/nutrition/widgets.dart | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/providers/nutrition.dart b/lib/providers/nutrition.dart index f6bd5af9..532617d5 100644 --- a/lib/providers/nutrition.dart +++ b/lib/providers/nutrition.dart @@ -132,6 +132,7 @@ class NutritionPlansProvider with ChangeNotifier { try { plan = findById(planId); } on NoSuchEntryException { + // TODO: remove this useless call, because we will fetch all details below plan = await fetchAndSetPlanSparse(planId); } @@ -145,6 +146,7 @@ class NutritionPlansProvider with ChangeNotifier { final List mealItems = []; final meal = Meal.fromJson(mealData); + // TODO: we should add these ingredients to the ingredient cache for (final mealItemData in mealData['meal_items']) { final mealItem = MealItem.fromJson(mealItemData); @@ -376,9 +378,10 @@ class NutritionPlansProvider with ChangeNotifier { if (data['count'] == 0) { return null; - } else { - return Ingredient.fromJson(data['results'][0]); } + // TODO we should probably add it to ingredient cache. + // TODO: we could also use the ingredient cache for code searches + return Ingredient.fromJson(data['results'][0]); } /// Log meal to nutrition diary diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index 23928bac..6998ed0b 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -367,6 +367,7 @@ class IngredientFormState extends State { ) { if (snapshot.hasData) { _mealItem.ingredient = snapshot.data!; + // here it could be nice to put the button to the popup return MealItemValuesTile( ingredient: _mealItem.ingredient, nutritionalValues: _mealItem.nutritionalValues, diff --git a/lib/widgets/nutrition/helpers.dart b/lib/widgets/nutrition/helpers.dart index 27e45761..3fc47ca5 100644 --- a/lib/widgets/nutrition/helpers.dart +++ b/lib/widgets/nutrition/helpers.dart @@ -107,6 +107,7 @@ void showIngredientDetails(BuildContext context, int id, {String? image}) { final url = context.read().baseProvider.auth.serverUrl; +// TODO: display source name and source URL for an ingredient in the UI showDialog( context: context, builder: (context) => FutureBuilder( diff --git a/lib/widgets/nutrition/widgets.dart b/lib/widgets/nutrition/widgets.dart index ba3dc0b6..ed79f111 100644 --- a/lib/widgets/nutrition/widgets.dart +++ b/lib/widgets/nutrition/widgets.dart @@ -224,6 +224,7 @@ class _IngredientTypeaheadState extends State { mainAxisSize: MainAxisSize.min, children: [ Text(AppLocalizations.of(context).productFoundDescription(result.name)), + // TODO replace with full view instead of small popup MealItemValuesTile( ingredient: result, nutritionalValues: result.nutritionalValues,