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 selectedMailbox = Rxn<PresentationMailbox>();
|
||||||
final newNameMailbox = Rxn<String>();
|
final newNameMailbox = Rxn<String>();
|
||||||
|
bool _createdMailbox = false;
|
||||||
|
|
||||||
FocusNode? nameInputFocusNode;
|
FocusNode? nameInputFocusNode;
|
||||||
TextEditingController? nameInputController;
|
TextEditingController? nameInputController;
|
||||||
@@ -77,19 +78,6 @@ class MailboxCreatorController extends BaseController {
|
|||||||
super.onClose();
|
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) {
|
MailboxNode? _findMailboxNodeById(MailboxId mailboxId) {
|
||||||
final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId)
|
final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId)
|
||||||
?? personalMailboxTree?.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) {
|
String? getErrorInputNameString(BuildContext context) {
|
||||||
final nameMailbox = newNameMailbox.value;
|
final nameMailbox = newNameMailbox.value;
|
||||||
|
final canCheckNameString = _createdMailbox && nameInputFocusNode?.hasFocus == false;
|
||||||
if (nameInputFocusNode?.hasFocus == false && nameMailbox == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _verifyNameInteractor.execute(
|
return _verifyNameInteractor.execute(
|
||||||
nameMailbox,
|
nameMailbox,
|
||||||
[
|
[
|
||||||
EmptyNameValidator(),
|
if (canCheckNameString)
|
||||||
|
EmptyNameValidator(),
|
||||||
DuplicateNameValidator(listMailboxNameAsStringExist),
|
DuplicateNameValidator(listMailboxNameAsStringExist),
|
||||||
]
|
]
|
||||||
).fold(
|
).fold(
|
||||||
(failure) {
|
(failure) {
|
||||||
if (failure is VerifyNameFailure) {
|
if (failure is VerifyNameFailure) {
|
||||||
|
_createdMailbox = false;
|
||||||
return failure.getMessage(context);
|
return failure.getMessage(context);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -199,7 +186,13 @@ class MailboxCreatorController extends BaseController {
|
|||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
|
|
||||||
final nameMailbox = newNameMailbox.value;
|
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(
|
final newMailboxArguments = NewMailboxArguments(
|
||||||
MailboxName(nameMailbox),
|
MailboxName(nameMailbox),
|
||||||
mailboxLocation: selectedMailbox.value);
|
mailboxLocation: selectedMailbox.value);
|
||||||
|
|||||||
@@ -100,13 +100,13 @@ class MailboxCreatorView extends GetWidget<MailboxCreatorController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAppBar(BuildContext context) {
|
Widget _buildAppBar(BuildContext context) {
|
||||||
return Obx(() => (AppBarMailboxCreatorBuilder(
|
return (AppBarMailboxCreatorBuilder(
|
||||||
context,
|
context,
|
||||||
title: AppLocalizations.of(context).new_mailbox,
|
title: AppLocalizations.of(context).new_mailbox,
|
||||||
isValidated: controller.isCreateMailboxValidated(context))
|
isValidated: true)
|
||||||
..addOnCancelActionClick(() => controller.closeMailboxCreator(context))
|
..addOnCancelActionClick(() => controller.closeMailboxCreator(context))
|
||||||
..addOnDoneActionClick(() => controller.createNewMailbox(context)))
|
..addOnDoneActionClick(() => controller.createNewMailbox(context)))
|
||||||
.build());
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCreateMailboxNameInput(BuildContext context) {
|
Widget _buildCreateMailboxNameInput(BuildContext context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user