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

import 'map_toolbar_action.dart';
import 'map_toolbar_divider.dart';

class MapEditCompactToolbar extends StatelessWidget {
  final MapSurveyController controller;

  const MapEditCompactToolbar({
    super.key,
    required this.controller,
  });

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      final activeTool = controller.activeEditTool.value;

      return SafeArea(
        top: false,
        minimum: const EdgeInsets.fromLTRB(10, 0, 10, 10),
        child: Align(
          alignment: Alignment.bottomCenter,
          child: Material(
            elevation: 8,
            color: Theme.of(context).colorScheme.surface.withOpacity(0.96),
            borderRadius: BorderRadius.circular(22),
            clipBehavior: Clip.antiAlias,
            child: Container(
              constraints: const BoxConstraints(
                maxWidth: 520,
              ),
              padding: const EdgeInsets.symmetric(
                horizontal: 6,
                vertical: 6,
              ),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(22),
                border: Border.all(
                  color:
                      Theme.of(context).colorScheme.outline.withOpacity(0.22),
                ),
              ),
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  ToolbarAction(
                    icon: Icons.add_location_alt_outlined,
                    label: 'Pont',
                    selected: activeTool == MapEditTool.point,
                    onTap: controller.startPointTool,
                  ),
                  ToolbarAction(
                    icon: Icons.polyline_outlined,
                    label: 'Vonal',
                    selected: activeTool == MapEditTool.line,
                    onTap: controller.startLineTool,
                  ),
                  ToolbarAction(
                    icon: Icons.border_outer_outlined,
                    label: 'Terület',
                    selected: activeTool == MapEditTool.polygon,
                    onTap: controller.startPolygonTool,
                  ),
                  const ToolbarDivider(),
                  ToolbarAction(
                    icon: Icons.list_alt_outlined,
                    label: 'Lista',
                    selected: false,
                    onTap: () {},
                  ),
                  ToolbarAction(
                    icon: Icons.layers_outlined,
                    label: 'Rétegek',
                    selected: false,
                    onTap: () {},
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    });
  }
}
