import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';

class OccupancyHeatMapGradient extends StatelessWidget {
  const OccupancyHeatMapGradient({super.key, required this.maxValue});

  final int maxValue;
  List<Color> _heatMapColors() {
    if (maxValue == 0) {
      return [
        ColorsManager.vividBlue.withValues(alpha: 0),
        ColorsManager.vividBlue.withValues(alpha: 0),
      ];
    }
    return List.generate(
      maxValue + 1,
      (index) => ColorsManager.vividBlue.withValues(alpha: index / maxValue),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        const Spacer(),
        Tooltip(
          message: 'Min: 0 - Max: $maxValue',
          child: Container(
            width: 150,
            height: 20,
            decoration: BoxDecoration(
              border: Border.all(
                color: ColorsManager.grayBorder,
                width: 1,
              ),
              gradient: LinearGradient(
                begin: AlignmentDirectional.centerStart,
                end: AlignmentDirectional.centerEnd,
                colors: _heatMapColors(),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
