import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class CustomRectangleChip extends StatelessWidget {
  final String text;
  final double? height;
  final double? width;
  final Color bgColor;
  final Color textColor;
  final Function() onHistoryItemDeleted;
  final Function() onHistoryItemTapped;

  const CustomRectangleChip({
    super.key,
    this.bgColor = MyColors.chipColor,
    required this.text,
    this.textColor = MyColors.darkTextColor,
    this.width,
    this.height = 28,
    required this.onHistoryItemDeleted,
    required this.onHistoryItemTapped,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
      color: bgColor,
      height: height,
      child: Row(
        children: [
          text.toText(fontSize: 15, color: MyColors.darkTextColor, fontWeight: MyFonts.Medium),
          8.width,
          Container(
            height: 15,
            width: 15,
            decoration: const BoxDecoration(
              shape: BoxShape.circle,
              color: MyColors.roundedCrossBgColor,
            ),
            child: const Icon(Icons.close, color: MyColors.white, size: 10),
          ).onPress(onHistoryItemDeleted),
        ],
      ),
    ).onPress(onHistoryItemTapped);
  }
}
