From 2e22914cc2f1e537d64d6d4a05fabd3230448285 Mon Sep 17 00:00:00 2001 From: 98spag Date: Fri, 16 Jun 2023 12:17:23 +0200 Subject: [PATCH] feat: sort meals --- lib/android/components/food_list_component.dart | 5 +++-- lib/android/components/meals.dart | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/android/components/food_list_component.dart b/lib/android/components/food_list_component.dart index fa0e4ee..cda9b35 100644 --- a/lib/android/components/food_list_component.dart +++ b/lib/android/components/food_list_component.dart @@ -14,14 +14,15 @@ class FoodComponent extends StatelessWidget { return ValueListenableBuilder( valueListenable: box.listenable(), builder: (context, box, widget) { + final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired orde return ListView.builder( primary: false, shrinkWrap: true, itemCount: box.keys.length, itemBuilder: (context, i) { return CardComponent( - eatingMealName: box.keyAt(i).toString(), - selectedMeal: castDynamicToListFood(box.getAt(i)), + eatingMealName: mealTypes[i], + selectedMeal: castDynamicToListFood(box.get(mealTypes[i])), addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(), ); } diff --git a/lib/android/components/meals.dart b/lib/android/components/meals.dart index a0958e3..13cfcf0 100644 --- a/lib/android/components/meals.dart +++ b/lib/android/components/meals.dart @@ -16,12 +16,13 @@ class MealsComponent extends StatelessWidget { return ValueListenableBuilder( valueListenable: Hive.box(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN').listenable(), builder: (context, box, widget) { + final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired order of meal types return ListView.builder( primary: false, shrinkWrap: true, itemCount: box.keys.length, itemBuilder: (context, i) { - String mealTypeAsString = box.keyAt(i).toString(); + String mealTypeAsString = mealTypes[i]; return CardComponent( mealTypeAsString, StatisticsService.instance.getMealsOfTodayByMealtype(mealTypeAsString),