Skip to content

Commit

Permalink
TF-2646 Handle move all selection emails when drag and drop to mailbox
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Dec 16, 2024
1 parent 0922b53 commit 28c7465
Show file tree
Hide file tree
Showing 28 changed files with 630 additions and 383 deletions.
1 change: 0 additions & 1 deletion core/lib/presentation/resources/assets_paths.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AssetsPaths {
static const images = 'assets/images/';
static const icons = 'assets/icons/';
static const configurationImages = 'configurations/icons/';
}
37 changes: 37 additions & 0 deletions lib/features/base/mixin/email_action_handler_mixin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import 'dart:ui';

import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:tmail_ui_user/features/base/mixin/message_dialog_action_mixin.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';

mixin EmailActionHandlerMixin implements MessageDialogActionMixin{
Future<void> showConfirmDialogWhenMakeToActionForSelectionAllEmails({
required ImagePaths imagePaths,
required int totalEmails,
required String folderName,
required VoidCallback onConfirmAction,
}) async {
if (currentContext == null) return;

final appLocalizations = AppLocalizations.of(currentContext!);

await showConfirmDialogAction(
currentContext!,
appLocalizations.messageConfirmationDialogWhenMakeToActionForSelectionAllEmailsInMailbox(
totalEmails,
folderName,
),
appLocalizations.ok,
title: appLocalizations.confirmBulkAction,
icon: SvgPicture.asset(
imagePaths.icQuotasWarning,
colorFilter: AppColor.colorBackgroundQuotasWarning.asFilter(),
),
onConfirmAction: onConfirmAction,
);
}
}
6 changes: 6 additions & 0 deletions lib/features/mailbox/presentation/mailbox_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ class MailboxController extends BaseMailboxController
log('MailboxController::_handleOpenMailbox():MAILBOX_ID = ${presentationMailboxSelected.id.asString} | MAILBOX_NAME: ${presentationMailboxSelected.name?.name}');
KeyboardUtils.hideKeyboard(context);
mailboxDashBoardController.clearSelectedEmail();
if (mailboxDashBoardController.isSelectAllEmailsEnabled.isTrue) {
mailboxDashBoardController.isSelectAllEmailsEnabled.value = false;
}
if (mailboxDashBoardController.isSelectAllPageEnabled.isTrue) {
mailboxDashBoardController.isSelectAllPageEnabled.value = false;
}
if (presentationMailboxSelected.id != mailboxDashBoardController.selectedMailbox.value?.id) {
mailboxDashBoardController.clearFilterMessageOption();
}
Expand Down
23 changes: 19 additions & 4 deletions lib/features/mailbox/presentation/mailbox_view_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:tmail_ui_user/features/mailbox/presentation/widgets/mailbox_load
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/user_information_widget.dart';
import 'package:tmail_ui_user/features/quotas/presentation/quotas_view.dart';
import 'package:tmail_ui_user/features/quotas/presentation/styles/quotas_view_styles.dart';
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/utils/app_config.dart';

Expand Down Expand Up @@ -393,15 +394,29 @@ class MailboxView extends BaseMailboxView {
}).toList() ?? <Widget>[];
}

void _handleDragItemAccepted(List<PresentationEmail> listEmails, PresentationMailbox presentationMailbox) {
void _handleDragItemAccepted(
DraggableEmailData draggableEmailData,
PresentationMailbox presentationMailbox,
) {
final mailboxPath = controller.findNodePath(presentationMailbox.id)
?? presentationMailbox.name?.name;
log('MailboxView::_handleDragItemAccepted(): mailboxPath: $mailboxPath');
if (mailboxPath != null) {
final newMailbox = presentationMailbox.toPresentationMailboxWithMailboxPath(mailboxPath);
controller.mailboxDashBoardController.dragSelectedMultipleEmailToMailboxAction(listEmails, newMailbox);
presentationMailbox = presentationMailbox
.toPresentationMailboxWithMailboxPath(mailboxPath);
}

if (draggableEmailData.isSelectAllEmailsEnabled) {
controller
.mailboxDashBoardController
.dragAllSelectedEmailToMailboxAction(presentationMailbox);
} else {
controller.mailboxDashBoardController.dragSelectedMultipleEmailToMailboxAction(listEmails, presentationMailbox);
controller
.mailboxDashBoardController
.dragSelectedMultipleEmailToMailboxAction(
draggableEmailData.listEmails!,
presentationMailbox,
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import 'package:flutter/material.dart';
import 'package:model/email/presentation_email.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart';
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';

typedef OnClickOpenMailboxAction = void Function(PresentationMailbox);
typedef OnClickOpenMenuMailboxAction = void Function(RelativeRect, PresentationMailbox);
typedef OnSelectMailboxAction = void Function(PresentationMailbox);
typedef OnDragEmailToMailboxAccepted = void Function(List<PresentationEmail>, PresentationMailbox);
typedef OnDragEmailToMailboxAccepted = void Function(DraggableEmailData, PresentationMailbox);
typedef OnLongPressMailboxAction = void Function(PresentationMailbox);

typedef OnClickExpandMailboxNodeAction = void Function(MailboxNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:model/email/presentation_email.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:model/mailbox/select_mode.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
Expand All @@ -16,6 +15,7 @@ import 'package:tmail_ui_user/features/mailbox/presentation/styles/mailbox_item_
import 'package:tmail_ui_user/features/mailbox/presentation/utils/mailbox_method_action_define.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/label_mailbox_item_widget.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/leading_mailbox_item_widget.dart';
import 'package:tmail_ui_user/features/thread/presentation/model/draggable_email_data.dart';

class MailboxItemWidget extends StatefulWidget {

Expand Down Expand Up @@ -65,8 +65,8 @@ class _MailboxItemWidgetState extends State<MailboxItemWidget> {
@override
Widget build(BuildContext context) {
if (_responsiveUtils.isWebDesktop(context) && widget.mailboxDisplayed == MailboxDisplayed.mailbox) {
return DragTarget<List<PresentationEmail>>(
builder: (context, candidateEmails, rejectedEmails) {
return DragTarget<DraggableEmailData>(
builder: (context, _, __) {
return InkWell(
onTap: () => widget.onOpenMailboxFolderClick?.call(widget.mailboxNode),
onHover: (value) => setState(() => _isItemHovered = value),
Expand Down Expand Up @@ -103,7 +103,8 @@ class _MailboxItemWidgetState extends State<MailboxItemWidget> {
),
);
},
onAcceptWithDetails: (emails) => widget.onDragItemAccepted?.call(emails.data, widget.mailboxNode.item),
onAcceptWithDetails: (details) =>
widget.onDragItemAccepted?.call(details.data, widget.mailboxNode.item),
);
} else {
if (widget.mailboxDisplayed == MailboxDisplayed.mailbox) {
Expand Down
Loading

0 comments on commit 28c7465

Please sign in to comment.