import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';

class IconSelectionDialog extends StatelessWidget {
  final List<String> spaceIconList;
  final Function(String selectedIcon) onIconSelected;

  const IconSelectionDialog({
    Key? key,
    required this.spaceIconList,
    required this.onIconSelected,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final screenHeight = MediaQuery.of(context).size.height;

    return Dialog(
      elevation: 0,
      backgroundColor: ColorsManager.transparentColor,
      child: Container(
        width: screenWidth * 0.44, 
        height: screenHeight * 0.45,
        decoration: BoxDecoration(
          color: ColorsManager.whiteColors,
          borderRadius: BorderRadius.circular(12),
          boxShadow: [
            BoxShadow(
              color: ColorsManager.blackColor.withOpacity(0.2), // Shadow color
              blurRadius: 20, // Spread of the blur
              offset: const Offset(0, 8), // Offset of the shadow
            ),
          ],
        ),
        child: AlertDialog(
          title: Text('Space Icon',style: Theme.of(context).textTheme.headlineMedium),
          backgroundColor: ColorsManager.whiteColors,
          content: Container(
            width: screenWidth * 0.4,
            height: screenHeight * 0.45,
            padding: const EdgeInsets.all(12),
            decoration: BoxDecoration(
              color: ColorsManager.boxColor,
              borderRadius: BorderRadius.circular(12),
            ),
            child: GridView.builder(
              gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 7,
                crossAxisSpacing: 8,
                mainAxisSpacing: 16,
              ),
              itemCount: spaceIconList.length,
              itemBuilder: (BuildContext context, int index) {
                return GestureDetector(
                  onTap: () {
                    onIconSelected(spaceIconList[index]);
                    Navigator.of(context).pop();
                  },
                  child: SvgPicture.asset(
                    spaceIconList[index],
                    width: screenWidth * 0.03,
                    height: screenWidth * 0.03,
                  ),
                );
              },
            ),
          ),
        ),
      ),
    );
  }
}
