import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_days.dart';
import 'package:syncrow_web/utils/color_manager.dart';

class OccupancyHeatMapMonths extends StatelessWidget {
  const OccupancyHeatMapMonths({
    required this.startDate,
    required this.cellSize,
    super.key,
  });

  final DateTime startDate;
  final double cellSize;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 48,
      width: double.infinity,
      color: Colors.transparent,
      child: Row(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          OccupancyHeatMapDays(
            cellSize: cellSize / 3,
            textColor: Colors.transparent,
          ),
          ...List.generate(12, (monthIndex) {
            final monthStartDate = DateTime(startDate.year, monthIndex + 1, 1);
            final monthName = DateFormat.MMM().format(monthStartDate);
            return Expanded(
              child: RotatedBox(
                quarterTurns: 3,
                child: Container(
                  padding: EdgeInsetsDirectional.zero,
                  margin: EdgeInsetsDirectional.zero,
                  decoration: const BoxDecoration(
                    border: Border(
                      top: BorderSide(color: ColorsManager.borderColor),
                    ),
                  ),
                  width: cellSize * 4,
                  child: Padding(
                    padding: const EdgeInsets.only(left: 4, top: 2),
                    child: Text(
                      monthName,
                      style: const TextStyle(fontSize: 8),
                    ),
                  ),
                ),
              ),
            );
          }),
        ],
      ),
    );
  }
}
