Flutter-Ernaehrungsapp/lib/android/components/food_list_component.dart

35 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:ernaehrung/android/config/cast_helper.dart';
2023-06-01 12:14:23 +02:00
import 'package:ernaehrung/android/config/statistics.dart';
2023-05-29 12:08:46 +02:00
import 'package:flutter/cupertino.dart';
import 'package:hive_flutter/adapters.dart';
import 'card_component.dart';
class FoodComponent extends StatelessWidget {
final Box box;
const FoodComponent({super.key, required this.box});
2023-05-29 12:08:46 +02:00
@override
Widget build(BuildContext context) {
2023-05-29 12:08:46 +02:00
return ValueListenableBuilder(
valueListenable: box.listenable(),
2023-05-29 12:08:46 +02:00
builder: (context, box, widget) {
2023-06-16 12:17:23 +02:00
final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired orde
2023-05-29 12:08:46 +02:00
return ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: box.keys.length,
itemBuilder: (context, i) {
2023-06-16 11:44:42 +02:00
return CardComponent(
2023-06-16 12:17:23 +02:00
eatingMealName: mealTypes[i],
selectedMeal: castDynamicToListFood(box.get(mealTypes[i])),
2023-06-16 11:44:42 +02:00
addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(),
);
}
);
2023-05-29 12:08:46 +02:00
});
}
2023-05-29 12:08:46 +02:00
}