37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
import 'package:ernaehrung/android/config/cast_helper.dart';
|
|
import 'package:ernaehrung/android/config/statistics.dart';
|
|
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});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return ValueListenableBuilder(
|
|
valueListenable: box.listenable(),
|
|
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(),
|
|
selectedMeal: castDynamicToListFood(box.getAt(i)),
|
|
addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(),
|
|
);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
}
|