2023-06-16 08:34:41 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
|
|
import 'package:hive_flutter/adapters.dart';
|
|
|
|
|
|
|
|
import '../config/statistics.dart';
|
|
|
|
import 'card/card_component.dart';
|
|
|
|
|
|
|
|
class MealsComponent extends StatelessWidget {
|
|
|
|
MealsComponent({Key? key}) : super(key: key);
|
2023-06-16 12:26:07 +02:00
|
|
|
final List<Color> colors = [Colors.green,Colors.lightGreen,CupertinoColors.systemGreen];
|
2023-06-16 08:34:41 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ValueListenableBuilder(
|
|
|
|
valueListenable: Hive.box(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN').listenable(),
|
|
|
|
builder: (context, box, widget) {
|
2023-06-16 12:17:23 +02:00
|
|
|
final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired order of meal types
|
2023-06-16 08:34:41 +02:00
|
|
|
return ListView.builder(
|
|
|
|
primary: false,
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: box.keys.length,
|
|
|
|
itemBuilder: (context, i) {
|
2023-06-16 12:17:23 +02:00
|
|
|
String mealTypeAsString = mealTypes[i];
|
2023-06-16 08:34:41 +02:00
|
|
|
return CardComponent(
|
|
|
|
mealTypeAsString,
|
|
|
|
StatisticsService.instance.getMealsOfTodayByMealtype(mealTypeAsString),
|
|
|
|
color: colors[i],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|