import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';

class SubspaceChip extends StatelessWidget {
  const SubspaceChip({
    required this.subSpace,
    required this.isDuplicate,
    super.key,
    required this.onDeleted,
  });

  final SubspaceTemplateModel subSpace;
  final bool isDuplicate;
  final void Function() onDeleted;

  @override
  Widget build(BuildContext context) {
    return Chip(
      label: Text(
        subSpace.subspaceName,
        style: context.textTheme.bodySmall?.copyWith(
          color: isDuplicate ? ColorsManager.red : ColorsManager.spaceColor,
        ),
      ),
      backgroundColor: ColorsManager.whiteColors,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
        side: BorderSide(
          color: isDuplicate ? ColorsManager.red : ColorsManager.transparentColor,
          width: 0,
        ),
      ),
      deleteIcon: Container(
        padding: const EdgeInsetsDirectional.all(1),
        decoration: BoxDecoration(
          shape: BoxShape.circle,
          border: Border.all(
            color: ColorsManager.lightGrayColor,
            width: 1.5,
          ),
        ),
        child: const FittedBox(
          fit: BoxFit.scaleDown,
          child: Icon(
            Icons.close,
            color: ColorsManager.lightGrayColor,
          ),
        ),
      ),
      onDeleted: onDeleted,
    );
  }
}
