From 99a4b1d9d27822c32bf166db5f7b63caee016dab Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 14 Jun 2022 10:38:45 +0700 Subject: [PATCH] TF-644 Update toast message download attachment on browser --- core/lib/presentation/utils/app_toast.dart | 12 +++++++++--- .../email/presentation/email_controller.dart | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/lib/presentation/utils/app_toast.dart b/core/lib/presentation/utils/app_toast.dart index 2ae9e3b6c..ce6bfa798 100644 --- a/core/lib/presentation/utils/app_toast.dart +++ b/core/lib/presentation/utils/app_toast.dart @@ -85,7 +85,7 @@ class AppToast { } void showToastWithIcon(BuildContext context, { - String? message, String? icon, Color? bgColor, + String? message, String? icon, Color? bgColor, Color? iconColor, Color? textColor, double? radius, EdgeInsets? padding, TextStyle? textStyle, double? widthToast, Duration? toastLength}) { double sizeWidth = context.width > 360 ? 360 : context.width - 40; @@ -104,8 +104,14 @@ class AppToast { child: Row( mainAxisSize: MainAxisSize.min, children: [ - if (icon != null) SvgPicture.asset(icon, width: 24, height: 24, fit: BoxFit.fill), - if (icon != null) SizedBox(width: 10.0), + if (icon != null) + SvgPicture.asset(icon, + width: 24, + height: 24, + fit: BoxFit.fill, + color: iconColor), + if (icon != null) + SizedBox(width: 10.0), Expanded(child: Text( message ?? '', style: textStyle ?? TextStyle(fontSize: 15, color: textColor ?? Colors.black))), diff --git a/lib/features/email/presentation/email_controller.dart b/lib/features/email/presentation/email_controller.dart index 028afe19d..2ec312209 100644 --- a/lib/features/email/presentation/email_controller.dart +++ b/lib/features/email/presentation/email_controller.dart @@ -347,15 +347,24 @@ class EmailController extends BaseController { void _downloadAttachmentForWebAction(BuildContext context, Attachment attachment) async { final accountId = mailboxDashBoardController.accountId.value; if (accountId != null && mailboxDashBoardController.sessionCurrent != null) { + _appToast.showToastWithIcon(context, + message: AppLocalizations.of(currentContext!).your_download_has_started, + iconColor: AppColor.primaryColor, + icon: imagePaths.icDownload); + final baseDownloadUrl = mailboxDashBoardController.sessionCurrent!.getDownloadUrl(); - _appToast.showToast(AppLocalizations.of(context).your_download_has_started); consumeState(_downloadAttachmentForWebInteractor.execute(attachment, accountId, baseDownloadUrl)); } } - void _downloadAttachmentForWebFailureAction(Failure failure) { - if (failure is DownloadAttachmentForWebFailure && currentContext != null) { - _appToast.showErrorToast(AppLocalizations.of(currentContext!).attachment_download_failed); + void _downloadAttachmentForWebFailureAction(DownloadAttachmentForWebFailure failure) { + if (currentOverlayContext != null && currentContext != null) { + _appToast.showToastWithIcon(currentOverlayContext!, + message: AppLocalizations.of(currentContext!).attachment_download_failed, + bgColor: AppColor.toastErrorBackgroundColor, + textColor: Colors.white, + iconColor: Colors.white, + icon: imagePaths.icDownload); } }