diff --git a/lib/features/contact/presentation/contact_controller.dart b/lib/features/contact/presentation/contact_controller.dart index 2d243e1f52..af32226f39 100644 --- a/lib/features/contact/presentation/contact_controller.dart +++ b/lib/features/contact/presentation/contact_controller.dart @@ -1,5 +1,6 @@ import 'package:core/presentation/utils/keyboard_utils.dart'; +import 'package:core/presentation/utils/theme_utils.dart'; import 'package:core/utils/app_logger.dart'; import 'package:core/utils/platform_info.dart'; import 'package:debounce_throttle/debounce_throttle.dart'; @@ -31,6 +32,7 @@ class ContactController extends BaseController { final searchQuery = SearchQuery.initial().obs; final session = Rxn(); final listContactSearched = RxList(); + final contactArguments = Rxn(); GetAllAutoCompleteInteractor? _getAllAutoCompleteInteractor; GetAutoCompleteInteractor? _getAutoCompleteInteractor; @@ -39,7 +41,6 @@ class ContactController extends BaseController { final Debouncer _deBouncerTime = Debouncer(const Duration(milliseconds: 300), initialValue: ''); AccountId? _accountId; - ContactArguments? arguments; EmailAddress? contactSelected; SelectedContactCallbackAction? onSelectedContactCallback; VoidCallback? onDismissContactView; @@ -47,8 +48,9 @@ class ContactController extends BaseController { @override void onInit() { super.onInit(); + ThemeUtils.setStatusBarTransparentColor(); log('ContactController::onInit():arguments: ${Get.arguments}'); - arguments = Get.arguments; + contactArguments.value = Get.arguments; _deBouncerTime.values.listen((value) { searchQuery.value = SearchQuery(value); _searchContactByNameOrEmail(searchQuery.value.value); @@ -56,15 +58,13 @@ class ContactController extends BaseController { } @override - void onReady() async { + void onReady() { super.onReady(); - log('ContactController::onReady():'); textInputSearchFocus.requestFocus(); - if (arguments != null) { - _accountId = arguments!.accountId; - session.value = arguments!.session; - final listContactSelected = arguments!.listContactSelected; - log('ContactController::onReady(): arguments: $arguments'); + if (contactArguments.value != null) { + _accountId = contactArguments.value!.accountId; + session.value = contactArguments.value!.session; + final listContactSelected = contactArguments.value!.listContactSelected; log('ContactController::onReady(): listContactSelected: $listContactSelected'); if (listContactSelected.isNotEmpty) { contactSelected = EmailAddress(listContactSelected.first, listContactSelected.first); @@ -167,9 +167,11 @@ class ContactController extends BaseController { popBack(result: emailAddress); } - void closeContactView(BuildContext context) { - clearAllTextInputSearchForm(); - KeyboardUtils.hideKeyboard(context); + void closeContactView() { + textInputSearchController.clear(); + searchQuery.value = SearchQuery.initial(); + textInputSearchFocus.unfocus(); + FocusManager.instance.primaryFocus?.unfocus(); popBack(); } } \ No newline at end of file diff --git a/lib/features/contact/presentation/contact_view.dart b/lib/features/contact/presentation/contact_view.dart index fe2e23dcee..9b77b966d2 100644 --- a/lib/features/contact/presentation/contact_view.dart +++ b/lib/features/contact/presentation/contact_view.dart @@ -8,6 +8,7 @@ import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:tmail_ui_user/features/composer/presentation/model/suggestion_email_address.dart'; import 'package:tmail_ui_user/features/contact/presentation/contact_controller.dart'; +import 'package:tmail_ui_user/features/contact/presentation/styles/contact_view_style.dart'; import 'package:tmail_ui_user/features/contact/presentation/utils/contact_utils.dart'; import 'package:tmail_ui_user/features/contact/presentation/widgets/app_bar_contact_widget.dart'; import 'package:tmail_ui_user/features/contact/presentation/widgets/contact_suggestion_box_item.dart'; @@ -16,9 +17,6 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; class ContactView extends GetWidget { - final _maxHeight = 656.0; - final _maxWidth = 556.0; - const ContactView({super.key}); @override @@ -32,140 +30,149 @@ class ContactView extends GetWidget { bottom: false, left: false, right: false, - top: ContactUtils.supportAppBarTopBorder(context, controller.responsiveUtils), + top: ContactViewStyle.isAppBarTopBorderSupported( + context, + controller.responsiveUtils + ), child: Center( child: Container( - height: _getHeightContactView(context), - width: _getWidthContactView(context), + height: ContactViewStyle.getContactViewHeight( + context, + controller.responsiveUtils + ), + width: ContactViewStyle.getContactViewWidth( + context, + controller.responsiveUtils + ), decoration: BoxDecoration( - borderRadius: _getRadiusContactView(context), + borderRadius: ContactViewStyle.getContactViewBorderRadius( + context, + controller.responsiveUtils + ), color: Colors.white ), - child: ClipRRect( - borderRadius: _getRadiusContactView(context), - child: SafeArea(child: Container( - color: Colors.white, - child: Column(children: [ - Container( - height: 52, - color: Colors.white, - padding: ContactUtils.getPaddingAppBar(context, controller.responsiveUtils), - child: AppBarContactWidget( - onCloseContactView: () => controller.closeContactView(context)) - ), - const Divider(color: AppColor.colorDividerComposer, height: 1), - SearchAppBarWidget( - imagePaths: controller.imagePaths, - searchQuery: controller.searchQuery.value, - searchFocusNode: controller.textInputSearchFocus, - searchInputController: controller.textInputSearchController, - hasBackButton: false, - hasSearchButton: true, - margin: ContactUtils.getPaddingSearchInputForm(context, controller.responsiveUtils), - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10)), - color: AppColor.colorBgSearchBar), - iconClearText: SvgPicture.asset( - controller.imagePaths.icClearTextSearch, - width: 18, - height: 18, - fit: BoxFit.fill), - hintText: AppLocalizations.of(context).hintSearchInputContact, - onClearTextSearchAction: controller.clearAllTextInputSearchForm, - onTextChangeSearchAction: controller.onTextSearchChange, - onSearchTextAction: controller.onSearchTextAction, - ), - if (PlatformInfo.isWeb) - Obx(() { - final username = controller.session.value?.username.value ?? ''; - if (username.isNotEmpty) { - final userEmailAddress = EmailAddress( - AppLocalizations.of(context).me, - username); - final fromMeSuggestionEmailAddress = SuggestionEmailAddress(userEmailAddress, state: SuggestionEmailState.valid); - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Column( - children: [ - ContactSuggestionBoxItem( - fromMeSuggestionEmailAddress, - padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), - selectedContactCallbackAction: (contact) { - controller.selectContact(context, contact); - }, - ), - Padding( - padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), - child: const Divider(height: 1, color: AppColor.colorDivider), - ), - ], - ), - ); - } else { - return const SizedBox.shrink(); - } - }), - Expanded(child: Obx(() { - if (controller.listContactSearched.isNotEmpty) { - if (PlatformInfo.isMobile) { - return Container( - color: Colors.white, - child: ListView.separated( - itemCount: controller.listContactSearched.length, - separatorBuilder: (context, index) { - return Padding( - padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), - child: const Divider(height: 1, color: AppColor.colorDivider), - ); + clipBehavior: Clip.antiAlias, + child: SafeArea( + child: Column( + children: [ + Obx(() => AppBarContactWidget( + title: controller.contactArguments.value?.contactViewTitle, + imagePaths: controller.imagePaths, + responsiveUtils: controller.responsiveUtils, + onCloseContactView: controller.closeContactView, + )), + SearchAppBarWidget( + imagePaths: controller.imagePaths, + searchQuery: controller.searchQuery.value, + searchFocusNode: controller.textInputSearchFocus, + searchInputController: controller.textInputSearchController, + hasBackButton: false, + hasSearchButton: true, + margin: ContactUtils.getPaddingSearchInputForm(context, controller.responsiveUtils), + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: AppColor.colorBgSearchBar), + iconClearText: SvgPicture.asset( + controller.imagePaths.icClearTextSearch, + width: 18, + height: 18, + fit: BoxFit.fill), + hintText: AppLocalizations.of(context).hintSearchInputContact, + onClearTextSearchAction: controller.clearAllTextInputSearchForm, + onTextChangeSearchAction: controller.onTextSearchChange, + onSearchTextAction: controller.onSearchTextAction, + ), + if (PlatformInfo.isWeb) + Obx(() { + final username = controller.session.value?.username.value ?? ''; + if (username.isNotEmpty) { + final userEmailAddress = EmailAddress( + AppLocalizations.of(context).me, + username); + final fromMeSuggestionEmailAddress = SuggestionEmailAddress(userEmailAddress, state: SuggestionEmailState.valid); + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Column( + children: [ + ContactSuggestionBoxItem( + fromMeSuggestionEmailAddress, + padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), + selectedContactCallbackAction: (contact) { + controller.selectContact(context, contact); }, - itemBuilder: (context, index) { - final emailAddress = controller.listContactSearched[index]; - final suggestionEmailAddress = _toSuggestionEmailAddress( - emailAddress, - controller.contactSelected != null ? [controller.contactSelected!] : [] - ); - return ContactSuggestionBoxItem( - suggestionEmailAddress, - padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), - selectedContactCallbackAction: (contact) => controller.selectContact(context, contact), - ); - } - ) - ); - } else { - return Container( - color: Colors.white, - padding: const EdgeInsets.symmetric(horizontal: 4), - child: ListView.separated( - itemCount: controller.listContactSearched.length, - separatorBuilder: (context, index) { - return Padding( - padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), - child: const Divider(height: 1, color: AppColor.colorDivider), - ); - }, - itemBuilder: (context, index) { - final emailAddress = controller.listContactSearched[index]; - final suggestionEmailAddress = _toSuggestionEmailAddress( - emailAddress, - controller.contactSelected != null ? [controller.contactSelected!] : [] - ); - return ContactSuggestionBoxItem( - suggestionEmailAddress, - padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), - selectedContactCallbackAction: (contact) => controller.selectContact(context, contact), - ); - } - ) - ); - } - } else { - return const SizedBox.shrink(); - } - })), - ]), - )) - ) + ), + Padding( + padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), + child: const Divider(height: 1, color: AppColor.colorDivider), + ), + ], + ), + ); + } else { + return const SizedBox.shrink(); + } + }), + Expanded(child: Obx(() { + if (controller.listContactSearched.isNotEmpty) { + if (PlatformInfo.isMobile) { + return Container( + color: Colors.white, + child: ListView.separated( + itemCount: controller.listContactSearched.length, + separatorBuilder: (context, index) { + return Padding( + padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), + child: const Divider(height: 1, color: AppColor.colorDivider), + ); + }, + itemBuilder: (context, index) { + final emailAddress = controller.listContactSearched[index]; + final suggestionEmailAddress = _toSuggestionEmailAddress( + emailAddress, + controller.contactSelected != null ? [controller.contactSelected!] : [] + ); + return ContactSuggestionBoxItem( + suggestionEmailAddress, + padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), + selectedContactCallbackAction: (contact) => controller.selectContact(context, contact), + ); + } + ) + ); + } else { + return Container( + color: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 4), + child: ListView.separated( + itemCount: controller.listContactSearched.length, + separatorBuilder: (context, index) { + return Padding( + padding: ContactUtils.getPaddingDividerSearchResultList(context, controller.responsiveUtils), + child: const Divider(height: 1, color: AppColor.colorDivider), + ); + }, + itemBuilder: (context, index) { + final emailAddress = controller.listContactSearched[index]; + final suggestionEmailAddress = _toSuggestionEmailAddress( + emailAddress, + controller.contactSelected != null ? [controller.contactSelected!] : [] + ); + return ContactSuggestionBoxItem( + suggestionEmailAddress, + padding: ContactUtils.getPaddingSearchResultList(context, controller.responsiveUtils), + selectedContactCallbackAction: (contact) => controller.selectContact(context, contact), + ); + } + ) + ); + } + } else { + return const SizedBox.shrink(); + } + })), + ] + ), + ) ), ), ), @@ -174,71 +181,6 @@ class ContactView extends GetWidget { ); } - BorderRadius _getRadiusContactView(BuildContext context) { - if (PlatformInfo.isMobile && controller.responsiveUtils.isLandscapeMobile(context)) { - return BorderRadius.zero; - } else if (controller.responsiveUtils.isMobile(context)) { - return BorderRadius.only( - topRight: Radius.circular( - ContactUtils.getRadiusBorderAppBarTop( - context, - controller.responsiveUtils - ) - ), - topLeft: Radius.circular( - ContactUtils.getRadiusBorderAppBarTop( - context, - controller.responsiveUtils - ) - ) - ); - } else { - return const BorderRadius.all(Radius.circular(16)); - } - } - - double _getHeightContactView(BuildContext context) { - if (PlatformInfo.isWeb) { - if (controller.responsiveUtils.isMobile(context)) { - return double.infinity; - } else { - if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) { - return _maxHeight; - } else { - return double.infinity; - } - } - } else { - if (controller.responsiveUtils.isLandscapeMobile(context) || - controller.responsiveUtils.isPortraitMobile(context)) { - return double.infinity; - } else { - if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) { - return _maxHeight; - } else { - return double.infinity; - } - } - } - } - - double _getWidthContactView(BuildContext context) { - if (PlatformInfo.isWeb) { - if (controller.responsiveUtils.isMobile(context)) { - return double.infinity; - } else { - return _maxWidth; - } - } else { - if (controller.responsiveUtils.isLandscapeMobile(context) || - controller.responsiveUtils.isPortraitMobile(context)) { - return double.infinity; - } else { - return _maxWidth; - } - } - } - SuggestionEmailAddress _toSuggestionEmailAddress(EmailAddress item, List addedEmailAddresses) { if (addedEmailAddresses.contains(item)) { return SuggestionEmailAddress(item, state: SuggestionEmailState.duplicated); diff --git a/lib/features/contact/presentation/model/contact_arguments.dart b/lib/features/contact/presentation/model/contact_arguments.dart index 9dc5c8e511..1136062893 100644 --- a/lib/features/contact/presentation/model/contact_arguments.dart +++ b/lib/features/contact/presentation/model/contact_arguments.dart @@ -7,9 +7,20 @@ class ContactArguments with EquatableMixin { final AccountId accountId; final Session session; final Set listContactSelected; + final String? contactViewTitle; - ContactArguments(this.accountId, this.session, this.listContactSelected); + ContactArguments({ + required this.accountId, + required this.session, + required this.listContactSelected, + this.contactViewTitle + }); @override - List get props => [accountId, session, listContactSelected]; + List get props => [ + accountId, + session, + listContactSelected, + contactViewTitle, + ]; } \ No newline at end of file diff --git a/lib/features/contact/presentation/styles/app_bar_contact_widget_style.dart b/lib/features/contact/presentation/styles/app_bar_contact_widget_style.dart new file mode 100644 index 0000000000..e08f51b0b7 --- /dev/null +++ b/lib/features/contact/presentation/styles/app_bar_contact_widget_style.dart @@ -0,0 +1,21 @@ + +import 'package:core/presentation/utils/responsive_utils.dart'; +import 'package:core/utils/platform_info.dart'; +import 'package:flutter/material.dart'; + +class AppBarContactWidgetStyle { + static EdgeInsetsGeometry getAppBarPadding( + BuildContext context, + ResponsiveUtils responsiveUtils + ) { + if (PlatformInfo.isWeb) { + return const EdgeInsets.symmetric(horizontal: 16); + } else { + if (responsiveUtils.isScreenWithShortestSide(context)) { + return const EdgeInsets.symmetric(horizontal: 10); + } else { + return const EdgeInsets.symmetric(horizontal: 32); + } + } + } +} \ No newline at end of file diff --git a/lib/features/contact/presentation/styles/contact_view_style.dart b/lib/features/contact/presentation/styles/contact_view_style.dart new file mode 100644 index 0000000000..492ca058d5 --- /dev/null +++ b/lib/features/contact/presentation/styles/contact_view_style.dart @@ -0,0 +1,62 @@ + +import 'package:core/presentation/utils/responsive_utils.dart'; +import 'package:core/utils/platform_info.dart'; +import 'package:flutter/cupertino.dart'; + +class ContactViewStyle { + static const double viewMaxHeight = 624.0; + static const double viewMaxWidth = 558.0; + + static double getContactViewHeight( + BuildContext context, + ResponsiveUtils responsiveUtils + ) { + if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) || + (PlatformInfo.isMobile && responsiveUtils.isScreenWithShortestSide(context)) + ) { + return double.infinity; + } else if (responsiveUtils.getSizeScreenHeight(context) > ContactViewStyle.viewMaxHeight) { + return ContactViewStyle.viewMaxHeight; + } else { + return double.infinity; + } + } + + static double getContactViewWidth( + BuildContext context, + ResponsiveUtils responsiveUtils + ) { + if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) || + (PlatformInfo.isMobile && responsiveUtils.isScreenWithShortestSide(context)) + ) { + return double.infinity; + } else { + return ContactViewStyle.viewMaxWidth; + } + } + + static bool isAppBarTopBorderSupported( + BuildContext context, + ResponsiveUtils responsiveUtils + ) { + return !(PlatformInfo.isWeb || responsiveUtils.isLandscapeMobile(context)); + } + + static BorderRadiusGeometry getContactViewBorderRadius( + BuildContext context, + ResponsiveUtils responsiveUtils + ) { + if (PlatformInfo.isMobile && responsiveUtils.isLandscapeMobile(context)) { + return BorderRadius.zero; + } else if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) || + (PlatformInfo.isMobile && responsiveUtils.isPortraitMobile(context)) + ) { + return const BorderRadiusDirectional.only( + topEnd: Radius.circular(16), + topStart: Radius.circular(16), + ); + } else { + return const BorderRadius.all(Radius.circular(16)); + } + } +} \ No newline at end of file diff --git a/lib/features/contact/presentation/utils/contact_utils.dart b/lib/features/contact/presentation/utils/contact_utils.dart index 214731eefc..39adf0c3f1 100644 --- a/lib/features/contact/presentation/utils/contact_utils.dart +++ b/lib/features/contact/presentation/utils/contact_utils.dart @@ -4,18 +4,6 @@ import 'package:core/utils/platform_info.dart'; import 'package:flutter/material.dart'; class ContactUtils { - static EdgeInsets getPaddingAppBar(BuildContext context, ResponsiveUtils responsiveUtils) { - if (PlatformInfo.isWeb) { - return const EdgeInsets.symmetric(horizontal: 16); - } else { - if (responsiveUtils.isScreenWithShortestSide(context)) { - return const EdgeInsets.symmetric(horizontal: 10); - } else { - return const EdgeInsets.symmetric(horizontal: 32); - } - } - } - static EdgeInsets getPaddingSearchInputForm(BuildContext context, ResponsiveUtils responsiveUtils) { if (PlatformInfo.isWeb) { return const EdgeInsets.symmetric(horizontal: 16, vertical: 10); @@ -51,19 +39,4 @@ class ContactUtils { } } } - - static bool supportAppBarTopBorder(BuildContext context, ResponsiveUtils responsiveUtils) { - if (PlatformInfo.isWeb || responsiveUtils.isLandscapeMobile(context)) { - return false; - } - return true; - } - - static double getRadiusBorderAppBarTop(BuildContext context, ResponsiveUtils responsiveUtils) { - if (supportAppBarTopBorder(context, responsiveUtils)) { - return 16; - } else { - return 0; - } - } } \ No newline at end of file diff --git a/lib/features/contact/presentation/widgets/app_bar_contact_widget.dart b/lib/features/contact/presentation/widgets/app_bar_contact_widget.dart index de3a01ace4..679de2a617 100644 --- a/lib/features/contact/presentation/widgets/app_bar_contact_widget.dart +++ b/lib/features/contact/presentation/widgets/app_bar_contact_widget.dart @@ -1,48 +1,64 @@ import 'package:core/presentation/extensions/color_extension.dart'; import 'package:core/presentation/resources/image_paths.dart'; -import 'package:core/presentation/views/button/icon_button_web.dart'; +import 'package:core/presentation/utils/responsive_utils.dart'; +import 'package:core/presentation/views/button/tmail_button_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:get/get.dart'; +import 'package:tmail_ui_user/features/contact/presentation/styles/app_bar_contact_widget_style.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; class AppBarContactWidget extends StatelessWidget { - final _imagePaths = Get.find(); + final String? title; + final ImagePaths imagePaths; + final ResponsiveUtils responsiveUtils; + final VoidCallback onCloseContactView; - final Function()? onCloseContactView; - - AppBarContactWidget({ - Key? key, - this.onCloseContactView, + const AppBarContactWidget({ + Key? key, + required this.title, + required this.imagePaths, + required this.responsiveUtils, + required this.onCloseContactView, }) : super(key: key); @override Widget build(BuildContext context) { - return Stack(alignment: Alignment.center, children: [ - Positioned( - left: 0, - child: buildIconWeb( - icon: SvgPicture.asset( - _imagePaths.icClose, - colorFilter: AppColor.colorCloseButton.asFilter(), - width: 24, - height: 24, - fit: BoxFit.fill), - minSize: 25, - iconSize: 25, - iconPadding: const EdgeInsets.all(5), - splashRadius: 15, - tooltip: AppLocalizations.of(context).close, - onTap: onCloseContactView), + return Container( + height: 56, + color: Colors.white, + padding: AppBarContactWidgetStyle.getAppBarPadding( + context, + responsiveUtils ), - Center(child: Text( - AppLocalizations.of(context).contact, - style: const TextStyle( + width: double.infinity, + child: Stack( + alignment: Alignment.center, + children: [ + Text( + title ?? AppLocalizations.of(context).contact, + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: Colors.black))), - ]); + color: Colors.black + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + PositionedDirectional( + end: 0, + child: TMailButtonWidget.fromIcon( + icon: imagePaths.icClose, + tooltipMessage: AppLocalizations.of(context).close, + iconSize: 24, + padding: const EdgeInsets.all(3), + iconColor: AppColor.colorCloseButton, + backgroundColor: AppColor.colorCloseButton.withOpacity(0.12), + onTapActionCallback: onCloseContactView, + ) + ), + ] + ), + ); } } \ No newline at end of file diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index 5f88cd3b0c..a548e33749 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -1696,13 +1696,15 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo dispatchAction(StartSearchEmailAction()); } - Future selectFromSearchFilter() async { + Future selectFromSearchFilter(BuildContext context) async { if (accountId.value == null || sessionCurrent == null) return; final contactArgument = ContactArguments( - accountId.value!, - sessionCurrent!, - searchController.searchEmailFilter.value.from); + accountId: accountId.value!, + session: sessionCurrent!, + listContactSelected: searchController.searchEmailFilter.value.from, + contactViewTitle: '${AppLocalizations.of(context).findEmails} ${AppLocalizations.of(context).from_email_address_prefix.toLowerCase()}' + ); final newContact = await DialogRouter.pushGeneralDialog( routeName: AppRoutes.contact, @@ -1714,13 +1716,15 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo } } - Future selectToSearchFilter() async { + Future selectToSearchFilter(BuildContext context) async { if (accountId.value == null || sessionCurrent == null) return; final contactArgument = ContactArguments( - accountId.value!, - sessionCurrent!, - searchController.searchEmailFilter.value.to); + accountId: accountId.value!, + session: sessionCurrent!, + listContactSelected: searchController.searchEmailFilter.value.to, + contactViewTitle: '${AppLocalizations.of(context).findEmails} ${AppLocalizations.of(context).to_email_address_prefix.toLowerCase()}' + ); final newContact = await DialogRouter.pushGeneralDialog( routeName: AppRoutes.contact, diff --git a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart index 3f5d0bae83..021c5d7f97 100644 --- a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart +++ b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart @@ -591,13 +591,13 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { } break; case QuickSearchFilter.from: - controller.selectFromSearchFilter(); + controller.selectFromSearchFilter(context); break; case QuickSearchFilter.hasAttachment: controller.selectHasAttachmentSearchFilter(); break; case QuickSearchFilter.to: - controller.selectToSearchFilter(); + controller.selectToSearchFilter(context); break; case QuickSearchFilter.folder: controller.selectFolderSearchFilter(); diff --git a/lib/features/search/email/presentation/search_email_controller.dart b/lib/features/search/email/presentation/search_email_controller.dart index 54eb981e59..b137d776af 100644 --- a/lib/features/search/email/presentation/search_email_controller.dart +++ b/lib/features/search/email/presentation/search_email_controller.dart @@ -27,6 +27,7 @@ import 'package:model/mailbox/presentation_mailbox.dart'; import 'package:model/mailbox/select_mode.dart'; import 'package:tmail_ui_user/features/base/base_controller.dart'; import 'package:tmail_ui_user/features/base/mixin/date_range_picker_mixin.dart'; +import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart'; import 'package:tmail_ui_user/features/contact/presentation/model/contact_arguments.dart'; import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart'; import 'package:tmail_ui_user/features/email/domain/model/mark_read_action.dart'; @@ -73,6 +74,7 @@ import 'package:tmail_ui_user/features/thread/domain/usecases/search_more_email_ import 'package:tmail_ui_user/features/thread/presentation/extensions/list_presentation_email_extensions.dart'; import 'package:tmail_ui_user/features/thread/presentation/mixin/email_action_controller.dart'; import 'package:tmail_ui_user/features/thread/presentation/model/delete_action_type.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; import 'package:tmail_ui_user/main/routes/app_routes.dart'; import 'package:tmail_ui_user/main/routes/dialog_router.dart'; import 'package:tmail_ui_user/main/routes/navigation_router.dart'; @@ -630,23 +632,30 @@ class SearchEmailController extends BaseController } } - void selectContactForSearchFilter( + Future selectContactForSearchFilter( BuildContext context, PrefixEmailAddress prefixEmailAddress ) async { - if (accountId != null && session != null) { - final listContactSelected = searchEmailFilter.value.getContactApplied(prefixEmailAddress); - final arguments = ContactArguments(accountId!, session!, listContactSelected); - - final newContact = await push(AppRoutes.contact, arguments: arguments); - - if (newContact is EmailAddress && context.mounted) { - _dispatchApplyContactAction( - context, - listContactSelected, - prefixEmailAddress, - newContact); - } + FocusManager.instance.primaryFocus?.unfocus(); + + if (accountId == null || session == null) return; + + final listContactSelected = searchEmailFilter.value.getContactApplied(prefixEmailAddress); + final arguments = ContactArguments( + accountId: accountId!, + session: session!, + listContactSelected: listContactSelected, + contactViewTitle: '${AppLocalizations.of(context).findEmails} ${prefixEmailAddress.asName(context).toLowerCase()}' + ); + + final newContact = await push(AppRoutes.contact, arguments: arguments); + + if (newContact is EmailAddress && context.mounted) { + _dispatchApplyContactAction( + context, + listContactSelected, + prefixEmailAddress, + newContact); } } diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index 04cf96ed56..cc68d12fd7 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2024-09-10T15:59:25.469570", + "@@last_modified": "2024-09-18T01:15:29.034686", "initializing_data": "Initializing data...", "@initializing_data": { "type": "text", @@ -4017,5 +4017,11 @@ "type": "text", "placeholders_order": [], "placeholders": {} + }, + "findEmails": "Find emails", + "@findEmails": { + "type": "text", + "placeholders_order": [], + "placeholders": {} } } \ No newline at end of file diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index 44cc48b95d..b818e230e9 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -4213,4 +4213,10 @@ class AppLocalizations { name: 'youAreOffline', ); } + + String get findEmails { + return Intl.message( + 'Find emails', + name: 'findEmails'); + } } \ No newline at end of file