Skip to content

Commit 2c61204

Browse files
committed
TF-2646 Handle select all emails in search mode
Signed-off-by: dab246 <[email protected]>
1 parent fe54398 commit 2c61204

File tree

74 files changed

+2099
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2099
-603
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class AssetsPaths {
22
static const images = 'assets/images/';
3-
static const icons = 'assets/icons/';
43
static const configurationImages = 'configurations/icons/';
54
}

integration_test/scenarios/search_email_by_date_time_and_sort_order_relevance_scenario.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import 'package:flutter_test/flutter_test.dart';
3-
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_receive_time_type.dart';
3+
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/email_receive_time_type.dart';
44
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_sort_order_type.dart';
55
import 'package:tmail_ui_user/features/search/email/presentation/search_email_view.dart';
66
import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_builder.dart';

lib/features/base/mixin/email_action_handler_mixin.dart

Lines changed: 0 additions & 37 deletions
This file was deleted.

lib/features/base/mixin/popup_menu_widget_mixin.dart

Lines changed: 0 additions & 43 deletions
This file was deleted.

lib/features/email/data/network/email_api.dart

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import 'package:model/extensions/account_id_extensions.dart';
5353
import 'package:model/extensions/email_extension.dart';
5454
import 'package:model/extensions/email_id_extensions.dart';
5555
import 'package:model/extensions/keyword_identifier_extension.dart';
56+
import 'package:model/extensions/list_email_extension.dart';
5657
import 'package:model/extensions/list_email_id_extension.dart';
5758
import 'package:model/extensions/list_id_extension.dart';
5859
import 'package:model/extensions/mailbox_id_extension.dart';
@@ -546,15 +547,11 @@ class EmailAPI with HandleSetErrorMixin {
546547

547548
final currentEmailIds = emailIds.sublist(start, end);
548549

549-
final moveProperties = isMovingToSpam
550-
? currentEmailIds.generateMapUpdateObjectMoveToSpam(
551-
currentMailboxId,
552-
destinationMailboxId,
553-
)
554-
: currentEmailIds.generateMapUpdateObjectMoveToMailbox(
555-
currentMailboxId,
556-
destinationMailboxId,
557-
);
550+
final moveProperties = currentEmailIds.generateMapUpdateObjectMoveToMailbox(
551+
currentMailboxId,
552+
destinationMailboxId,
553+
isDestinationSpamMailbox: isMovingToSpam,
554+
);
558555

559556
final setEmailMethod = SetEmailMethod(accountId)
560557
..addUpdates(moveProperties);
@@ -1016,19 +1013,27 @@ class EmailAPI with HandleSetErrorMixin {
10161013
Future<(List<EmailId> emailIds, Map<Id, SetError> mapErrors)> moveSelectionAllEmailsToFolder(
10171014
Session session,
10181015
AccountId accountId,
1019-
MailboxId currentMailboxId,
10201016
MailboxId destinationMailboxId,
1021-
List<EmailId> listEmailId,
10221017
{
1018+
MailboxId? currentMailboxId,
1019+
List<EmailId>? listEmailId,
1020+
List<Email>? listEmail,
10231021
bool isDestinationSpamMailbox = false
10241022
}
10251023
) async {
1026-
final moveProperties = isDestinationSpamMailbox
1027-
? listEmailId.generateMapUpdateObjectMoveToSpam(currentMailboxId, destinationMailboxId)
1028-
: listEmailId.generateMapUpdateObjectMoveToMailbox(currentMailboxId, destinationMailboxId);
1024+
final moveProperties = currentMailboxId != null
1025+
? listEmailId?.generateMapUpdateObjectMoveToMailbox(
1026+
currentMailboxId,
1027+
destinationMailboxId,
1028+
isDestinationSpamMailbox: isDestinationSpamMailbox,
1029+
)
1030+
: listEmail?.generateMapUpdateObjectMoveToMailbox(
1031+
destinationMailboxId,
1032+
isDestinationSpamMailbox: isDestinationSpamMailbox,
1033+
);
10291034

10301035
final setEmailMethod = SetEmailMethod(accountId)
1031-
..addUpdates(moveProperties);
1036+
..addUpdates(moveProperties ?? {});
10321037

10331038
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
10341039
final setEmailInvocation = requestBuilder.invocation(setEmailMethod);

lib/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@ import 'package:tmail_ui_user/main/routes/route_utils.dart';
1111
extension PresentationMailboxExtension on PresentationMailbox {
1212

1313
String getDisplayName(BuildContext context) {
14+
return getDisplayNameByAppLocalizations(AppLocalizations.of(context));
15+
}
16+
17+
String getDisplayNameByAppLocalizations(AppLocalizations appLocalizations) {
1418
if (isDefault) {
1519
switch(role!.value.toLowerCase()) {
1620
case PresentationMailbox.inboxRole:
17-
return AppLocalizations.of(context).inboxMailboxDisplayName;
21+
return appLocalizations.inboxMailboxDisplayName;
1822
case PresentationMailbox.archiveRole:
19-
return AppLocalizations.of(context).archiveMailboxDisplayName;
23+
return appLocalizations.archiveMailboxDisplayName;
2024
case PresentationMailbox.draftsRole:
21-
return AppLocalizations.of(context).draftsMailboxDisplayName;
25+
return appLocalizations.draftsMailboxDisplayName;
2226
case PresentationMailbox.sentRole:
23-
return AppLocalizations.of(context).sentMailboxDisplayName;
27+
return appLocalizations.sentMailboxDisplayName;
2428
case PresentationMailbox.outboxRole:
25-
return AppLocalizations.of(context).outboxMailboxDisplayName;
29+
return appLocalizations.outboxMailboxDisplayName;
2630
case PresentationMailbox.trashRole:
27-
return AppLocalizations.of(context).trashMailboxDisplayName;
31+
return appLocalizations.trashMailboxDisplayName;
2832
case PresentationMailbox.spamRole:
2933
case PresentationMailbox.junkRole:
30-
return AppLocalizations.of(context).spamMailboxDisplayName;
34+
return appLocalizations.spamMailboxDisplayName;
3135
case PresentationMailbox.templatesRole:
32-
return AppLocalizations.of(context).templatesMailboxDisplayName;
36+
return appLocalizations.templatesMailboxDisplayName;
3337
case PresentationMailbox.recoveredRole:
34-
return AppLocalizations.of(context).recoveredMailboxDisplayName;
38+
return appLocalizations.recoveredMailboxDisplayName;
3539
}
3640
}
3741
return name?.name ?? '';

lib/features/mailbox/presentation/mailbox_view_web.dart

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import 'package:tmail_ui_user/features/mailbox/presentation/widgets/app_grid_vie
1414
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/mailbox_item_widget.dart';
1515
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/mailbox_loading_bar_widget.dart';
1616
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/user_information_widget.dart';
17-
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_action_for_select_all_emails_extension.dart';
17+
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_email_action_type_when_select_all_active_and_mailbox_opened_extension.dart';
18+
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_email_action_type_when_select_all_active_and_search_active_extension.dart';
19+
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_email_action_type_when_selection_active_extension.dart';
1820
import 'package:tmail_ui_user/features/quotas/presentation/quotas_view.dart';
1921
import 'package:tmail_ui_user/features/quotas/presentation/styles/quotas_view_styles.dart';
20-
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';
2122
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
2223

2324
class MailboxView extends BaseMailboxView {
@@ -366,7 +367,12 @@ class MailboxView extends BaseMailboxView {
366367
onOpenMailboxFolderClick: (mailboxNode) => controller.openMailbox(context, mailboxNode.item),
367368
onExpandFolderActionClick: (mailboxNode) => controller.toggleMailboxFolder(mailboxNode, controller.mailboxListScrollController),
368369
onSelectMailboxFolderClick: controller.selectMailboxNode,
369-
onDragItemAccepted: _handleDragItemAccepted,
370+
onDragItemAccepted: (draggableEmailData, destinationMailbox) =>
371+
_handleDragItemAccepted(
372+
AppLocalizations.of(context),
373+
draggableEmailData,
374+
destinationMailbox,
375+
),
370376
onMenuActionClick: (position, mailboxNode) {
371377
openMailboxMenuActionOnWeb(
372378
context,
@@ -387,7 +393,12 @@ class MailboxView extends BaseMailboxView {
387393
mailboxNodeSelected: controller.mailboxDashBoardController.selectedMailbox.value,
388394
onOpenMailboxFolderClick: (mailboxNode) => controller.openMailbox(context, mailboxNode.item),
389395
onSelectMailboxFolderClick: controller.selectMailboxNode,
390-
onDragItemAccepted: _handleDragItemAccepted,
396+
onDragItemAccepted: (draggableEmailData, destinationMailbox) =>
397+
_handleDragItemAccepted(
398+
AppLocalizations.of(context),
399+
draggableEmailData,
400+
destinationMailbox,
401+
),
391402
onMenuActionClick: (position, mailboxNode) {
392403
openMailboxMenuActionOnWeb(
393404
context,
@@ -405,27 +416,39 @@ class MailboxView extends BaseMailboxView {
405416
}
406417

407418
void _handleDragItemAccepted(
408-
DraggableEmailData draggableEmailData,
409-
PresentationMailbox presentationMailbox,
419+
AppLocalizations appLocalizations,
420+
List<PresentationEmail> listEmails,
421+
PresentationMailbox destinationMailbox,
410422
) {
411-
final mailboxPath = controller.findNodePath(presentationMailbox.id)
412-
?? presentationMailbox.name?.name;
423+
final mailboxPath = controller.findNodePath(destinationMailbox.id)
424+
?? destinationMailbox.name?.name;
413425
log('MailboxView::_handleDragItemAccepted(): mailboxPath: $mailboxPath');
414426
if (mailboxPath != null) {
415-
presentationMailbox = presentationMailbox
427+
destinationMailbox = destinationMailbox
416428
.toPresentationMailboxWithMailboxPath(mailboxPath);
417429
}
418430

419-
if (draggableEmailData.isSelectAllEmailsEnabled) {
431+
if (controller.mailboxDashBoardController.isSelectAllActiveAndMailboxOpened) {
432+
controller
433+
.mailboxDashBoardController
434+
.dragEmailsToMailboxWhenSelectAllActiveAndMailboxOpened(
435+
appLocalizations: appLocalizations,
436+
selectedMailbox: controller.mailboxDashBoardController.selectedMailbox.value!,
437+
destinationMailbox: destinationMailbox,
438+
);
439+
} else if (controller.mailboxDashBoardController.isSelectAllActiveAndMailboxOpened) {
420440
controller
421441
.mailboxDashBoardController
422-
.dragAllSelectedEmailToMailboxAction(presentationMailbox);
442+
.dragEmailsToMailboxWhenSelectAllActiveAndSearchActive(
443+
appLocalizations: appLocalizations,
444+
destinationMailbox: destinationMailbox,
445+
);
423446
} else {
424447
controller
425448
.mailboxDashBoardController
426449
.dragSelectedMultipleEmailToMailboxAction(
427-
draggableEmailData.listEmails!,
428-
presentationMailbox,
450+
listEmails,
451+
destinationMailbox,
429452
);
430453
}
431454
}

lib/features/mailbox/presentation/utils/mailbox_method_action_define.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
import 'package:flutter/material.dart';
3+
import 'package:model/email/presentation_email.dart';
34
import 'package:model/mailbox/presentation_mailbox.dart';
45
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart';
5-
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';
66

77
typedef OnClickOpenMailboxAction = void Function(PresentationMailbox);
88
typedef OnClickOpenMenuMailboxAction = void Function(RelativeRect, PresentationMailbox);
99
typedef OnSelectMailboxAction = void Function(PresentationMailbox);
10-
typedef OnDragEmailToMailboxAccepted = void Function(DraggableEmailData, PresentationMailbox);
10+
typedef OnDragEmailToMailboxAccepted = void Function(List<PresentationEmail>, PresentationMailbox);
1111
typedef OnLongPressMailboxAction = void Function(PresentationMailbox);
1212

1313
typedef OnClickExpandMailboxNodeAction = void Function(MailboxNode);

lib/features/mailbox/presentation/widgets/mailbox_item_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
66
import 'package:flutter_svg/flutter_svg.dart';
77
import 'package:get/get.dart';
88
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
9+
import 'package:model/email/presentation_email.dart';
910
import 'package:model/mailbox/presentation_mailbox.dart';
1011
import 'package:model/mailbox/select_mode.dart';
1112
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
@@ -15,7 +16,6 @@ import 'package:tmail_ui_user/features/mailbox/presentation/styles/mailbox_item_
1516
import 'package:tmail_ui_user/features/mailbox/presentation/utils/mailbox_method_action_define.dart';
1617
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/label_mailbox_item_widget.dart';
1718
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/leading_mailbox_item_widget.dart';
18-
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';
1919

2020
class MailboxItemWidget extends StatefulWidget {
2121

@@ -65,7 +65,7 @@ class _MailboxItemWidgetState extends State<MailboxItemWidget> {
6565
@override
6666
Widget build(BuildContext context) {
6767
if (_responsiveUtils.isWebDesktop(context) && widget.mailboxDisplayed == MailboxDisplayed.mailbox) {
68-
return DragTarget<DraggableEmailData>(
68+
return DragTarget<List<PresentationEmail>>(
6969
builder: (context, _, __) {
7070
return InkWell(
7171
onTap: () => widget.onOpenMailboxFolderClick?.call(widget.mailboxNode),

0 commit comments

Comments
 (0)