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

class SpaceCell extends StatelessWidget {
  final String icon;
  final String name;
  final VoidCallback? onTap;

  const SpaceCell({
    super.key,
    required this.icon,
    required this.name,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: 150,
        height: 70,
        decoration: _containerDecoration(),
        child: Row(
          children: [
            _buildIconContainer(),
            const SizedBox(width: 10),
            Expanded(
              child: Text(
                name,
                style: context.textTheme.bodyLarge?.copyWith(
                  fontWeight: FontWeight.bold,
                  color: ColorsManager.blackColor,
                ),
                overflow: TextOverflow.ellipsis,
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildIconContainer() {
    return Container(
      width: 40,
      height: double.infinity,
      decoration: const BoxDecoration(
        color: ColorsManager.spaceColor,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(15),
          bottomLeft: Radius.circular(15),
        ),
      ),
      child: Center(
        child: SvgPicture.asset(
          icon,
          colorFilter: const ColorFilter.mode(
            ColorsManager.whiteColors,
            BlendMode.srcIn,
          ),
          width: 24,
          height: 24,
        ),
      ),
    );
  }

  BoxDecoration _containerDecoration() {
    return BoxDecoration(
      color: ColorsManager.whiteColors,
      borderRadius: BorderRadius.circular(15),
      boxShadow: [
        BoxShadow(
          color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
          spreadRadius: 2,
          blurRadius: 5,
          offset: const Offset(0, 3),
        ),
      ],
    );
  }
}
