From 63d1b6584f47f140ec67909822f6118d7d834b7f Mon Sep 17 00:00:00 2001 From: dab246 Date: Thu, 7 Apr 2022 09:56:22 +0700 Subject: [PATCH] TF-354 Remove the real time validate of the mailbox name field --- .../mailbox_creator_controller.dart | 17 +++++++++++++++++ .../presentation/mailbox_creator_view.dart | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/features/mailbox_creator/presentation/mailbox_creator_controller.dart b/lib/features/mailbox_creator/presentation/mailbox_creator_controller.dart index 5992182b1..e2b0e8f23 100644 --- a/lib/features/mailbox_creator/presentation/mailbox_creator_controller.dart +++ b/lib/features/mailbox_creator/presentation/mailbox_creator_controller.dart @@ -29,6 +29,8 @@ class MailboxCreatorController extends BaseController { final selectedMailbox = Rxn(); final newNameMailbox = Rxn(); + final nameInputFocusNode = FocusNode(); + AccountId? accountId; MailboxTree? folderMailboxTree; MailboxTree? defaultMailboxTree; @@ -66,8 +68,19 @@ class MailboxCreatorController extends BaseController { @override void onError(error) {} + @override + void onClose() { + nameInputFocusNode.dispose(); + super.onClose(); + } + bool isCreateMailboxValidated(BuildContext context) { final nameValidated = getErrorInputNameString(context); + + if (!nameInputFocusNode.hasFocus && newNameMailbox.value == null) { + return false; + } + if (nameValidated?.isNotEmpty == true) { return false; } @@ -101,6 +114,10 @@ class MailboxCreatorController extends BaseController { String? getErrorInputNameString(BuildContext context) { final nameMailbox = newNameMailbox.value; + if (!nameInputFocusNode.hasFocus && nameMailbox == null) { + return null; + } + return _verifyNameInteractor.execute( nameMailbox, [ diff --git a/lib/features/mailbox_creator/presentation/mailbox_creator_view.dart b/lib/features/mailbox_creator/presentation/mailbox_creator_view.dart index d12da066d..40cbb853e 100644 --- a/lib/features/mailbox_creator/presentation/mailbox_creator_view.dart +++ b/lib/features/mailbox_creator/presentation/mailbox_creator_view.dart @@ -112,8 +112,8 @@ class MailboxCreatorView extends GetWidget { ..onChange((value) => controller.setNewNameMailbox(value)) ..keyboardType(TextInputType.visiblePassword) ..cursorColor(AppColor.colorTextButton) - ..autoFocus(true) ..textStyle(TextStyle(color: AppColor.colorNameEmail, fontSize: 16)) + ..addFocusNode(controller.nameInputFocusNode) ..textDecoration((CreateMailboxNameInputDecorationBuilder() ..setHintText(AppLocalizations.of(context).hint_input_create_new_mailbox) ..setErrorText(controller.getErrorInputNameString(context)))