import 'package:flutter/material.dart';
import 'package:iconsax/iconsax.dart';
import 'package:sigap/src/utils/constants/colors.dart';
import 'package:sigap/src/utils/constants/sizes.dart';
import 'package:sigap/src/utils/device/device_utility.dart';
import 'package:sigap/src/utils/helpers/helper_functions.dart';

class SearchContainer extends StatelessWidget {
  const SearchContainer({
    super.key,
    required this.text,
    this.icon,
    this.showBackground = true,
    this.showBorder = true,
    this.onTap,
    this.padding = const EdgeInsets.symmetric(horizontal: TSizes.defaultSpace),
  });

  final String text;
  final IconData? icon;
  final bool showBackground, showBorder;
  final VoidCallback? onTap;
  final EdgeInsetsGeometry padding;

  @override
  Widget build(BuildContext context) {
    final dark = THelperFunctions.isDarkMode(context);

    return GestureDetector(
      onTap: onTap,
      child: Padding(
        padding: padding,
        child: Container(
          width: TDeviceUtils.getScreenWidth(context),
          padding: const EdgeInsets.all(TSizes.md),
          decoration: BoxDecoration(
            color:
                showBackground
                    ? dark
                        ? TColors.black
                        : TColors.light
                    : TColors.transparent,
            borderRadius: BorderRadius.circular(TSizes.cardRadiusLg),
            border: showBorder ? Border.all(color: TColors.darkGrey) : null,
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Icon(icon ?? Iconsax.search_normal, color: TColors.primary),
                  const SizedBox(width: TSizes.spaceBtwItems),
                  Text(
                    text,
                    style: Theme.of(
                      context,
                    ).textTheme.bodySmall!.apply(color: TColors.darkGrey),
                  ),
                ],
              ),
              const Icon(Icons.filter_list, color: TColors.primary),
            ],
          ),
        ),
      ),
    );
  }
}
