import 'package:flutter/material.dart'; class SearchAppBar extends StatefulWidget { const SearchAppBar({ super.key, this.onMenuPressed, this.onSearchChanged, this.searchHint = 'Buscar notas...', }); final VoidCallback? onMenuPressed; final ValueChanged? onSearchChanged; final String searchHint; @override State createState() => _SearchAppBarState(); } class _SearchAppBarState extends State { late TextEditingController _searchController; @override void initState() { super.initState(); _searchController = TextEditingController(); } @override void dispose() { _searchController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( color: const Color.fromRGBO(31, 32, 33, 1), border: Border( bottom: BorderSide( color: Colors.white.withValues(alpha: 0.12), width: 0.5, ), ), ), padding: const EdgeInsets.only(left: 16, right: 16, top: 7, bottom: 7), child: Row( children: [ // Menu button (fixed on left) IconButton( onPressed: widget.onMenuPressed, icon: const Icon(Icons.menu, color: Colors.white70, size: 20), tooltip: 'MenĂº', splashRadius: 18, constraints: const BoxConstraints(minWidth: 40, minHeight: 40), ), const SizedBox(width: 8), // Search input (centered with max width) Expanded( child: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 600), child: TextField( controller: _searchController, onChanged: widget.onSearchChanged, style: const TextStyle(color: Colors.white, fontSize: 13), cursorColor: Colors.white70, decoration: InputDecoration( hintText: widget.searchHint, hintStyle: TextStyle( color: Colors.white.withValues(alpha: 0.5), ), prefixIcon: const Icon( Icons.search, color: Colors.white70, size: 18, ), suffixIcon: _searchController.text.isNotEmpty ? IconButton( icon: const Icon( Icons.clear, color: Colors.white70, size: 18, ), onPressed: () { _searchController.clear(); widget.onSearchChanged?.call(''); }, constraints: const BoxConstraints( minWidth: 36, minHeight: 36, ), ) : null, border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( color: Colors.white.withValues(alpha: 0.2), width: 0.5, ), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( color: Colors.white.withValues(alpha: 0.2), width: 0.5, ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( color: Colors.white.withValues(alpha: 0.4), width: 0.5, ), ), filled: true, fillColor: Colors.white.withValues(alpha: 0.05), contentPadding: const EdgeInsets.symmetric( horizontal: 12, vertical: 8, ), isDense: true, ), ), ), ), ), ], ), ); } }