mirrored_repositories/Expenses_Tracker_App/lib/screens
import 'package:expenses_tracker/bloc/get_expenses_bloc/get_expenses_bloc.dart';
import 'package:expenses_tracker/screens/graph/chart.dart';
import 'package:expenses_tracker/utils/constants/colors.dart';
import 'package:expenses_tracker/utils/constants/sizes.dart';
import 'package:expenses_tracker/utils/constants/texts.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class Statistics extends StatefulWidget {
  const Statistics({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _StatisticsState createState() => _StatisticsState();
}

class _StatisticsState extends State<Statistics> {
  List day = ["Day", "Week", "Month", "Year"];
  int indexColor = 0;
  @override
  Widget build(BuildContext context) {
    return BlocBuilder<GetExpensesBloc, GetExpensesState>(
      builder: (context, state) {
        return Scaffold(
          body: SafeArea(
            child: CustomScrollView(
              slivers: [
                SliverToBoxAdapter(
                  child: Column(
                    children: [
                      const SizedBox(height: ESizes.paddingXl),
                      Text(
                        "Statistics",
                        style: Theme.of(context).textTheme.headlineMedium,
                      ),
                      const SizedBox(height: ESizes.paddingXl),
                      Padding(
                        padding:
                            const EdgeInsets.symmetric(horizontal: ESizes.md),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            ...List.generate(4, (index) {
                              return GestureDetector(
                                onTap: () {
                                  setState(() {
                                    indexColor = index;
                                  });
                                },
                                child: Container(
                                  height: 40,
                                  width: 80,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(
                                        ESizes.borderRadiusXl),
                                    color: indexColor == index
                                        ? EColors.primary
                                        : Colors.transparent,
                                  ),
                                  alignment: Alignment.center,
                                  child: Text(
                                    day[index],
                                    style: Theme.of(context)
                                        .textTheme
                                        .titleMedium!
                                        .apply(
                                          color: indexColor == index
                                              ? EColors.white
                                              : EColors.black,
                                        ),
                                  ),
                                ),
                              );
                            })
                          ],
                        ),
                      ),
                      const SizedBox(height: ESizes.paddingXl),
                      Padding(
                        padding:
                            const EdgeInsets.symmetric(horizontal: ESizes.md),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            Container(
                              width: 120,
                              height: 40,
                              decoration: BoxDecoration(
                                border: Border.all(
                                    color: EColors.darkGrey, width: 2),
                                borderRadius: BorderRadius.circular(ESizes.sm),
                              ),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceAround,
                                children: [
                                  Text(
                                    ETexts.expenses,
                                    style: Theme.of(context)
                                        .textTheme
                                        .titleLarge!
                                        .apply(color: EColors.darkGrey),
                                  ),
                                  const Icon(
                                    Icons.arrow_downward_outlined,
                                    color: EColors.darkGrey,
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                      const SizedBox(height: ESizes.paddingXl),
                      const Chart(),
                    ],
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
