diff --git a/core/lib/presentation/extensions/color_extension.dart b/core/lib/presentation/extensions/color_extension.dart index a9722901c..7d716d73f 100644 --- a/core/lib/presentation/extensions/color_extension.dart +++ b/core/lib/presentation/extensions/color_extension.dart @@ -55,5 +55,7 @@ extension AppColor on Color { static const toastBackgroundColor = Color(0xFFACAFFF); static const toastSuccessBackgroundColor = Color(0xFF04AA11); static const toastErrorBackgroundColor = Color(0xFFFF5858); + static const toastWithActionBackgroundColor = Color(0xFF3F3F3F); + static const buttonActionToastWithActionColor = Color(0xFF7ADCF8); static const backgroundCountAttachment = Color(0x681C1C1C); } diff --git a/core/lib/presentation/utils/app_toast.dart b/core/lib/presentation/utils/app_toast.dart index 0dabca478..6bd384d3d 100644 --- a/core/lib/presentation/utils/app_toast.dart +++ b/core/lib/presentation/utils/app_toast.dart @@ -1,6 +1,8 @@ import 'package:core/presentation/extensions/color_extension.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:getwidget/components/toast/gf_toast.dart'; +import 'package:getwidget/getwidget.dart'; class AppToast { void showToast(String message) { @@ -32,4 +34,25 @@ class AppToast { toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM); } + + void showToastWithAction(BuildContext context, String message, String actionName, Function onActionClick) { + GFToast.showToast( + message, + context, + toastPosition: GFToastPosition.BOTTOM, + textStyle: TextStyle(fontSize: 16, color: Colors.white), + backgroundColor: AppColor.toastWithActionBackgroundColor, + trailing: GFButton( + onPressed: () { + ToastView.dismiss(); + onActionClick(); + }, + text: actionName, + type: GFButtonType.transparent, + color: AppColor.buttonActionToastWithActionColor, + ), + toastBorderRadius: 5.0, + toastDuration: 3 + ); + } } diff --git a/core/pubspec.yaml b/core/pubspec.yaml index 728821a48..8d845e491 100644 --- a/core/pubspec.yaml +++ b/core/pubspec.yaml @@ -56,6 +56,9 @@ dependencies: # device_info device_info: 2.0.2 + # getwidget + getwidget: 2.0.4 + dev_dependencies: flutter_test: sdk: flutter diff --git a/lib/features/email/presentation/email_controller.dart b/lib/features/email/presentation/email_controller.dart index 2768308d1..5dbfd6e0f 100644 --- a/lib/features/email/presentation/email_controller.dart +++ b/lib/features/email/presentation/email_controller.dart @@ -267,6 +267,34 @@ class EmailController extends BaseController { void _moveToMailboxSuccess(Success success) { mailboxDashBoardController.dispatchState(Right(success)); + + if (success is MoveToMailboxSuccess + && success.moveRequest.moveAction == MoveAction.moveTo + && Get.context != null && Get.overlayContext != null) { + _appToast.showToastWithAction( + Get.overlayContext!, + AppLocalizations.of(Get.context!).moved_to_mailbox(success.moveRequest.destinationMailboxName.name), + AppLocalizations.of(Get.context!).undo_action, + () { + final newMoveRequest = MoveRequest( + success.moveRequest.emailId, + success.moveRequest.destinationMailboxId, + success.moveRequest.destinationMailboxName, + success.moveRequest.currentMailboxId, + success.moveRequest.currentMailboxName, + MoveAction.undo); + _undoMoveToMailbox(newMoveRequest); + } + ); + } + } + + void _undoMoveToMailbox(MoveRequest newMoveRequest) { + final accountId = mailboxDashBoardController.accountId.value; + + if (accountId != null) { + _moveToMailbox(accountId, newMoveRequest); + } } bool canComposeEmail() => mailboxDashBoardController.sessionCurrent != null