import 'package:ernaehrung/android/components/statistics_circular_indicator_component.dart';
import 'package:ernaehrung/android/config/cast_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:hive_flutter/adapters.dart';
import '../../android/components/card_component.dart';
import '../../android/components/diet_chart_component.dart';

class SectionComponent extends StatelessWidget {
  const SectionComponent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          const StatisticsPercentComponent(
            calorienLeftPercent: 0,
            eaten: 0,
            calorienBurned: 0,
            calorienLeft: 0,
          ),
          DietChatComponent(1500),
          ValueListenableBuilder(
              valueListenable: Hive.box("TODAY").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)),
                        );
                      }
                    });
              }),
        ],
      ),
    );
  }
}
