fix: accent in searchbar frontend
This commit is contained in:
parent
41b68a00bb
commit
82caca3276
@ -18,6 +18,7 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
late SearchController _searchBarController;
|
||||
String _rawSearchInput = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -26,9 +27,9 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
||||
_tabController.addListener(_handleTabIndex);
|
||||
_searchBarController = SearchController();
|
||||
_searchBarController.addListener(() {
|
||||
// Sync _searchController with SearchController in real-time
|
||||
if (_searchController.text != _searchBarController.text) {
|
||||
_searchController.text = _searchBarController.text;
|
||||
_rawSearchInput = _searchBarController.text;
|
||||
_searchController.text = _rawSearchInput;
|
||||
_onSearchChanged(_searchBarController.text);
|
||||
}
|
||||
});
|
||||
@ -44,6 +45,7 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
||||
void _clearSearch() {
|
||||
_searchController.clear();
|
||||
_searchBarController.clear();
|
||||
_rawSearchInput = '';
|
||||
_onSearchChanged('');
|
||||
}
|
||||
|
||||
@ -162,14 +164,14 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
||||
const SizedBox(width: 8.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_searchController.text.isEmpty
|
||||
_rawSearchInput.isEmpty
|
||||
? 'Search contacts'
|
||||
: _searchController.text,
|
||||
: _rawSearchInput,
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 16.0),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (_searchController.text.isNotEmpty)
|
||||
if (_rawSearchInput.isNotEmpty)
|
||||
GestureDetector(
|
||||
onTap: _clearSearch,
|
||||
child: const Icon(
|
||||
@ -184,9 +186,11 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
||||
);
|
||||
},
|
||||
viewOnChanged: (query) {
|
||||
// Update immediately as you type
|
||||
|
||||
if (_searchBarController.text != query) {
|
||||
_rawSearchInput = query;
|
||||
_searchBarController.text = query;
|
||||
_searchController.text = query;
|
||||
}
|
||||
_onSearchChanged(query);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user