TF-452 Fix search boxes should be collapsed automatically when search inputs lost focus

This commit is contained in:
dab246
2022-06-15 12:17:47 +07:00
committed by Dat H. Pham
parent f0c6055dc1
commit e4a0855738
5 changed files with 37 additions and 5 deletions
@@ -117,6 +117,7 @@ class MailboxController extends BaseMailboxController {
@override
void onInit() {
_initWorker();
_registerSearchFocusListener();
super.onInit();
}
@@ -234,6 +235,17 @@ class MailboxController extends BaseMailboxController {
});
}
void _registerSearchFocusListener() {
searchFocus.addListener(() {
final hasFocus = searchFocus.hasFocus;
final query = searchQuery.value.value;
log('MailboxController::_registerSearchFocusListener(): hasFocus: $hasFocus | query: $query');
if (!hasFocus && query.isEmpty) {
disableSearch();
}
});
}
void _clearWorker() {
accountIdWorker.call();
viewStateWorker.call();
@@ -396,13 +408,13 @@ class MailboxController extends BaseMailboxController {
searchState.value = searchState.value.enableSearchState();
}
void disableSearch(BuildContext context) {
void disableSearch() {
_cancelSelectMailbox();
listMailboxSearched.clear();
searchState.value = searchState.value.disableSearchState();
searchQuery.value = SearchQuery.initial();
searchInputController.clear();
FocusScope.of(context).unfocus();
searchFocus.unfocus();
}
void clearSearchText() {