import 'package:ernaehrung/pages/nav_pages/subpages/progress_page/sub_components/charts/sub_components/charts/progress_circular_chart.dart';
import 'package:ernaehrung/pages/nav_pages/subpages/progress_page/sub_components/charts/sub_components/charts/progress_horizontal_chart.dart';
import 'package:flutter/material.dart';
import '../../../../../../../../services/statistics.dart';

class ProgressChartsComponent extends StatelessWidget {
  final double heightStatisticsContainer = 220.0;
  final double widthStatisticsContainer = double.infinity;

  const ProgressChartsComponent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<List<double>>(
        valueListenable: DataService.instance.ingredients,
        builder: (context, value, child) {
          return Container(
            height: heightStatisticsContainer,
            padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  child: SizedBox(
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          vertical: 0, horizontal: 8),
                      child: FittedBox(
                        child: ProgressCircularChartComponent(value[6].toInt()),
                      ),
                    ),
                  ),
                ),
                Expanded(
                    child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    // TODO adjust 200 to values from user box
                    ProgressHorizontalChartComponent(Colors.lightGreen, value[0],
                        value[3].toInt(), "Fat (g)"),
                    ProgressHorizontalChartComponent(Colors.lightGreen, value[1],
                        value[4].toInt(), "Protein (g)"),
                    ProgressHorizontalChartComponent(Colors.lightGreen, value[2],
                        value[5].toInt(), "Carbohydrate (g)"),
                  ],
                ))
              ],
            ),
          );
        });
  }
}
