import 'package:flutter/material.dart'; import '../theme/app_theme.dart'; class AppSearchField extends StatelessWidget { const AppSearchField({ super.key, required this.controller, required this.onChanged, this.hint, }); final TextEditingController controller; final ValueChanged onChanged; final String? hint; @override Widget build(BuildContext context) { return Container( color: AppColors.surface, padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), child: ListenableBuilder( listenable: controller, builder: (context, _) => Container( decoration: BoxDecoration( color: AppColors.surfaceVariant, borderRadius: BorderRadius.circular(12), border: Border.all(color: AppColors.border), ), child: TextField( controller: controller, onChanged: onChanged, style: const TextStyle( fontSize: 14, color: AppColors.textPrimary, ), decoration: InputDecoration( hintText: hint ?? 'Ara...', hintStyle: const TextStyle( color: AppColors.textMuted, fontSize: 14, ), prefixIcon: const Icon( Icons.search_rounded, color: AppColors.textMuted, size: 20, ), suffixIcon: controller.text.isNotEmpty ? GestureDetector( onTap: () { controller.clear(); onChanged(''); }, child: const Padding( padding: EdgeInsets.all(12), child: Icon( Icons.close_rounded, color: AppColors.textMuted, size: 16, ), ), ) : null, border: InputBorder.none, contentPadding: const EdgeInsets.symmetric(vertical: 12), ), ), ), ), ); } }