TF-1562: Fix don't show msg when close PopUp
(cherry picked from commit 2e16b5d56aed8dee778a84eeeb2a2079049c2448)
This commit is contained in:
@@ -29,6 +29,7 @@ class MailboxCreatorController extends BaseController {
|
||||
|
||||
final selectedMailbox = Rxn<PresentationMailbox>();
|
||||
final newNameMailbox = Rxn<String>();
|
||||
bool _createdMailbox = false;
|
||||
|
||||
FocusNode? nameInputFocusNode;
|
||||
TextEditingController? nameInputController;
|
||||
@@ -77,19 +78,6 @@ class MailboxCreatorController extends BaseController {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool isCreateMailboxValidated(BuildContext context) {
|
||||
final nameValidated = getErrorInputNameString(context);
|
||||
|
||||
if (nameInputFocusNode?.hasFocus == false && newNameMailbox.value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nameValidated?.isNotEmpty == true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MailboxNode? _findMailboxNodeById(MailboxId mailboxId) {
|
||||
final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId)
|
||||
?? personalMailboxTree?.findNode((node) => node.item.id == mailboxId)
|
||||
@@ -126,20 +114,19 @@ class MailboxCreatorController extends BaseController {
|
||||
|
||||
String? getErrorInputNameString(BuildContext context) {
|
||||
final nameMailbox = newNameMailbox.value;
|
||||
|
||||
if (nameInputFocusNode?.hasFocus == false && nameMailbox == null) {
|
||||
return null;
|
||||
}
|
||||
final canCheckNameString = _createdMailbox && nameInputFocusNode?.hasFocus == false;
|
||||
|
||||
return _verifyNameInteractor.execute(
|
||||
nameMailbox,
|
||||
[
|
||||
EmptyNameValidator(),
|
||||
if (canCheckNameString)
|
||||
EmptyNameValidator(),
|
||||
DuplicateNameValidator(listMailboxNameAsStringExist),
|
||||
]
|
||||
).fold(
|
||||
(failure) {
|
||||
if (failure is VerifyNameFailure) {
|
||||
_createdMailbox = false;
|
||||
return failure.getMessage(context);
|
||||
} else {
|
||||
return null;
|
||||
@@ -199,7 +186,13 @@ class MailboxCreatorController extends BaseController {
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
final nameMailbox = newNameMailbox.value;
|
||||
if (nameMailbox != null && nameMailbox.isNotEmpty) {
|
||||
final nameValidated = getErrorInputNameString(context);
|
||||
|
||||
if (nameValidated == null) {
|
||||
_createdMailbox = true;
|
||||
}
|
||||
|
||||
if (nameMailbox != null && nameMailbox.isNotEmpty && _createdMailbox) {
|
||||
final newMailboxArguments = NewMailboxArguments(
|
||||
MailboxName(nameMailbox),
|
||||
mailboxLocation: selectedMailbox.value);
|
||||
|
||||
@@ -100,13 +100,13 @@ class MailboxCreatorView extends GetWidget<MailboxCreatorController> {
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
return Obx(() => (AppBarMailboxCreatorBuilder(
|
||||
context,
|
||||
title: AppLocalizations.of(context).new_mailbox,
|
||||
isValidated: controller.isCreateMailboxValidated(context))
|
||||
..addOnCancelActionClick(() => controller.closeMailboxCreator(context))
|
||||
..addOnDoneActionClick(() => controller.createNewMailbox(context)))
|
||||
.build());
|
||||
return (AppBarMailboxCreatorBuilder(
|
||||
context,
|
||||
title: AppLocalizations.of(context).new_mailbox,
|
||||
isValidated: true)
|
||||
..addOnCancelActionClick(() => controller.closeMailboxCreator(context))
|
||||
..addOnDoneActionClick(() => controller.createNewMailbox(context)))
|
||||
.build();
|
||||
}
|
||||
|
||||
Widget _buildCreateMailboxNameInput(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user