diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index c40a39156..b16836aff 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -503,8 +503,10 @@ class ComposerController extends BaseController { _updateStatusEmailSendButton(); } - void updateListEmailAddress(PrefixEmailAddress prefixEmailAddress, - List newListEmailAddress) { + void updateListEmailAddress( + PrefixEmailAddress prefixEmailAddress, + List newListEmailAddress + ) { switch(prefixEmailAddress) { case PrefixEmailAddress.to: listToEmailAddress = List.from(newListEmailAddress); diff --git a/lib/features/composer/presentation/widgets/email_address_input_builder.dart b/lib/features/composer/presentation/widgets/email_address_input_builder.dart index 758686947..ca49ff485 100644 --- a/lib/features/composer/presentation/widgets/email_address_input_builder.dart +++ b/lib/features/composer/presentation/widgets/email_address_input_builder.dart @@ -148,6 +148,7 @@ class EmailAddressInputBuilder { suggestionsBoxRadius: 20, suggestionsBoxMaxHeight: 300, textStyle: const TextStyle(color: AppColor.colorEmailAddress, fontSize: 14, fontWeight: FontWeight.w500), + onDeleteTagAction: () => _handleDeleteTagAction(setState), onSubmitted: (value) { log('EmailAddressInputBuilder::_buildTagEditor(): onSubmitted: $value'); if (!_isDuplicatedRecipient(value)) { @@ -326,11 +327,8 @@ class EmailAddressInputBuilder { return []; } - final currentTextOnTextField = controller?.text ?? ''; - log('EmailAddressInputBuilder::_findSuggestions():currentTextOnTextField: $currentTextOnTextField'); final processedQuery = query.trim(); - - if (processedQuery.isEmpty || currentTextOnTextField.isEmpty) { + if (processedQuery.isEmpty) { return []; } @@ -343,6 +341,11 @@ class EmailAddressInputBuilder { tmailSuggestion.addAll(_matchedSuggestionEmailAddress(processedQuery, listEmailAddress)); + final currentTextOnTextField = controller?.text ?? ''; + if (currentTextOnTextField.isEmpty) { + return []; + } + return tmailSuggestion; } @@ -374,4 +377,27 @@ class EmailAddressInputBuilder { void _handleGapBetweenTagChangedAndFindSuggestion() { log('EmailAddressInputBuilder::_handleGapBetweenTagChangedAndFindSuggestion(): Timeout'); } + + void _handleDeleteTagAction(StateSetter setState) { + log('EmailAddressInputBuilder::_handleDeleteTagAction()'); + if (listEmailAddress.isNotEmpty) { + setState(() { + final emailAddressDeleted = listEmailAddress.removeLast(); + + Future.delayed(const Duration(milliseconds: 10), () { + if (controller != null) { + controller!.text = emailAddressDeleted.emailAddress; + controller!.value = controller!.value.copyWith( + text: emailAddressDeleted.asString(), + selection: TextSelection( + baseOffset: emailAddressDeleted.asString().length, + extentOffset: emailAddressDeleted.asString().length + ) + ); + } + }); + }); + _onUpdateListEmailAddressAction?.call(_prefixEmailAddress, listEmailAddress); + } + } } \ No newline at end of file