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_edit_line_or_polygon_drawing_content.dart';
import 'map_edit_point_drawing_content.dart';

class MapEditDrawingToolbar extends StatelessWidget {
  final MapSurveyController controller;

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

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

      if (tool == MapEditTool.none) {
        return const SizedBox.shrink();
      }

      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.97),
            borderRadius: BorderRadius.circular(22),
            clipBehavior: Clip.antiAlias,
            child: Container(
              constraints: const BoxConstraints(
                maxWidth: 560,
              ),
              padding: const EdgeInsets.fromLTRB(10, 8, 10, 8),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(22),
                border: Border.all(
                  color:
                      Theme.of(context).colorScheme.outline.withOpacity(0.22),
                ),
              ),
              child: tool == MapEditTool.point
                  ? PointDrawingContent(controller: controller)
                  : LineOrPolygonDrawingContent(controller: controller),
            ),
          ),
        ),
      );
    });
  }
}
