TF-3952 Clear recipient input focus after perform any actions

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-08-08 09:30:50 +07:00
committed by Dat H. Pham
parent f8d93e738b
commit b72048788a
2 changed files with 31 additions and 4 deletions
@@ -1,7 +1,7 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/keyboard_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/platform_info.dart';
import 'package:flutter/material.dart';
import 'package:forward/forward/tmail_forward.dart';
import 'package:get/get.dart';
@@ -119,6 +119,8 @@ class ForwardController extends BaseController {
}
void deleteRecipients(BuildContext context, String emailAddress) {
clearInputFocus();
showConfirmDialogAction(
context,
title: AppLocalizations.of(context).deleteRecipient,
@@ -180,6 +182,8 @@ class ForwardController extends BaseController {
});
void selectRecipientForward(RecipientForward recipientForward) {
clearInputFocus();
if (selectionMode.value == SelectMode.INACTIVE) {
selectionMode.value = SelectMode.ACTIVE;
}
@@ -204,6 +208,8 @@ class ForwardController extends BaseController {
}
void deleteMultipleRecipients(BuildContext context, Set<String> listEmailAddress) {
clearInputFocus();
showConfirmDialogAction(
context,
title: AppLocalizations.of(context).deleteRecipient,
@@ -228,7 +234,7 @@ class ForwardController extends BaseController {
}
void addRecipientAction(BuildContext context, List<EmailAddress> listRecipientsSelected) {
KeyboardUtils.hideKeyboard(context);
clearInputFocus();
final accountId = accountDashBoardController.accountId.value;
if (accountId != null) {
@@ -263,6 +269,8 @@ class ForwardController extends BaseController {
}
void handleEditLocalCopy() {
clearInputFocus();
final accountId = accountDashBoardController.accountId.value;
if (accountId != null &&
currentForward.value != null &&
@@ -320,4 +328,10 @@ class ForwardController extends BaseController {
: BannerState.disabled;
log('ForwardController::_updateForwardWarningBannerState: forwardWarningBannerState = ${forwardWarningBannerState.value}');
}
void clearInputFocus() {
if (PlatformInfo.isMobile) {
FocusManager.instance.primaryFocus?.unfocus();
}
}
}
@@ -1,6 +1,7 @@
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/utils/platform_info.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
@@ -26,7 +27,7 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
Widget build(BuildContext context) {
final isWebDesktop = controller.responsiveUtils.isWebDesktop(context);
return Column(
final bodyWidget = Column(
children: [
Obx(() {
if (controller.forwardWarningBannerState.value == BannerState.enabled) {
@@ -128,6 +129,15 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
),
],
);
if (PlatformInfo.isMobile) {
return GestureDetector(
onTap: controller.clearInputFocus,
child: bodyWidget,
);
} else {
return bodyWidget;
}
}
EdgeInsetsGeometry _getScrollViewPadding(
@@ -147,7 +157,10 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
return Obx(() => controller.viewState.value.fold(
(failure) => const SizedBox.shrink(),
(success) => success is LoadingState
? loadingWidget
? Padding(
padding: const EdgeInsets.only(top: 8.0),
child: loadingWidget,
)
: const SizedBox.shrink()
));
}