TF-80 Undo when move email to mailbox success from email detailed view
This commit is contained in:
@@ -55,5 +55,7 @@ extension AppColor on Color {
|
|||||||
static const toastBackgroundColor = Color(0xFFACAFFF);
|
static const toastBackgroundColor = Color(0xFFACAFFF);
|
||||||
static const toastSuccessBackgroundColor = Color(0xFF04AA11);
|
static const toastSuccessBackgroundColor = Color(0xFF04AA11);
|
||||||
static const toastErrorBackgroundColor = Color(0xFFFF5858);
|
static const toastErrorBackgroundColor = Color(0xFFFF5858);
|
||||||
|
static const toastWithActionBackgroundColor = Color(0xFF3F3F3F);
|
||||||
|
static const buttonActionToastWithActionColor = Color(0xFF7ADCF8);
|
||||||
static const backgroundCountAttachment = Color(0x681C1C1C);
|
static const backgroundCountAttachment = Color(0x681C1C1C);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:getwidget/components/toast/gf_toast.dart';
|
||||||
|
import 'package:getwidget/getwidget.dart';
|
||||||
|
|
||||||
class AppToast {
|
class AppToast {
|
||||||
void showToast(String message) {
|
void showToast(String message) {
|
||||||
@@ -32,4 +34,25 @@ class AppToast {
|
|||||||
toastLength: Toast.LENGTH_SHORT,
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
gravity: ToastGravity.BOTTOM);
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ dependencies:
|
|||||||
# device_info
|
# device_info
|
||||||
device_info: 2.0.2
|
device_info: 2.0.2
|
||||||
|
|
||||||
|
# getwidget
|
||||||
|
getwidget: 2.0.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
@@ -267,6 +267,34 @@ class EmailController extends BaseController {
|
|||||||
|
|
||||||
void _moveToMailboxSuccess(Success success) {
|
void _moveToMailboxSuccess(Success success) {
|
||||||
mailboxDashBoardController.dispatchState(Right(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
|
bool canComposeEmail() => mailboxDashBoardController.sessionCurrent != null
|
||||||
|
|||||||
Reference in New Issue
Block a user