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
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
_initWorker();
|
_initWorker();
|
||||||
|
_registerSearchFocusListener();
|
||||||
super.onInit();
|
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() {
|
void _clearWorker() {
|
||||||
accountIdWorker.call();
|
accountIdWorker.call();
|
||||||
viewStateWorker.call();
|
viewStateWorker.call();
|
||||||
@@ -396,13 +408,13 @@ class MailboxController extends BaseMailboxController {
|
|||||||
searchState.value = searchState.value.enableSearchState();
|
searchState.value = searchState.value.enableSearchState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void disableSearch(BuildContext context) {
|
void disableSearch() {
|
||||||
_cancelSelectMailbox();
|
_cancelSelectMailbox();
|
||||||
listMailboxSearched.clear();
|
listMailboxSearched.clear();
|
||||||
searchState.value = searchState.value.disableSearchState();
|
searchState.value = searchState.value.disableSearchState();
|
||||||
searchQuery.value = SearchQuery.initial();
|
searchQuery.value = SearchQuery.initial();
|
||||||
searchInputController.clear();
|
searchInputController.clear();
|
||||||
FocusScope.of(context).unfocus();
|
searchFocus.unfocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearSearchText() {
|
void clearSearchText() {
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ class MailboxView extends GetWidget<MailboxController> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 5),
|
padding: EdgeInsets.only(left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 5),
|
||||||
child: buildIconWeb(
|
child: buildIconWeb(
|
||||||
onTap: () => controller.disableSearch(context),
|
onTap: () => controller.disableSearch(),
|
||||||
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ class MailboxView extends GetWidget<MailboxController> with AppLoaderMixin, Popu
|
|||||||
minSize: 40,
|
minSize: 40,
|
||||||
splashRadius: 15,
|
splashRadius: 15,
|
||||||
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
icon: SvgPicture.asset(_imagePaths.icBack, color: AppColor.colorTextButton),
|
||||||
onTap: () => controller.disableSearch(context)),
|
onTap: () => controller.disableSearch()),
|
||||||
Expanded(child: (SearchAppBarWidget(
|
Expanded(child: (SearchAppBarWidget(
|
||||||
_imagePaths,
|
_imagePaths,
|
||||||
controller.searchQuery.value,
|
controller.searchQuery.value,
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
_registerNetworkConnectivityState();
|
_registerNetworkConnectivityState();
|
||||||
_registerPendingEmailAddress();
|
_registerPendingEmailAddress();
|
||||||
|
_registerSearchFocusListener();
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +225,17 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _registerSearchFocusListener() {
|
||||||
|
searchFocus.addListener(() {
|
||||||
|
final hasFocus = searchFocus.hasFocus;
|
||||||
|
final query = searchQuery?.value;
|
||||||
|
log('MailboxDashBoardController::_registerSearchFocusListener(): hasFocus: $hasFocus | query: $query');
|
||||||
|
if (!hasFocus && (query == null || query.isEmpty)) {
|
||||||
|
disableSearch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _getUserProfile() async {
|
void _getUserProfile() async {
|
||||||
userProfile.value = sessionCurrent != null ? UserProfile(sessionCurrent!.username.value) : null;
|
userProfile.value = sessionCurrent != null ? UserProfile(sessionCurrent!.username.value) : null;
|
||||||
}
|
}
|
||||||
@@ -300,7 +312,7 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
searchInputController.clear();
|
searchInputController.clear();
|
||||||
listFilterQuickSearch.clear();
|
listFilterQuickSearch.clear();
|
||||||
emailReceiveTimeType.value = null;
|
emailReceiveTimeType.value = null;
|
||||||
FocusManager.instance.primaryFocus?.unfocus();
|
searchFocus.unfocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearTextSearch() {
|
void clearTextSearch() {
|
||||||
@@ -309,6 +321,10 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
searchFocus.requestFocus();
|
searchFocus.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onChangeTextSearch(String value) {
|
||||||
|
searchQuery = SearchQuery(value);
|
||||||
|
}
|
||||||
|
|
||||||
void updateTextSearch(String value) {
|
void updateTextSearch(String value) {
|
||||||
searchInputController.text = value;
|
searchInputController.text = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,6 +420,10 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
|||||||
}
|
}
|
||||||
controller.searchEmail(context, keyword);
|
controller.searchEmail(context, keyword);
|
||||||
},
|
},
|
||||||
|
onChanged: (query) {
|
||||||
|
log('MailboxDashBoardView::_buildSearchForm(): onChanged: $query');
|
||||||
|
controller.onChangeTextSearch(query);
|
||||||
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
focusedBorder: InputBorder.none,
|
focusedBorder: InputBorder.none,
|
||||||
|
|||||||
Reference in New Issue
Block a user