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