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 'package:terepi_seged/widgets/map_edit_tools/color_row_extended.dart';
import 'package:terepi_seged/widgets/map_edit_tools/note_audio_widget.dart';
import 'package:terepi_seged/widgets/map_edit_tools/note_photo_gallery.dart';

import 'color_row.dart';
import 'label_field.dart';
import 'opacity_slider.dart';
import 'save_sheet_actions.dart';
import 'sheet_handle.dart';
import 'stroke_slider.dart';

class MapFeatureSaveSheet extends StatelessWidget {
  final MapSurveyController ctrl;
  final ScrollController scrollCtrl;
  const MapFeatureSaveSheet({
    required this.ctrl,
    required this.scrollCtrl,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Theme.of(context).colorScheme.surface,
        borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.15),
            blurRadius: 16,
            offset: const Offset(0, -4),
          ),
        ],
      ),
      child: CustomScrollView(
        controller: scrollCtrl,
        slivers: [
          SliverToBoxAdapter(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // Handle
                SheetHandle(),

                Padding(
                  padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text(
                        'Stílus',
                        style: TextStyle(
                            fontSize: 18, fontWeight: FontWeight.w600),
                      ),
                      const SizedBox(height: 16),
                      // ColorRow(ctrl: ctrl),
                      ColorRowExtended(ctrl: ctrl),
                      const SizedBox(height: 18),
                      OpacitySlider(ctrl: ctrl),
                      const SizedBox(height: 10),
                      Obx(() => ctrl.activeEditTool.value != MapEditTool.point
                          ? Column(children: [
                              StrokeSlider(ctrl: ctrl),
                              const SizedBox(
                                height: 1,
                              )
                            ])
                          : const SizedBox.shrink()),
                      LabelField(ctrl: ctrl),
                      const SizedBox(height: 16),
                      NotePhotoGallery(noteItemId: ctrl.editingNoteItemId),
                      const SizedBox(height: 16),
                      NoteAudioWidget(noteItemId: ctrl.editingNoteItemId),
                      const SizedBox(height: 24),
                      SaveSheetActions(ctrl: ctrl),
                      SizedBox(
                          height: MediaQuery.of(context).padding.bottom + 12),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
