import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:terepi_seged/widgets/map_edit_tools/style_editable.dart';

import 'color_row.dart';
import 'opacity_slider.dart';
import 'stroke_slider.dart';

class ImportedLayerStyleSheet extends StatelessWidget {
  final String layerName;
  final LayerStyleSession session; // ← a közös interfész implementációja
  final VoidCallback onSave;
  final VoidCallback onReset;

  const ImportedLayerStyleSheet({
    required this.layerName,
    required this.session,
    required this.onSave,
    required this.onReset,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(
          20, 16, 20, MediaQuery.of(context).padding.bottom + 16),
      decoration: BoxDecoration(
        color: Theme.of(context).colorScheme.surface,
        borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Handle
          Center(
              child: Container(
            width: 40,
            height: 4,
            margin: const EdgeInsets.only(bottom: 16),
            decoration: BoxDecoration(
                color: Colors.grey.shade300,
                borderRadius: BorderRadius.circular(2)),
          )),

          Text(layerName,
              style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
              overflow: TextOverflow.ellipsis),
          const SizedBox(height: 20),

          // ── Meglévő widgetek — ismerős felület ──────────────────
          ColorRow(ctrl: session), // ← ugyanaz mint a geometriáknál
          const SizedBox(height: 18),
          OpacitySlider(ctrl: session),
          const SizedBox(height: 10),
          StrokeSlider(ctrl: session),
          const SizedBox(height: 24),

          // Gombok
          Row(children: [
            OutlinedButton(
              onPressed: () {
                onReset();
                Get.back();
              },
              child: const Text('Visszaállítás'),
            ),
            const Spacer(),
            FilledButton(
              onPressed: () {
                onSave();
                Get.back();
              },
              child: const Text('Alkalmaz'),
            ),
          ]),
        ],
      ),
    );
  }
}
