feat: sort meals

main
98spag 2023-06-16 12:17:23 +02:00
parent 98b45aabca
commit 2e22914cc2
2 changed files with 5 additions and 3 deletions

View File

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

View File

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