TF-452 Fix search boxes should be collapsed automatically when search inputs lost focus
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -333,7 +333,7 @@ class MailboxView extends GetWidget<MailboxController> {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 5),
|
||||
child: buildIconWeb(
|
||||
onTap: () => controller.disableSearch(context),
|
||||
onTap: () => controller.disableSearch(),
|
||||
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class MailboxView extends GetWidget<MailboxController> with AppLoaderMixin, Popu
|
||||
minSize: 40,
|
||||
splashRadius: 15,
|
||||
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
||||
onTap: () => controller.disableSearch(context)),
|
||||
onTap: () => controller.disableSearch()),
|
||||
Expanded(child: (SearchAppBarWidget(
|
||||
_imagePaths,
|
||||
controller.searchQuery.value,
|
||||
|
||||
Reference in New Issue
Block a user