import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/plus_button_widget.dart';

class SpaceCardWidget extends StatefulWidget {
  final void Function() onTap;
  final Widget Function() buildSpaceContainer;

  const SpaceCardWidget({
    required this.onTap,
    required this.buildSpaceContainer,
    super.key,
  });

  @override
  State<SpaceCardWidget> createState() => _SpaceCardWidgetState();
}

class _SpaceCardWidgetState extends State<SpaceCardWidget> {
  bool isHovered = false;
  @override
  Widget build(BuildContext context) {
    return MouseRegion(
      onEnter: (_) => setState(() => isHovered = true),
      onExit: (_) => setState(() => isHovered = false),
      child: SizedBox(
        child: Stack(
          clipBehavior: Clip.none,
          alignment: Alignment.center,
          children: [
            widget.buildSpaceContainer(),
            if (isHovered)
              Positioned(
                bottom: 0,
                child: PlusButtonWidget(
                  offset: Offset.zero,
                  onButtonTap: widget.onTap,
                ),
              ),
          ],
        ),
      ),
    );
  }
}
