import 'package:flutter/cupertino.dart';
import 'package:hive_flutter/adapters.dart';
import '../../../../../../helper/cast_helper.dart';
import '../../../../../../services/statistics.dart';
import 'progress_card.dart';

class ProgressFoodListComponent extends StatelessWidget {
  final Box box;
  const ProgressFoodListComponent({super.key, required this.box});

  @override
  Widget build(BuildContext context) {

    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 ProgressCardComponent(
                  eatingMealName: mealTypes[i],
                  selectedMeal: castDynamicToListFood(box.get(mealTypes[i])),
                  addButtonVisible: box.name != DataService.instance.progressBoxName.toLowerCase(),
              );
            }
              );
        });
  }


}
