import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:sizer/sizer.dart';

class CustomSearch extends StatelessWidget {
  final String hintText;
  final FocusNode searchFocusNode;
  final Color searchIconColor;
  final Function(String) onChanged;
  
  const CustomSearch({
    super.key,
    required this.hintText,
    required this.searchFocusNode,
    required this.searchIconColor,
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 4.w, vertical: 1.h),
      child: TextField(
        focusNode: searchFocusNode,
        onChanged: onChanged,
        style: TextStyle(
          color: searchIconColor,
          fontWeight: FontWeight.w500,
          fontSize: isTablet ? AppFontSize.medium.sp : AppFontSize.small.sp,
        ),
        decoration: InputDecoration(
          hintText: hintText,
          hintStyle: TextStyle(
            color: Colors.grey,
            fontSize: isTablet ? AppFontSize.medium.sp : AppFontSize.small.sp,
          ),
          prefixIcon: Icon(Icons.search, color: searchIconColor, size: 6.w),
          enabledBorder: const UnderlineInputBorder(
            borderSide: BorderSide(color: Colors.grey),
          ),
          focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(color: AppColor.primaryColor),
          ),
          contentPadding: EdgeInsets.symmetric(vertical: 4.h),
        ),
      ),
    );
  }
}
