From e0cf8272cf86359e15182ef3ec30fb15e12e3272 Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 22 Nov 2023 15:34:31 +0700 Subject: [PATCH] TF-2336 Fix jumping screen when clicking on Cc, Bcc Signed-off-by: dab246 (cherry picked from commit 376836017243e803ae056c085a2a0fb3756e2b15) --- .../presentation/composer_controller.dart | 33 ++-- .../composer/presentation/composer_view.dart | 145 ++++++++++-------- .../widgets/recipient_composer_widget.dart | 4 +- ...complete_contact_text_field_with_tags.dart | 2 +- ..._field_autocomplete_email_address_web.dart | 2 +- pubspec.lock | 2 +- 6 files changed, 107 insertions(+), 81 deletions(-) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index 37811e7b5..27c860d56 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -1699,18 +1699,12 @@ class ComposerController extends BaseController { switch(prefixEmailAddress) { case PrefixEmailAddress.to: toAddressExpandMode.value = ExpandMode.EXPAND; - ccAddressExpandMode.value = ExpandMode.COLLAPSE; - bccAddressExpandMode.value = ExpandMode.COLLAPSE; break; case PrefixEmailAddress.cc: ccAddressExpandMode.value = ExpandMode.EXPAND; - toAddressExpandMode.value = ExpandMode.COLLAPSE; - bccAddressExpandMode.value = ExpandMode.COLLAPSE; break; case PrefixEmailAddress.bcc: bccAddressExpandMode.value = ExpandMode.EXPAND; - toAddressExpandMode.value = ExpandMode.COLLAPSE; - ccAddressExpandMode.value = ExpandMode.COLLAPSE; break; default: break; @@ -1720,9 +1714,30 @@ class ComposerController extends BaseController { htmlEditorApi?.unfocus(); } } else { - if (PlatformInfo.isMobile) { - _collapseAllRecipient(); - _autoCreateEmailTag(); + switch(prefixEmailAddress) { + case PrefixEmailAddress.to: + toAddressExpandMode.value = ExpandMode.COLLAPSE; + final inputToEmail = toEmailAddressController.text; + if (inputToEmail.isNotEmpty) { + _autoCreateToEmailTag(inputToEmail); + } + break; + case PrefixEmailAddress.cc: + ccAddressExpandMode.value = ExpandMode.COLLAPSE; + final inputCcEmail = ccEmailAddressController.text; + if (inputCcEmail.isNotEmpty) { + _autoCreateCcEmailTag(inputCcEmail); + } + break; + case PrefixEmailAddress.bcc: + bccAddressExpandMode.value = ExpandMode.COLLAPSE; + final inputBccEmail = bccEmailAddressController.text; + if (inputBccEmail.isNotEmpty) { + _autoCreateBccEmailTag(inputBccEmail); + } + break; + default: + break; } } } diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index 75a12db60..c87da8ffb 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -93,81 +93,92 @@ class ComposerView extends GetWidget { physics: const ClampingScrollPhysics(), child: Column( children: [ - Obx(() => Column( - children: [ - if (controller.fromRecipientState.value == PrefixRecipientState.enabled) - FromComposerMobileWidget( - selectedIdentity: controller.identitySelected.value, - imagePaths: controller.imagePaths, - responsiveUtils: controller.responsiveUtils, - margin: ComposerStyle.mobileRecipientMargin, - padding: ComposerStyle.mobileRecipientPadding, - onTap: () => controller.openSelectIdentityBottomSheet(context) - ), - RecipientComposerWidget( - prefix: PrefixEmailAddress.to, - listEmailAddress: controller.listToEmailAddress, - fromState: controller.fromRecipientState.value, - ccState: controller.ccRecipientState.value, - bccState: controller.bccRecipientState.value, - expandMode: controller.toAddressExpandMode.value, - controller: controller.toEmailAddressController, - focusNode: controller.toAddressFocusNode, - keyTagEditor: controller.keyToEmailTagEditor, + Obx(() { + if (controller.fromRecipientState.value == PrefixRecipientState.enabled) { + return FromComposerMobileWidget( + selectedIdentity: controller.identitySelected.value, + imagePaths: controller.imagePaths, + responsiveUtils: controller.responsiveUtils, + margin: ComposerStyle.mobileRecipientMargin, + padding: ComposerStyle.mobileRecipientPadding, + onTap: () => controller.openSelectIdentityBottomSheet(context) + ); + } else { + return const SizedBox.shrink(); + } + }), + Obx(() => RecipientComposerWidget( + prefix: PrefixEmailAddress.to, + listEmailAddress: controller.listToEmailAddress, + fromState: controller.fromRecipientState.value, + ccState: controller.ccRecipientState.value, + bccState: controller.bccRecipientState.value, + expandMode: controller.toAddressExpandMode.value, + controller: controller.toEmailAddressController, + focusNode: controller.toAddressFocusNode, + keyTagEditor: controller.keyToEmailTagEditor, + isInitial: controller.isInitialRecipient.value, + padding: ComposerStyle.mobileRecipientPadding, + margin: ComposerStyle.mobileRecipientMargin, + nextFocusNode: controller.getNextFocusOfToEmailAddress(), + onFocusEmailAddressChangeAction: controller.onEmailAddressFocusChange, + onShowFullListEmailAddressAction: controller.showFullEmailAddress, + onAddEmailAddressTypeAction: controller.addEmailAddressType, + onUpdateListEmailAddressAction: controller.updateListEmailAddress, + onSuggestionEmailAddress: controller.getAutoCompleteSuggestion, + onFocusNextAddressAction: controller.handleFocusNextAddressAction, + onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.to), + )), + Obx(() { + if (controller.ccRecipientState.value == PrefixRecipientState.enabled) { + return RecipientComposerWidget( + prefix: PrefixEmailAddress.cc, + listEmailAddress: controller.listCcEmailAddress, + expandMode: controller.ccAddressExpandMode.value, + controller: controller.ccEmailAddressController, + focusNode: controller.ccAddressFocusNode, + keyTagEditor: controller.keyCcEmailTagEditor, isInitial: controller.isInitialRecipient.value, + nextFocusNode: controller.getNextFocusOfCcEmailAddress(), padding: ComposerStyle.mobileRecipientPadding, margin: ComposerStyle.mobileRecipientMargin, - nextFocusNode: controller.getNextFocusOfToEmailAddress(), onFocusEmailAddressChangeAction: controller.onEmailAddressFocusChange, onShowFullListEmailAddressAction: controller.showFullEmailAddress, - onAddEmailAddressTypeAction: controller.addEmailAddressType, + onDeleteEmailAddressTypeAction: controller.deleteEmailAddressType, onUpdateListEmailAddressAction: controller.updateListEmailAddress, onSuggestionEmailAddress: controller.getAutoCompleteSuggestion, onFocusNextAddressAction: controller.handleFocusNextAddressAction, - onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.to), - ), - if (controller.ccRecipientState.value == PrefixRecipientState.enabled) - RecipientComposerWidget( - prefix: PrefixEmailAddress.cc, - listEmailAddress: controller.listCcEmailAddress, - expandMode: controller.ccAddressExpandMode.value, - controller: controller.ccEmailAddressController, - focusNode: controller.ccAddressFocusNode, - keyTagEditor: controller.keyCcEmailTagEditor, - isInitial: controller.isInitialRecipient.value, - nextFocusNode: controller.getNextFocusOfCcEmailAddress(), - padding: ComposerStyle.mobileRecipientPadding, - margin: ComposerStyle.mobileRecipientMargin, - onFocusEmailAddressChangeAction: controller.onEmailAddressFocusChange, - onShowFullListEmailAddressAction: controller.showFullEmailAddress, - onDeleteEmailAddressTypeAction: controller.deleteEmailAddressType, - onUpdateListEmailAddressAction: controller.updateListEmailAddress, - onSuggestionEmailAddress: controller.getAutoCompleteSuggestion, - onFocusNextAddressAction: controller.handleFocusNextAddressAction, - onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.cc), - ), - if (controller.bccRecipientState.value == PrefixRecipientState.enabled) - RecipientComposerWidget( - prefix: PrefixEmailAddress.bcc, - listEmailAddress: controller.listBccEmailAddress, - expandMode: controller.bccAddressExpandMode.value, - controller: controller.bccEmailAddressController, - focusNode: controller.bccAddressFocusNode, - keyTagEditor: controller.keyBccEmailTagEditor, - isInitial: controller.isInitialRecipient.value, - nextFocusNode: controller.subjectEmailInputFocusNode, - padding: ComposerStyle.mobileRecipientPadding, - margin: ComposerStyle.mobileRecipientMargin, - onFocusEmailAddressChangeAction: controller.onEmailAddressFocusChange, - onShowFullListEmailAddressAction: controller.showFullEmailAddress, - onDeleteEmailAddressTypeAction: controller.deleteEmailAddressType, - onUpdateListEmailAddressAction: controller.updateListEmailAddress, - onSuggestionEmailAddress: controller.getAutoCompleteSuggestion, - onFocusNextAddressAction: controller.handleFocusNextAddressAction, - onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.bcc), - ), - ], - )), + onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.cc), + ); + } else { + return const SizedBox.shrink(); + } + }), + Obx(() { + if (controller.bccRecipientState.value == PrefixRecipientState.enabled) { + return RecipientComposerWidget( + prefix: PrefixEmailAddress.bcc, + listEmailAddress: controller.listBccEmailAddress, + expandMode: controller.bccAddressExpandMode.value, + controller: controller.bccEmailAddressController, + focusNode: controller.bccAddressFocusNode, + keyTagEditor: controller.keyBccEmailTagEditor, + isInitial: controller.isInitialRecipient.value, + nextFocusNode: controller.subjectEmailInputFocusNode, + padding: ComposerStyle.mobileRecipientPadding, + margin: ComposerStyle.mobileRecipientMargin, + onFocusEmailAddressChangeAction: controller.onEmailAddressFocusChange, + onShowFullListEmailAddressAction: controller.showFullEmailAddress, + onDeleteEmailAddressTypeAction: controller.deleteEmailAddressType, + onUpdateListEmailAddressAction: controller.updateListEmailAddress, + onSuggestionEmailAddress: controller.getAutoCompleteSuggestion, + onFocusNextAddressAction: controller.handleFocusNextAddressAction, + onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.bcc), + ); + } else { + return const SizedBox.shrink(); + } + }), SubjectComposerWidget( focusNode: controller.subjectEmailInputFocusNode, textController: controller.subjectEmailInputController, diff --git a/lib/features/composer/presentation/widgets/recipient_composer_widget.dart b/lib/features/composer/presentation/widgets/recipient_composer_widget.dart index deb0932c6..34649c79b 100644 --- a/lib/features/composer/presentation/widgets/recipient_composer_widget.dart +++ b/lib/features/composer/presentation/widgets/recipient_composer_widget.dart @@ -166,11 +166,11 @@ class _RecipientComposerWidgetState extends State { keyboardType: TextInputType.emailAddress, textInputAction: TextInputAction.done, debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration, - hasAddButton: false, tagSpacing: RecipientComposerWidgetStyle.tagSpacing, autofocus: widget.prefix != PrefixEmailAddress.to && _currentListEmailAddress.isEmpty, minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth, resetTextOnSubmitted: true, + autoScrollToInput: false, suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation, suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor, suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius, @@ -240,11 +240,11 @@ class _RecipientComposerWidgetState extends State { keyboardType: TextInputType.emailAddress, textInputAction: TextInputAction.done, debounceDuration: RecipientComposerWidgetStyle.suggestionDebounceDuration, - hasAddButton: false, tagSpacing: RecipientComposerWidgetStyle.tagSpacing, autofocus: widget.prefix != PrefixEmailAddress.to && _currentListEmailAddress.isEmpty, minTextFieldWidth: RecipientComposerWidgetStyle.minTextFieldWidth, resetTextOnSubmitted: true, + autoScrollToInput: false, suggestionsBoxElevation: RecipientComposerWidgetStyle.suggestionsBoxElevation, suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor, suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius, diff --git a/lib/features/contact/presentation/widgets/autocomplete_contact_text_field_with_tags.dart b/lib/features/contact/presentation/widgets/autocomplete_contact_text_field_with_tags.dart index 31231304c..b44736eb4 100644 --- a/lib/features/contact/presentation/widgets/autocomplete_contact_text_field_with_tags.dart +++ b/lib/features/contact/presentation/widgets/autocomplete_contact_text_field_with_tags.dart @@ -85,12 +85,12 @@ class _AutocompleteContactTextFieldWithTagsState extends State