2023-05-30 09:38:54 +02:00
|
|
|
import 'package:ernaehrung/android/config/cast_helper.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 {
|
2023-05-30 09:38:54 +02:00
|
|
|
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-30 09:38:54 +02:00
|
|
|
|
2023-05-29 12:08:46 +02:00
|
|
|
return ValueListenableBuilder(
|
2023-05-30 09:38:54 +02:00
|
|
|
valueListenable: box.listenable(),
|
2023-05-29 12:08:46 +02:00
|
|
|
builder: (context, box, widget) {
|
|
|
|
return ListView.builder(
|
|
|
|
primary: false,
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: box.keys.length,
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
if (box.keyAt(i).toString() == "DATE") {
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
} else {
|
|
|
|
return CardComponent(
|
|
|
|
eatingMealName: box.keyAt(i).toString(),
|
2023-05-30 09:38:54 +02:00
|
|
|
selectedMeal: castDynamicToListFood(box.getAt(i)),
|
|
|
|
addButtonVisible: box.name != 'statistics_reduced',
|
|
|
|
);
|
2023-05-29 12:08:46 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2023-05-30 09:38:54 +02:00
|
|
|
|
|
|
|
|
2023-05-29 12:08:46 +02:00
|
|
|
}
|