import 'package:flutter/material.dart';

import '../../../../common/data/report_menu.dart';
import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart';
import '../../spaces/space.dart';

class ReportHeader extends StatelessWidget {
  final ReportMenu menu;
  final DateTime endDate;
  final DateTime startDate;
  const ReportHeader({
    super.key,
    required this.menu,
    required this.endDate,
    required this.startDate,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              menu.title,
              style: AppStyle.xl.copyWith(
                fontWeight: FontWeight.bold,
                color: AppColor.textPrimary,
              ),
            ),
            const SpaceHeight(4),
            Text(
              menu.subtitle,
              style: AppStyle.md.copyWith(color: AppColor.textSecondary),
            ),
          ],
        ),
        Container(
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
          decoration: BoxDecoration(
            color: AppColor.primary,
            borderRadius: BorderRadius.circular(8),
          ),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              const Icon(Icons.calendar_today, color: Colors.white, size: 16),
              const SizedBox(width: 8),
              Text(
                startDate.toSimpleMonthDate() == endDate.toSimpleMonthDate()
                    ? startDate.toSimpleMonthDate()
                    : '${startDate.toSimpleMonthDate()} - ${endDate.toSimpleMonthDate()}',
                style: AppStyle.sm.copyWith(
                  color: Colors.white,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
