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)))