import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:terepi_seged/core/style_editable.dart';
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';

class ColorRow extends StatelessWidget {
  final StyleEditable ctrl;
  final double circleSize;

  static const _palette = [
    Color(0xFF6C63FF),
    Color(0xFFE74C3C),
    Color(0xFF27AE60),
    Color(0xFFE91E8C),
    Color(0xFFE67E22),
    Color(0xFF3498DB),
    Color(0xFF8BC34A),
  ];
  const ColorRow({required this.ctrl, this.circleSize = 40});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text('Kitöltési szín',
            style: TextStyle(fontSize: 13, color: Colors.grey.shade600)),
        const SizedBox(height: 10),
        Obx(() => Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: _palette.map((color) {
                final sel = ctrl.activeEditColor.value == color;
                return GestureDetector(
                  onTap: () => ctrl.activeEditColor.value = color,
                  child: AnimatedContainer(
                    duration: const Duration(milliseconds: 150),
                    width: circleSize,
                    height: circleSize,
                    decoration: BoxDecoration(
                      color: color,
                      shape: BoxShape.circle,
                      border: Border.all(
                        color: sel
                            ? Theme.of(context).colorScheme.onSurface
                            : Colors.transparent,
                        width: 3,
                      ),
                      boxShadow: sel
                          ? [
                              BoxShadow(
                                  color: color.withOpacity(0.45),
                                  blurRadius: 8,
                                  spreadRadius: 2)
                            ]
                          : null,
                    ),
                  ),
                );
              }).toList(),
            )),
      ],
    );
  }
}
