TF-1594 Use only one class TmailToast to display the message.

(cherry picked from commit 379c34b32b2e5c4dad141e6a98bdb92597fa6908)
This commit is contained in:
dab246
2023-03-16 18:23:47 +07:00
committed by Dat Vu
parent fe05df3477
commit 4e17813e1a
34 changed files with 752 additions and 930 deletions
+6 -2
View File
@@ -1,4 +1,8 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z" fill="#FF3B30"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.3 6.40002C11.17 6.40009 11.0427 6.43634 10.9321 6.50471C10.8216 6.57308 10.7323 6.67087 10.6742 6.78712L10.1674 7.80002H7.80001C7.61435 7.80002 7.43631 7.87377 7.30503 8.00505C7.17376 8.13633 7.10001 8.31437 7.10001 8.50002C7.10001 8.68568 7.17376 8.86372 7.30503 8.995C7.43631 9.12627 7.61435 9.20002 7.80001 9.20002V16.2C7.80001 16.5713 7.94751 16.9274 8.21006 17.19C8.47261 17.4525 8.8287 17.6 9.20001 17.6H14.8C15.1713 17.6 15.5274 17.4525 15.79 17.19C16.0525 16.9274 16.2 16.5713 16.2 16.2V9.20002C16.3857 9.20002 16.5637 9.12627 16.695 8.995C16.8263 8.86372 16.9 8.68568 16.9 8.50002C16.9 8.31437 16.8263 8.13633 16.695 8.00505C16.5637 7.87377 16.3857 7.80002 16.2 7.80002H13.8326L13.3258 6.78712C13.2677 6.67087 13.1784 6.57308 13.0679 6.50471C12.9573 6.43634 12.83 6.40009 12.7 6.40002H11.3ZM9.90001 10.6C9.90001 10.4144 9.97376 10.2363 10.105 10.105C10.2363 9.97377 10.4144 9.90002 10.6 9.90002C10.7857 9.90002 10.9637 9.97377 11.095 10.105C11.2263 10.2363 11.3 10.4144 11.3 10.6V14.8C11.3 14.9857 11.2263 15.1637 11.095 15.295C10.9637 15.4263 10.7857 15.5 10.6 15.5C10.4144 15.5 10.2363 15.4263 10.105 15.295C9.97376 15.1637 9.90001 14.9857 9.90001 14.8V10.6ZM13.4 9.90002C13.2144 9.90002 13.0363 9.97377 12.905 10.105C12.7738 10.2363 12.7 10.4144 12.7 10.6V14.8C12.7 14.9857 12.7738 15.1637 12.905 15.295C13.0363 15.4263 13.2144 15.5 13.4 15.5C13.5857 15.5 13.7637 15.4263 13.895 15.295C14.0263 15.1637 14.1 14.9857 14.1 14.8V10.6C14.1 10.4144 14.0263 10.2363 13.895 10.105C13.7637 9.97377 13.5857 9.90002 13.4 9.90002Z" fill="white"/>
<path
d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z"
fill="white" />
<path fill-rule="evenodd" clip-rule="evenodd"
d="M11.3 6.40002C11.17 6.40009 11.0427 6.43634 10.9321 6.50471C10.8216 6.57308 10.7323 6.67087 10.6742 6.78712L10.1674 7.80002H7.80001C7.61435 7.80002 7.43631 7.87377 7.30503 8.00505C7.17376 8.13633 7.10001 8.31437 7.10001 8.50002C7.10001 8.68568 7.17376 8.86372 7.30503 8.995C7.43631 9.12627 7.61435 9.20002 7.80001 9.20002V16.2C7.80001 16.5713 7.94751 16.9274 8.21006 17.19C8.47261 17.4525 8.8287 17.6 9.20001 17.6H14.8C15.1713 17.6 15.5274 17.4525 15.79 17.19C16.0525 16.9274 16.2 16.5713 16.2 16.2V9.20002C16.3857 9.20002 16.5637 9.12627 16.695 8.995C16.8263 8.86372 16.9 8.68568 16.9 8.50002C16.9 8.31437 16.8263 8.13633 16.695 8.00505C16.5637 7.87377 16.3857 7.80002 16.2 7.80002H13.8326L13.3258 6.78712C13.2677 6.67087 13.1784 6.57308 13.0679 6.50471C12.9573 6.43634 12.83 6.40009 12.7 6.40002H11.3ZM9.90001 10.6C9.90001 10.4144 9.97376 10.2363 10.105 10.105C10.2363 9.97377 10.4144 9.90002 10.6 9.90002C10.7857 9.90002 10.9637 9.97377 11.095 10.105C11.2263 10.2363 11.3 10.4144 11.3 10.6V14.8C11.3 14.9857 11.2263 15.1637 11.095 15.295C10.9637 15.4263 10.7857 15.5 10.6 15.5C10.4144 15.5 10.2363 15.4263 10.105 15.295C9.97376 15.1637 9.90001 14.9857 9.90001 14.8V10.6ZM13.4 9.90002C13.2144 9.90002 13.0363 9.97377 12.905 10.105C12.7738 10.2363 12.7 10.4144 12.7 10.6V14.8C12.7 14.9857 12.7738 15.1637 12.905 15.295C13.0363 15.4263 13.2144 15.5 13.4 15.5C13.5857 15.5 13.7637 15.4263 13.895 15.295C14.0263 15.1637 14.1 14.9857 14.1 14.8V10.6C14.1 10.4144 14.0263 10.2363 13.895 10.105C13.7637 9.97377 13.5857 9.90002 13.4 9.90002Z"
fill="#FF3B30" />
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

+4 -2
View File
@@ -1,4 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="12" fill="#007AFF"/>
<path d="M6.49316 16.5801L9.95752 13.1641L7.05176 10.3389C6.93896 10.2207 6.93896 10.0864 7.05176 10.0005L11.6494 6.44482C11.9287 6.22998 12.0791 6.12256 12.2993 6.12256C12.5195 6.12256 12.6646 6.22998 12.9492 6.44482L17.5469 10.0005C17.6597 10.0864 17.6597 10.2261 17.5469 10.3389L14.6572 13.1641L18.1055 16.5693C18.186 16.4189 18.229 16.1611 18.229 15.7959V10.3496C18.229 9.78027 18.1323 9.49561 17.7349 9.16797L13.4058 5.81104C13.0083 5.49951 12.6968 5.30078 12.2993 5.30078C11.9019 5.30078 11.5903 5.49951 11.1929 5.81104L6.8584 9.16797C6.47168 9.49023 6.36963 9.78027 6.36963 10.3496V15.7959C6.36963 16.1719 6.4126 16.4297 6.49316 16.5801ZM7.89502 17.4609H16.5425C17.0742 17.4609 17.4448 17.3643 17.6436 17.1709L12.9707 12.5518C12.7344 12.3154 12.5303 12.2134 12.3101 12.2134C12.0845 12.2134 11.8804 12.3154 11.6494 12.5518L6.94434 17.1978C7.12695 17.375 7.44385 17.4609 7.89502 17.4609Z" fill="white"/>
<circle cx="12" cy="12" r="12" fill="white" />
<path
d="M6.49316 16.5801L9.95752 13.1641L7.05176 10.3389C6.93896 10.2207 6.93896 10.0864 7.05176 10.0005L11.6494 6.44482C11.9287 6.22998 12.0791 6.12256 12.2993 6.12256C12.5195 6.12256 12.6646 6.22998 12.9492 6.44482L17.5469 10.0005C17.6597 10.0864 17.6597 10.2261 17.5469 10.3389L14.6572 13.1641L18.1055 16.5693C18.186 16.4189 18.229 16.1611 18.229 15.7959V10.3496C18.229 9.78027 18.1323 9.49561 17.7349 9.16797L13.4058 5.81104C13.0083 5.49951 12.6968 5.30078 12.2993 5.30078C11.9019 5.30078 11.5903 5.49951 11.1929 5.81104L6.8584 9.16797C6.47168 9.49023 6.36963 9.78027 6.36963 10.3496V15.7959C6.36963 16.1719 6.4126 16.4297 6.49316 16.5801ZM7.89502 17.4609H16.5425C17.0742 17.4609 17.4448 17.3643 17.6436 17.1709L12.9707 12.5518C12.7344 12.3154 12.5303 12.2134 12.3101 12.2134C12.0845 12.2134 11.8804 12.3154 11.6494 12.5518L6.94434 17.1978C7.12695 17.375 7.44385 17.4609 7.89502 17.4609Z"
fill="#007AFF" />
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

+8
View File
@@ -0,0 +1,8 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z"
fill="white" />
<path
d="M8.15912 14.1694C7.70202 15.406 7.41479 16.2748 7.29741 16.7759C6.92851 18.3507 6.66028 18.7054 8.03519 17.957C9.41011 17.2086 16.0663 13.5012 17.5513 12.6773C19.4871 11.6033 19.513 11.6872 17.4474 10.5469C15.8743 9.6784 9.29614 6.06777 8.03519 5.35883C6.77425 4.64989 6.92851 4.96514 7.29741 6.53991C7.41631 7.04748 7.70771 7.92406 8.17163 9.16964C8.4961 10.0408 9.25082 10.6801 10.1635 10.8569L14.0065 11.6013C14.0426 11.6085 14.066 11.6436 14.0588 11.6797C14.0535 11.7061 14.0329 11.7268 14.0065 11.732L10.1548 12.4757C9.2392 12.6525 8.48245 13.2947 8.15912 14.1694Z"
fill="#007AFF" />
</svg>

After

Width:  |  Height:  |  Size: 881 B

@@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M12 1.71428C17.6806 1.71428 22.2857 6.31935 22.2857 12C22.2857 17.6806 17.6806 22.2857 12 22.2857C6.31935 22.2857 1.71428 17.6806 1.71428 12C1.71428 6.31935 6.31935 1.71428 12 1.71428ZM12 3.42856C7.26612 3.42856 3.42856 7.26612 3.42856 12C3.42856 16.7339 7.26612 20.5714 12 20.5714C16.7339 20.5714 20.5714 16.7339 20.5714 12C20.5714 7.26612 16.7339 3.42856 12 3.42856ZM15.6771 8.81999C16.0119 8.48526 16.5595 8.48526 16.8943 8.81999C17.229 9.15473 17.229 9.7024 16.8943 10.0371L10.8918 16.0347C10.5571 16.3694 10.0144 16.3694 9.67962 16.0347L6.67962 13.0347C6.34488 12.6999 6.34488 12.1572 6.67962 11.8225C7.01435 11.4877 7.55706 11.4877 7.8918 11.8225L10.2857 14.2164L15.6771 8.81999Z"
fill="white" />
</svg>

After

Width:  |  Height:  |  Size: 835 B

+6 -2
View File
@@ -1,4 +1,8 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z" fill="#007AFF"/>
<path d="M16.7543 10.5015C17.7125 10.5015 18.5025 9.71152 18.5025 8.74822C18.5025 7.79001 17.7125 7 16.7543 7C15.791 7 15.0061 7.79001 15.0061 8.74822C15.0061 9.71152 15.791 10.5015 16.7543 10.5015ZM11.8818 12.8308C12.1111 12.8308 12.3099 12.7187 12.5494 12.4791L14.7615 10.2773C14.4353 9.85423 14.2416 9.32416 14.2416 8.74822C14.2416 8.40673 14.3129 8.08053 14.4455 7.77982H7.71764C7.26402 7.77982 6.93782 7.86137 6.73904 8.01937L11.2141 12.4791C11.4536 12.7187 11.6524 12.8308 11.8818 12.8308ZM16.7543 9.51274C16.3364 9.51274 15.9949 9.16616 15.9949 8.74822C15.9949 8.33537 16.3364 7.98879 16.7543 7.98879C17.1672 7.98879 17.5138 8.33537 17.5138 8.74822C17.5138 9.16616 17.1672 9.51274 16.7543 9.51274ZM6.15291 16.0673L9.90418 12.3313L6.18349 8.65138C6.06116 8.83996 6 9.14577 6 9.56881V15.211C6 15.6035 6.05097 15.8889 6.15291 16.0673ZM17.6055 16.0622C17.7023 15.8838 17.7533 15.6035 17.7533 15.211V11.0469C17.4526 11.1845 17.1111 11.261 16.7543 11.261C16.2396 11.261 15.7604 11.1081 15.3629 10.8379L13.8542 12.3313L17.6055 16.0622ZM16.0408 17C16.5199 17 16.8665 16.9032 17.0805 16.7248L13.2579 12.9174L12.9827 13.1927C12.6208 13.5494 12.2691 13.7125 11.8818 13.7125C11.4944 13.7125 11.1376 13.5494 10.7808 13.1927L10.5056 12.9225L6.68807 16.7197C6.91233 16.9032 7.2844 17 7.79918 17H16.0408Z" fill="white"/>
<path
d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z"
fill="white" />
<path
d="M16.7543 10.5015C17.7125 10.5015 18.5025 9.71152 18.5025 8.74822C18.5025 7.79001 17.7125 7 16.7543 7C15.791 7 15.0061 7.79001 15.0061 8.74822C15.0061 9.71152 15.791 10.5015 16.7543 10.5015ZM11.8818 12.8308C12.1111 12.8308 12.3099 12.7187 12.5494 12.4791L14.7615 10.2773C14.4353 9.85423 14.2416 9.32416 14.2416 8.74822C14.2416 8.40673 14.3129 8.08053 14.4455 7.77982H7.71764C7.26402 7.77982 6.93782 7.86137 6.73904 8.01937L11.2141 12.4791C11.4536 12.7187 11.6524 12.8308 11.8818 12.8308ZM16.7543 9.51274C16.3364 9.51274 15.9949 9.16616 15.9949 8.74822C15.9949 8.33537 16.3364 7.98879 16.7543 7.98879C17.1672 7.98879 17.5138 8.33537 17.5138 8.74822C17.5138 9.16616 17.1672 9.51274 16.7543 9.51274ZM6.15291 16.0673L9.90418 12.3313L6.18349 8.65138C6.06116 8.83996 6 9.14577 6 9.56881V15.211C6 15.6035 6.05097 15.8889 6.15291 16.0673ZM17.6055 16.0622C17.7023 15.8838 17.7533 15.6035 17.7533 15.211V11.0469C17.4526 11.1845 17.1111 11.261 16.7543 11.261C16.2396 11.261 15.7604 11.1081 15.3629 10.8379L13.8542 12.3313L17.6055 16.0622ZM16.0408 17C16.5199 17 16.8665 16.9032 17.0805 16.7248L13.2579 12.9174L12.9827 13.1927C12.6208 13.5494 12.2691 13.7125 11.8818 13.7125C11.4944 13.7125 11.1376 13.5494 10.7808 13.1927L10.5056 12.9225L6.68807 16.7197C6.91233 16.9032 7.2844 17 7.79918 17H16.0408Z"
fill="#007AFF" />
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -57,9 +57,8 @@ extension AppColor on Color {
static const enableSendEmailButtonColor = Color(0xFF007AFF);
static const disableSendEmailButtonColor = Color(0xFFA9B4C2);
static const borderLeftEmailContentColor = Color(0xFFEFEFEF);
static const toastBackgroundColor = Color(0xFFACAFFF);
static const toastSuccessBackgroundColor = Color(0xFF4BB34B);
static const toastErrorBackgroundColor = Color(0xFFFF5858);
static const toastErrorBackgroundColor = Color(0xFFE64646);
static const toastWithActionBackgroundColor = Color(0xFF3F3F3F);
static const buttonActionToastWithActionColor = Color(0xFF7ADCF8);
static const backgroundCountAttachment = Color(0x681C1C1C);
@@ -49,6 +49,7 @@ class ImagePaths {
String get icFilterMessageAttachments => _getImagePath('ic_filter_message_attachments.svg');
String get icLogoTMail => _getImagePath('logo_tmail.png');
String get icSendToast => _getImagePath('ic_send_toast.svg');
String get icSendSuccessToast => _getImagePath('ic_send_success_toast.svg');
String get icClearTextSearch => _getImagePath('ic_clear_text_search.svg');
String get icRenameMailbox => _getImagePath('ic_rename_mailbox.svg');
String get icDeleteToast => _getImagePath('ic_delete_toast.svg');
@@ -175,6 +176,7 @@ class ImagePaths {
String get icHideMailbox => _getImagePath('ic_hide_mailbox.svg');
String get icShowMailbox => _getImagePath('ic_show_mailbox.svg');
String get icMailboxVisibility => _getImagePath('ic_mailbox_visibility.svg');
String get icToastSuccessMessage => _getImagePath('ic_toast_success_message.svg');
String _getImagePath(String imageName) {
return AssetsPaths.images + imageName;
+122 -164
View File
@@ -1,79 +1,97 @@
import 'package:core/core.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/views/toast/tmail_toast.dart';
import 'package:core/presentation/views/toast/toast_position.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
class AppToast {
final fToast = Get.find<FToast>();
void showToast(String message) {
Fluttertoast.showToast(
msg: message,
fontSize: 16,
textColor: Colors.white,
backgroundColor: AppColor.toastBackgroundColor,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM);
}
void showSuccessToast(String message, {bool isToastLengthLong = false}) {
Fluttertoast.showToast(
msg: message,
fontSize: 16,
textColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
toastLength: isToastLengthLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM);
}
void showErrorToast(String message, {bool isToastLengthLong = false}) {
Fluttertoast.showToast(
msg: message,
fontSize: 16,
textColor: Colors.white,
backgroundColor: AppColor.toastErrorBackgroundColor,
toastLength: isToastLengthLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM);
}
void showBottomToast(
BuildContext context,
String message,
{
String? actionName,
Function? onActionClick,
Widget? actionIcon,
Widget? leadingIcon,
double? maxWidth,
bool infinityToast = false,
Color? backgroundColor,
Color? textColor,
Color? textActionColor,
}
void showToastErrorMessage(
BuildContext context,
String message,
{
Color? leadingSVGIconColor,
String? leadingSVGIcon
}
) {
Widget? trailingAction;
final imagePaths = Get.find<ImagePaths>();
showToastMessage(
context,
message,
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
leadingSVGIconColor: leadingSVGIconColor ?? (leadingSVGIcon == null ? Colors.white : null),
leadingSVGIcon: leadingSVGIcon ?? imagePaths.icNotConnection
);
}
void showToastSuccessMessage(
BuildContext context,
String message,
{
Color? leadingSVGIconColor,
String? leadingSVGIcon,
}
) {
final imagePaths = Get.find<ImagePaths>();
showToastMessage(
context,
message,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
leadingSVGIconColor: leadingSVGIconColor ?? (leadingSVGIcon == null ? Colors.white : null),
leadingSVGIcon: leadingSVGIcon ?? imagePaths.icToastSuccessMessage
);
}
void showToastMessage(
BuildContext context,
String message,
{
String? actionName,
Function? onActionClick,
Widget? actionIcon,
Widget? leadingIcon,
String? leadingSVGIcon,
Color? leadingSVGIconColor,
double? maxWidth,
bool infinityToast = false,
Color? backgroundColor,
Color? textColor,
Color? textActionColor,
TextStyle? textStyle,
EdgeInsets? padding,
}
) {
final responsiveUtils = Get.find<ResponsiveUtils>();
Widget? trailingWidget;
if (actionName != null) {
if (actionIcon == null) {
trailingAction = TextButton(
onPressed: () {
ToastView.dismiss();
onActionClick?.call();
},
child: Text(
actionName,
style: TextStyle(
trailingWidget = PointerInterceptor(
child: TextButton(
onPressed: () {
ToastView.dismiss();
onActionClick?.call();
},
child: Text(
actionName,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? AppColor.buttonActionToastWithActionColor),
color: textActionColor ?? Colors.white
),
),
),
);
} else {
trailingAction = Material(
color: Colors.transparent,
child: InkWell(
trailingWidget = PointerInterceptor(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
ToastView.dismiss();
onActionClick?.call();
@@ -82,118 +100,58 @@ class AppToast {
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
actionIcon,
Text(
actionName,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white),
)
]
mainAxisSize: MainAxisSize.min,
children: [
actionIcon,
Text(
actionName,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textActionColor ?? Colors.white
),
)
]
),
)),
)
),
),
);
}
}
showToastMessage(
context,
message,
maxWidth: maxWidth,
backgroundColor: backgroundColor,
infinityToast: infinityToast,
textColor: textColor,
leading: leadingIcon,
trailing: trailingAction);
}
Widget? leadingWidget;
if (leadingIcon != null) {
leadingWidget = PointerInterceptor(child: leadingIcon);
} else {
if (leadingSVGIcon != null) {
leadingWidget = PointerInterceptor(
child: SvgPicture.asset(
leadingSVGIcon,
width: 24,
height: 24,
fit: BoxFit.fill,
colorFilter: leadingSVGIconColor?.asFilter(),
)
);
}
}
void showToastMessage(
BuildContext context,
String message, {
Color? textColor,
Widget? leading,
bool infinityToast = false,
Widget? trailing,
double? maxWidth,
Color? backgroundColor
}) {
TMailToast.showToast(
message,
context,
width: maxWidth,
toastPosition: ToastPosition.BOTTOM,
textStyle: TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textColor ?? Colors.white),
backgroundColor: backgroundColor ?? AppColor.toastWithActionBackgroundColor,
trailing: trailing != null
? Padding(
padding: const EdgeInsets.only(left: 8),
child: PointerInterceptor(child: trailing))
: null,
leading: leading != null
? Padding(
padding: const EdgeInsets.only(right: 8),
child: PointerInterceptor(child: leading))
: null,
toastBorderRadius: 10.0,
toastDuration: infinityToast ? null : 3,
);
}
void showToastWithIcon(
BuildContext context, {
String? message,
String? icon,
Color? bgColor,
Color? iconColor,
Color? textColor,
double? radius,
EdgeInsets? padding,
TextStyle? textStyle,
double? widthToast,
Duration? toastLength
}) async {
double sizeWidth = context.width > 360 ? 360 : context.width - 40;
final toast = Material(
color: bgColor ?? Colors.white,
elevation: 10,
shadowColor: Colors.black54,
borderRadius: BorderRadius.all(Radius.circular(radius ?? 10)),
child: Container(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 12.0, vertical: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radius ?? 10.0),
color: bgColor ?? Colors.white,
),
width: widthToast ?? sizeWidth,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null)
SvgPicture.asset(icon,
width: 24,
height: 24,
fit: BoxFit.fill,
colorFilter: iconColor.asFilter()),
if (icon != null)
const SizedBox(width: 10.0),
Expanded(child: Text(
message ?? '',
style: textStyle ?? TextStyle(fontSize: 15, color: textColor ?? Colors.black))),
],
),
message,
context,
width: maxWidth ?? responsiveUtils.getMaxWidthToast(context),
toastPosition: ToastPosition.BOTTOM,
textStyle: textStyle ?? TextStyle(
fontSize: 15,
fontWeight: FontWeight.normal,
color: textColor ?? AppColor.primaryColor
),
);
fToast.init(context);
fToast.showToast(
child: toast,
gravity: ToastGravity.BOTTOM,
toastDuration: toastLength ?? const Duration(seconds: 3),
backgroundColor: backgroundColor ?? Colors.white,
trailing: trailingWidget,
leading: leadingWidget,
padding: padding,
toastDuration: infinityToast ? null : 3,
);
}
}
@@ -77,7 +77,7 @@ class ResponsiveUtils {
if (isPortraitMobile(context)) {
return widthScreen;
} else {
return widthScreen < 444 ? widthScreen : 444;
return widthScreen < 424 ? widthScreen : 424;
}
}
@@ -18,13 +18,13 @@ class ButtonBuilder {
bool? _isVertical;
Key? _key;
Color? _iconColor;
Color? _colorButton;
TextStyle? _textStyle;
BoxDecoration? _decoration;
Widget? _iconAction;
double? _radiusSplash;
double? _maxWidth;
EdgeInsets? _padding;
EdgeInsets? _margin;
String? _tooltip;
BoxConstraints? _constraints;
@@ -48,10 +48,6 @@ class ButtonBuilder {
_iconColor = color;
}
void colorButton(Color color) {
_colorButton = color;
}
void decoration(BoxDecoration decoration) {
_decoration = decoration;
}
@@ -68,6 +64,10 @@ class ButtonBuilder {
_padding = padding;
}
void margin(EdgeInsets? margin) {
_margin = margin;
}
void textStyle(TextStyle style) {
_textStyle = style;
}
@@ -100,38 +100,40 @@ class ButtonBuilder {
}
Widget build() {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () => _onPressActionClick != null ? _onPressActionClick!.call() : null,
onTapDown: (detail) {
if (_onPressActionWithPositionClick != null && _context != null) {
final screenSize = MediaQuery.of(_context!).size;
final offset = detail.globalPosition;
final position = RelativeRect.fromLTRB(
offset.dx,
offset.dy,
screenSize.width - offset.dx,
screenSize.height - offset.dy,
);
_onPressActionWithPositionClick?.call(position);
}
},
customBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_radiusSplash ?? 20)),
child: Tooltip(
message: _tooltip ?? '',
child: Container(
key: _key,
alignment: Alignment.center,
color: _decoration == null ? _colorButton : null,
decoration: _decoration,
width: _maxWidth,
constraints: _constraints,
padding: _padding ?? EdgeInsets.zero,
child: _buildBody()
),
)
return Padding(
padding: _margin ?? EdgeInsets.zero,
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: _onPressActionClick,
onTapDown: (detail) {
if (_onPressActionWithPositionClick != null && _context != null) {
final screenSize = MediaQuery.of(_context!).size;
final offset = detail.globalPosition;
final position = RelativeRect.fromLTRB(
offset.dx,
offset.dy,
screenSize.width - offset.dx,
screenSize.height - offset.dy,
);
_onPressActionWithPositionClick?.call(position);
}
},
borderRadius: BorderRadius.circular(_radiusSplash ?? 20),
child: Tooltip(
message: _tooltip ?? '',
child: Container(
key: _key,
alignment: Alignment.center,
color: _decoration == null ? Colors.transparent : null,
decoration: _decoration,
width: _maxWidth,
constraints: _constraints,
padding: _padding ?? EdgeInsets.zero,
child: _buildBody()
),
)
),
),
);
}
@@ -163,11 +165,12 @@ class ButtonBuilder {
Widget _buildIcon() => Padding(
padding: _paddingIcon ?? const EdgeInsets.all(10),
child: SvgPicture.asset(
_icon ?? '',
width: _size ?? 24,
height: _size ?? 24,
fit: BoxFit.fill,
colorFilter: _iconColor.asFilter()));
_icon ?? '',
width: _size ?? 24,
height: _size ?? 24,
fit: BoxFit.fill,
colorFilter: _iconColor.asFilter()
));
Widget _buildText() {
return Text(
@@ -176,8 +179,9 @@ class ButtonBuilder {
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
style: _textStyle ?? const TextStyle(
fontSize: 12,
color: AppColor.colorTextButton),
fontSize: 12,
color: AppColor.colorTextButton
),
);
}
}
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/views/toast/toast_position.dart';
import 'package:flutter/material.dart';
@@ -34,52 +35,68 @@ class TMailToast {
/// defines the size width widget of the toast
double? width;
// ignore: type_annotate_public_apis, always_declare_return_types
/// defines the padding widget of the toast
EdgeInsets? padding;
static showToast(
text,
BuildContext context, {
toastDuration,
toastPosition,
backgroundColor = const Color(0xAA000000),
textStyle = const TextStyle(fontSize: 15, color: Colors.white),
toastBorderRadius = 20.0,
backgroundColor,
textStyle = const TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
),
toastBorderRadius = 10.0,
border,
trailing,
leading,
width,
padding,
}) {
assert(text != null);
ToastView.dismiss();
ToastView.createView(text, context, toastPosition,
backgroundColor, textStyle, toastBorderRadius, border, trailing,
leading, width, toastDuration: toastDuration,);
ToastView.createView(
text,
context,
toastPosition,
backgroundColor,
textStyle,
toastBorderRadius,
border,
trailing,
leading,
width,
padding,
toastDuration: toastDuration,
);
}
}
class ToastView {
static final ToastView _instance = ToastView._internal();
// ignore: sort_constructors_first
factory ToastView() => _instance;
// ignore: sort_constructors_first
ToastView._internal();
static OverlayState? overlayState;
static OverlayEntry? _overlayEntry;
static bool _isVisible = false;
// ignore: avoid_void_async
static void createView(
String text,
BuildContext context,
ToastPosition? toastPosition,
Color backgroundColor,
TextStyle textStyle,
Color? backgroundColor,
TextStyle? textStyle,
double toastBorderRadius,
Border? border,
Widget? trailing,
Widget? leading,
double? width,
{int? toastDuration = 2}
EdgeInsets? padding,
{int? toastDuration}
) async {
overlayState = Overlay.of(context, rootOverlay: false);
@@ -89,49 +106,72 @@ class ToastView {
child: Container(
width: width,
decoration: BoxDecoration(
color: backgroundColor,
color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(toastBorderRadius),
border: border,
boxShadow: const [
BoxShadow(
color: AppColor.colorShadowLayerBottom,
blurRadius: 24,
offset: Offset.zero),
BoxShadow(
color: AppColor.colorShadowBgContentEmail,
blurRadius: 2,
offset: Offset.zero),
]
),
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
child: trailing == null && leading == null ?
Text(text, softWrap: true, style: textStyle) :
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (leading != null) leading,
Expanded(child: Text(text, style: textStyle)),
if (trailing != null) trailing
],
),
padding: padding ?? const EdgeInsets.all(12),
child: trailing == null && leading == null
? Text(
text,
softWrap: true,
style: textStyle ?? const TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
)
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (leading != null) leading,
Expanded(child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
text,
style: textStyle ?? const TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal
)
)
)),
if (trailing != null) trailing
],
),
),
),
);
_overlayEntry = OverlayEntry(
builder: (BuildContext context) =>
_showWidgetBasedOnPosition(
toastDuration != null ?
ToastCard(
child,
Duration(seconds: toastDuration),
fadeDuration: 500,
)
: child, toastPosition,
));
_overlayEntry = OverlayEntry(builder: (context) =>
_showWidgetBasedOnPosition(
toastDuration != null
? ToastCard(child, Duration(seconds: toastDuration))
: child,
toastPosition,
)
);
_isVisible = true;
overlayState!.insert(_overlayEntry!);
if (toastDuration != null) {
await Future.delayed(Duration(seconds: toastDuration));
await dismiss();
}
}
static Positioned _showWidgetBasedOnPosition(
Widget child, ToastPosition? toastPosition) {
Widget child,
ToastPosition? toastPosition
) {
switch (toastPosition) {
case ToastPosition.BOTTOM:
return Positioned(bottom: 60, left: 18, right: 18, child: child);
@@ -140,8 +180,7 @@ class ToastView {
case ToastPosition.BOTTOM_RIGHT:
return Positioned(bottom: 60, right: 18, child: child);
case ToastPosition.CENTER:
return Positioned(
top: 60, bottom: 60, left: 18, right: 18, child: child);
return Positioned(top: 60, bottom: 60, left: 18, right: 18, child: child);
case ToastPosition.CENTER_LEFT:
return Positioned(top: 60, bottom: 60, left: 18, child: child);
case ToastPosition.CENTER_RIGHT:
@@ -165,9 +204,14 @@ class ToastView {
}
class ToastCard extends StatefulWidget {
const ToastCard(this.child, this.duration,
{Key? key, this.fadeDuration = 500})
: super(key: key);
const ToastCard(
this.child,
this.duration,
{
Key? key,
this.fadeDuration = 300
}
) : super(key: key);
final Widget child;
final Duration duration;
@@ -199,8 +243,7 @@ class ToastStateFulState extends State<ToastCard>
vsync: this,
duration: Duration(milliseconds: widget.fadeDuration),
);
_fadeAnimation =
CurvedAnimation(parent: _animationController!, curve: Curves.easeIn);
_fadeAnimation = CurvedAnimation(parent: _animationController!, curve: Curves.easeIn);
super.initState();
showAnimation();
@@ -226,4 +269,4 @@ class ToastStateFulState extends State<ToastCard>
opacity: _fadeAnimation as Animation<double>,
child: widget.child,
);
}
}
+11 -26
View File
@@ -1,18 +1,13 @@
import 'package:contact/contact/model/capability_contact.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/build_utils.dart';
import 'package:core/utils/fps_manager.dart';
import 'package:dartz/dartz.dart';
import 'package:fcm/model/firebase_capability.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:forward/forward/capability_forward.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -77,7 +72,6 @@ abstract class BaseController extends GetxController
final AppToast _appToast = Get.find<AppToast>();
final viewState = Rx<Either<Failure, Success>>(Right(UIState.idle));
FpsCallback? fpsCallback;
@@ -137,7 +131,12 @@ abstract class BaseController extends GetxController
if (failure.exception is NoNetworkError) {
return true;
} else if (failure.exception is BadCredentialsException) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).badCredentials);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).badCredentials);
}
checkAuthenticationTypeWhenLogout();
return true;
}
@@ -152,8 +151,6 @@ abstract class BaseController extends GetxController
}
final appToast = Get.find<AppToast>();
final imagePaths = Get.find<ImagePaths>();
final responsiveUtils = Get.find<ResponsiveUtils>();
String messageError = '';
if (error is MethodLevelErrors) {
@@ -165,19 +162,7 @@ abstract class BaseController extends GetxController
}
if (messageError.isNotEmpty && currentContext != null && currentOverlayContext != null) {
appToast.showBottomToast(
currentOverlayContext!,
messageError,
leadingIcon: SvgPicture.asset(
imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!));
appToast.showToastErrorMessage(currentOverlayContext!, messageError);
}
}
@@ -262,18 +247,18 @@ abstract class BaseController extends GetxController
}
bool fcmEnabled(Session? session, AccountId? accountId) {
bool _fcmEnabled = false;
bool fcmEnabled = false;
try {
requireCapability(session!, accountId!, [FirebaseCapability.fcmIdentifier]);
if (AppConfig.fcmAvailable) {
_fcmEnabled = true;
fcmEnabled = true;
} else {
_fcmEnabled = false;
fcmEnabled = false;
}
} catch (e) {
logError('BaseController::fcmEnabled(): exception: $e');
}
return _fcmEnabled;
return fcmEnabled;
}
void goToLogin({LoginArguments? arguments}) {
@@ -1,5 +1,4 @@
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter_date_range_picker/multiple_view_date_range_picker.dart';
@@ -54,36 +53,26 @@ mixin DateRangePickerMixin {
DateTime? endDate,
{Function(DateTime? startDate, DateTime? endDate)? onCallbackAction}
) {
final _appToast = Get.find<AppToast>();
final _imagePaths = Get.find<ImagePaths>();
final appToast = Get.find<AppToast>();
if (startDate == null) {
_appToast.showToastWithIcon(
appToast.showToastErrorMessage(
context,
textColor: Colors.black,
message: AppLocalizations.of(context).toastMessageErrorWhenSelectStartDateIsEmpty,
icon: _imagePaths.icNotConnection
);
AppLocalizations.of(context).toastMessageErrorWhenSelectStartDateIsEmpty);
return;
}
if (endDate == null) {
_appToast.showToastWithIcon(
appToast.showToastErrorMessage(
context,
textColor: Colors.black,
message: AppLocalizations.of(context).toastMessageErrorWhenSelectEndDateIsEmpty,
icon: _imagePaths.icNotConnection
);
AppLocalizations.of(context).toastMessageErrorWhenSelectEndDateIsEmpty);
return;
}
if (endDate.isBefore(startDate)) {
_appToast.showToastWithIcon(
appToast.showToastErrorMessage(
context,
textColor: Colors.black,
message: AppLocalizations.of(context).toastMessageErrorWhenSelectDateIsInValid,
icon: _imagePaths.icNotConnection
);
AppLocalizations.of(context).toastMessageErrorWhenSelectDateIsInValid);
return;
}
@@ -872,8 +872,10 @@ class ComposerController extends BaseController {
void _pickFileFailure(Failure failure) {
if (failure is LocalFilePickerFailure) {
if (currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments);
}
}
}
@@ -1,14 +1,10 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/utils/build_utils.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
@@ -51,8 +47,6 @@ class DestinationPickerController extends BaseMailboxController {
final _uuid = Get.find<Uuid>();
final _appToast = Get.find<AppToast>();
final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
final SearchMailboxInteractor _searchMailboxInteractor;
final CreateNewMailboxInteractor _createNewMailboxInteractor;
@@ -318,19 +312,9 @@ class DestinationPickerController extends BaseMailboxController {
void openCreateNewMailboxView(BuildContext context) async {
if (mailboxDestination.value == null) {
_appToast.showBottomToast(
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox,
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox);
} else {
destinationScreenType.value = DestinationScreenType.createNewMailbox;
_createListMailboxNameAsStringInMailboxLocation();
@@ -363,20 +347,7 @@ class DestinationPickerController extends BaseMailboxController {
if (exception is ErrorMethodResponse) {
messageError = exception.description ?? AppLocalizations.of(currentContext!).create_new_mailbox_failure;
}
_appToast.showBottomToast(
currentOverlayContext!,
messageError,
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(currentOverlayContext!, messageError);
}
}
@@ -409,19 +380,9 @@ class DestinationPickerController extends BaseMailboxController {
FocusScope.of(context).unfocus();
if (mailboxDestination.value == null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox,
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox);
return;
}
@@ -212,11 +212,12 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
taskId: success.taskId,
attachment: success.attachment));
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).your_download_has_started,
iconColor: AppColor.primaryColor,
icon: imagePaths.icDownload);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).your_download_has_started,
leadingSVGIconColor: AppColor.primaryColor,
leadingSVGIcon: imagePaths.icDownload);
}
} else if (success is DownloadingAttachmentForWeb) {
final percent = success.progress.round();
@@ -445,8 +446,11 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
_downloadAttachmentsAction(attachments);
break;
case PermissionStatus.permanentlyDenied:
if (context.mounted) {
_appToast.showToast(AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments);
if (context.mounted && currentOverlayContext != null && currentContext != null) {
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments,
);
}
break;
default: {
@@ -456,8 +460,11 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
_downloadAttachmentsAction(attachments);
break;
default:
if (context.mounted) {
_appToast.showToast(AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments);
if (context.mounted && currentOverlayContext != null && currentContext != null) {
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments,
);
}
break;
}
@@ -477,8 +484,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _downloadAttachmentsFailure(DownloadAttachmentsFailure failure) {
if (currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).attachment_download_failed);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).attachment_download_failed);
}
}
@@ -526,8 +535,11 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _exportAttachmentFailureAction(ExportAttachmentFailure failure) {
if (failure.exception is! CancelDownloadFileException) {
popBack();
if (currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).attachment_download_failed);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).attachment_download_failed);
}
}
}
@@ -550,8 +562,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
if (openResult.type != open_file.ResultType.done) {
logError('SingleEmailController::_openDownloadedPreviewWorkGroupDocument(): no preview available');
if (currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).noPreviewAvailable);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).noPreviewAvailable);
}
}
}
@@ -587,13 +601,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
log('SingleEmailController::_downloadAttachmentForWebFailureAction(): $failure');
mailboxDashBoardController.deleteDownloadTask(failure.taskId);
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);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).attachment_download_failed);
}
}
@@ -682,7 +693,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _moveToMailboxSuccess(MoveToMailboxSuccess success) {
mailboxDashBoardController.dispatchState(Right(success));
if (success.moveAction == MoveAction.moving && currentContext != null && currentOverlayContext != null) {
_appToast.showBottomToast(
_appToast.showToastMessage(
currentOverlayContext!,
success.emailActionType.getToastMessageMoveToMailboxSuccess(currentContext!, destinationPath: success.destinationPath),
actionName: AppLocalizations.of(currentContext!).undo,
@@ -694,17 +705,11 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
mailboxDashBoardController.sessionCurrent!,
success.emailActionType));
},
leadingIcon: SvgPicture.asset(
imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.fill),
leadingSVGIcon: imagePaths.icFolderMailbox,
leadingSVGIconColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(imagePaths.icUndo),
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!)
actionIcon: SvgPicture.asset(imagePaths.icUndo)
);
}
}
@@ -931,53 +936,23 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
if (_sendReceiptToSenderInteractor == null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageNotSupportMdnWhenSendReceipt,
leadingIcon: SvgPicture.asset(
imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageNotSupportMdnWhenSendReceipt);
return;
}
if (_identitySelected == null || _identitySelected?.id == null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageCannotFoundIdentityWhenSendReceipt,
leadingIcon: SvgPicture.asset(
imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageCannotFoundIdentityWhenSendReceipt);
return;
}
if (currentEmail == null || _currentEmailId == null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageCannotFoundEmailIdWhenSendReceipt,
leadingIcon: SvgPicture.asset(
imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageCannotFoundEmailIdWhenSendReceipt);
return;
}
@@ -1027,18 +1002,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _sendReceiptToSenderSuccess(SendReceiptToSenderSuccess success) {
log('SingleEmailController::_sendReceiptToSenderSuccess(): ${success.mdn.toString()}');
if (currentContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageSendReceiptSuccess,
leadingIcon: SvgPicture.asset(
imagePaths.icReadReceiptMessage,
width: 24,
height: 24,
fit: BoxFit.fill),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageSendReceiptSuccess,
leadingSVGIcon: imagePaths.icReadReceiptMessage);
}
}
@@ -1152,10 +1119,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _createNewRuleFilterSuccess(CreateNewRuleFilterSuccess success) {
if (success.newListRules.isNotEmpty == true) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).newFilterWasCreated,
icon: imagePaths.icSelected);
AppLocalizations.of(currentContext!).newFilterWasCreated);
}
}
}
@@ -509,19 +509,11 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
void _createNewMailboxSuccess(CreateNewMailboxSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(currentContext!).new_mailbox_is_created(success.newMailbox.name?.name ?? ''),
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).new_mailbox_is_created(success.newMailbox.name?.name ?? ''),
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icFolderMailbox);
}
_refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
@@ -534,20 +526,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
if (exception is ErrorMethodResponse) {
messageError = exception.description ?? AppLocalizations.of(currentContext!).create_new_mailbox_failure;
}
_appToast.showBottomToast(
currentOverlayContext!,
messageError,
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
_appToast.showToastErrorMessage(currentOverlayContext!, messageError);
}
}
@@ -685,11 +664,11 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
jmap.State? currentMailboxState
) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).delete_mailboxes_successfully,
icon: _imagePaths.icSelected);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).delete_mailboxes_successfully);
}
if (listMailboxIdDeleted.contains(selectedMailbox?.id)) {
_switchBackToMailboxDefault();
_closeEmailViewIfMailboxDisabledOrNotExist(listMailboxIdDeleted);
@@ -772,10 +751,11 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
void _deleteMailboxFailure(DeleteMultipleMailboxFailure failure) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).delete_mailboxes_failure,
icon: _imagePaths.icDeleteToast);
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).delete_mailboxes_failure,
leadingSVGIcon: _imagePaths.icDeleteToast
);
}
}
@@ -810,7 +790,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
if (success.moveAction == MoveAction.moving
&& currentOverlayContext != null
&& currentContext != null) {
_appToast.showBottomToast(
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).moved_to_mailbox(
success.destinationMailboxName?.name ?? AppLocalizations.of(currentContext!).allMailboxes),
@@ -822,17 +802,11 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
destinationMailboxId: success.parentId,
parentId: success.destinationMailboxId));
},
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
leadingSVGIcon: _imagePaths.icFolderMailbox,
leadingSVGIconColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
actionIcon: SvgPicture.asset(_imagePaths.icUndo));
}
_refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
@@ -1106,7 +1080,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
{List<MailboxId>? listDescendantMailboxIds}
) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showBottomToast(
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMsgHideMailboxSuccess,
actionName: AppLocalizations.of(currentContext!).undo,
@@ -1114,19 +1088,11 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
mailboxIdSubscribed,
listDescendantMailboxIds: listDescendantMailboxIds
),
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill
),
leadingSVGIcon: _imagePaths.icFolderMailbox,
leadingSVGIconColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!)
);
actionIcon: SvgPicture.asset(_imagePaths.icUndo));
}
}
@@ -37,7 +37,6 @@ class BottomBarSelectionMailboxWidget extends StatelessWidget {
Widget _buildMailboxActionButton(BuildContext context, MailboxActions actions) {
return Expanded(child: (ButtonBuilder(actions.getContextMenuIcon(_imagePaths))
..key(const Key('button_move_all_mailbox'))
..radiusSplash(8)
..padding(const EdgeInsets.all(8))
..tooltip(actions.getTitleContextMenu(context))
@@ -262,10 +262,10 @@ class MailboxDashBoardController extends ReloadableController {
log('MailboxDashBoardController::onData():success $success');
if (success is SendingEmailState) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).your_email_being_sent,
icon: _imagePaths.icSendToast,
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).your_email_being_sent,
leadingSVGIcon: _imagePaths.icSendToast
);
}
} else if (success is GetEmailStateToRefreshSuccess) {
@@ -301,11 +301,10 @@ class MailboxDashBoardController extends ReloadableController {
(success) {
if (success is SendEmailSuccess) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
textColor: AppColor.primaryColor,
message: AppLocalizations.of(currentContext!).message_has_been_sent_successfully,
icon: _imagePaths.icSendToast);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).message_has_been_sent_successfully,
leadingSVGIcon: _imagePaths.icSendSuccessToast);
}
} else if (success is SaveEmailAsDraftsSuccess) {
log('MailboxDashBoardController::onDone(): SaveEmailAsDraftsSuccess');
@@ -580,23 +579,16 @@ class MailboxDashBoardController extends ReloadableController {
void _saveEmailAsDraftsSuccess(SaveEmailAsDraftsSuccess success) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(currentContext!).drafts_saved,
actionName: AppLocalizations.of(currentContext!).discard,
onActionClick: () => _discardEmail(success.emailAsDrafts),
leadingIcon: SvgPicture.asset(
_imagePaths.icMailboxDrafts,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!)
);
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).drafts_saved,
actionName: AppLocalizations.of(currentContext!).discard,
onActionClick: () => _discardEmail(success.emailAsDrafts),
leadingSVGIcon: _imagePaths.icMailboxDrafts,
leadingSVGIconColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo));
}
}
@@ -606,30 +598,24 @@ class MailboxDashBoardController extends ReloadableController {
void _moveToMailboxSuccess(MoveToMailboxSuccess success) {
if (success.moveAction == MoveAction.moving && currentContext != null && currentOverlayContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
success.emailActionType.getToastMessageMoveToMailboxSuccess(currentContext!, destinationPath: success.destinationPath),
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () {
_revertedToOriginalMailbox(MoveToMailboxRequest(
{success.destinationMailboxId: [success.emailId]},
success.currentMailboxId,
MoveAction.undo,
sessionCurrent!,
success.emailActionType));
},
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!)
);
_appToast.showToastMessage(
currentOverlayContext!,
success.emailActionType.getToastMessageMoveToMailboxSuccess(currentContext!, destinationPath: success.destinationPath),
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () {
_revertedToOriginalMailbox(MoveToMailboxRequest(
{success.destinationMailboxId: [success.emailId]},
success.currentMailboxId,
MoveAction.undo,
sessionCurrent!,
success.emailActionType
));
},
leadingSVGIcon: _imagePaths.icFolderMailbox,
leadingSVGIconColor: Colors.white,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo));
}
}
@@ -655,12 +641,12 @@ class MailboxDashBoardController extends ReloadableController {
}
void _deleteEmailPermanentlySuccess(DeleteEmailPermanentlySuccess success) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
widthToast: _responsiveUtils.isDesktop(currentContext!) ? 360 : null,
message: AppLocalizations.of(currentContext!).toast_message_delete_a_email_permanently_success,
icon: _imagePaths.icDeleteToast);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toast_message_delete_a_email_permanently_success,
leadingSVGIcon: _imagePaths.icDeleteToast
);
}
}
@@ -704,16 +690,18 @@ class MailboxDashBoardController extends ReloadableController {
readActions = success.readActions;
}
if (currentContext != null && readActions != null && currentOverlayContext != null) {
if (readActions != null && currentContext != null && currentOverlayContext != null) {
final message = readActions == ReadActions.markAsUnread
? AppLocalizations.of(currentContext!).marked_message_toast(AppLocalizations.of(currentContext!).unread)
: AppLocalizations.of(currentContext!).marked_message_toast(AppLocalizations.of(currentContext!).read);
_appToast.showToastWithIcon(
currentOverlayContext!,
message: message,
icon: readActions == ReadActions.markAsUnread
? _imagePaths.icUnreadToast
: _imagePaths.icReadToast);
? AppLocalizations.of(currentContext!).marked_message_toast(AppLocalizations.of(currentContext!).unread)
: AppLocalizations.of(currentContext!).marked_message_toast(AppLocalizations.of(currentContext!).read);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message,
leadingSVGIcon: readActions == ReadActions.markAsUnread
? _imagePaths.icUnreadToast
: _imagePaths.icReadToast
);
}
}
@@ -741,16 +729,19 @@ class MailboxDashBoardController extends ReloadableController {
countMarkStarSuccess = success.countMarkStarSuccess;
}
if (currentContext != null && markStarAction != null && currentOverlayContext != null) {
if (markStarAction != null) {
final message = markStarAction == MarkStarAction.unMarkStar
? AppLocalizations.of(currentContext!).marked_unstar_multiple_item(countMarkStarSuccess)
: AppLocalizations.of(currentContext!).marked_star_multiple_item(countMarkStarSuccess);
_appToast.showToastWithIcon(
? AppLocalizations.of(currentContext!).marked_unstar_multiple_item(countMarkStarSuccess)
: AppLocalizations.of(currentContext!).marked_star_multiple_item(countMarkStarSuccess);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastMessage(
currentOverlayContext!,
message: message,
icon: markStarAction == MarkStarAction.unMarkStar
? _imagePaths.icUnStar
: _imagePaths.icStar);
message,
leadingSVGIcon: markStarAction == MarkStarAction.unMarkStar
? _imagePaths.icUnStar
: _imagePaths.icStar);
}
}
}
@@ -932,36 +923,31 @@ class MailboxDashBoardController extends ReloadableController {
currentOverlayContext != null &&
emailActionType != null &&
moveAction == MoveAction.moving) {
_appToast.showBottomToast(
currentOverlayContext!,
emailActionType.getToastMessageMoveToMailboxSuccess(
currentContext!,
destinationPath: destinationPath),
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () {
final newCurrentMailboxId = destinationMailboxId;
final newDestinationMailboxId = currentMailboxId;
if (newCurrentMailboxId != null && newDestinationMailboxId != null) {
_revertedSelectionEmailToOriginalMailbox(MoveToMailboxRequest(
{newCurrentMailboxId: movedEmailIds},
newDestinationMailboxId,
MoveAction.undo,
sessionCurrent!,
emailActionType!,
destinationPath: destinationPath));
}
},
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!)
_appToast.showToastMessage(
currentOverlayContext!,
emailActionType.getToastMessageMoveToMailboxSuccess(
currentContext!,
destinationPath: destinationPath),
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () {
final newCurrentMailboxId = destinationMailboxId;
final newDestinationMailboxId = currentMailboxId;
if (newCurrentMailboxId != null && newDestinationMailboxId != null) {
_revertedSelectionEmailToOriginalMailbox(MoveToMailboxRequest(
{newCurrentMailboxId: movedEmailIds},
newDestinationMailboxId,
MoveAction.undo,
sessionCurrent!,
emailActionType!,
destinationPath: destinationPath
));
}
},
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icFolderMailbox,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
);
}
}
@@ -1095,12 +1081,10 @@ class MailboxDashBoardController extends ReloadableController {
}
void _emptyTrashFolderSuccess(EmptyTrashFolderSuccess success) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
widthToast: _responsiveUtils.isDesktop(currentContext!) ? 360 : null,
message: AppLocalizations.of(currentContext!).toast_message_empty_trash_folder_success,
icon: _imagePaths.icDeleteToast);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toast_message_empty_trash_folder_success);
}
}
@@ -1122,12 +1106,10 @@ class MailboxDashBoardController extends ReloadableController {
listEmailIdResult = success.emailIds;
}
if (currentContext != null && currentOverlayContext != null && listEmailIdResult.isNotEmpty) {
_appToast.showToastWithIcon(
currentOverlayContext!,
widthToast: _responsiveUtils.isDesktop(currentContext!) ? 360 : null,
message: AppLocalizations.of(currentContext!).toast_message_delete_multiple_email_permanently_success(listEmailIdResult.length),
icon: _imagePaths.icDeleteToast);
if (currentOverlayContext != null && currentContext != null && listEmailIdResult.isNotEmpty) {
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toast_message_delete_multiple_email_permanently_success(listEmailIdResult.length));
}
}
@@ -1237,21 +1219,17 @@ class MailboxDashBoardController extends ReloadableController {
if (success is MarkAsMailboxReadAllSuccess) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
widthToast: _responsiveUtils.isDesktop(currentContext!) ? 360 : null,
message: AppLocalizations.of(currentContext!)
.toastMessageMarkAsMailboxReadSuccess(success.mailboxName.name),
icon: _imagePaths.icReadToast);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageMarkAsMailboxReadSuccess(success.mailboxName.name),
leadingSVGIcon: _imagePaths.icReadToast);
}
} else if (success is MarkAsMailboxReadHasSomeEmailFailure) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
widthToast: _responsiveUtils.isDesktop(currentContext!) ? 360 : null,
message: AppLocalizations.of(currentContext!)
.toastMessageMarkAsMailboxReadHasSomeEmailFailure(success.mailboxName.name, success.countEmailsRead),
icon: _imagePaths.icReadToast);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageMarkAsMailboxReadHasSomeEmailFailure(success.mailboxName.name, success.countEmailsRead),
leadingSVGIcon: _imagePaths.icReadToast);
}
}
}
@@ -1347,10 +1325,9 @@ class MailboxDashBoardController extends ReloadableController {
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
icon: _imagePaths.icChecked);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
}
vacationResponse.value = success.listVacationResponse.first;
log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
@@ -1623,13 +1600,11 @@ class MailboxDashBoardController extends ReloadableController {
}
void _showToastSendMessageFailure(String message) {
if (currentOverlayContext != null) {
_appToast.showToastWithIcon(
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
textColor: AppColor.toastErrorBackgroundColor,
message: message,
icon: _imagePaths.icSendToast
);
message,
leadingSVGIcon: _imagePaths.icSendSuccessToast);
}
}
@@ -123,10 +123,9 @@ class EmailRulesController extends BaseController {
void _createNewRuleFilterSuccess(CreateNewRuleFilterSuccess success) {
if (success.newListRules.isNotEmpty == true) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).newFilterWasCreated,
icon: _imagePaths.icSelected);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).newFilterWasCreated);
}
listEmailRule.value = success.newListRules;
listEmailRule.refresh();
@@ -176,10 +175,9 @@ class EmailRulesController extends BaseController {
void _editEmailRuleFilterSuccess(EditEmailRuleFilterSuccess success) {
if (success.listRulesUpdated.isNotEmpty == true) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).yourFilterHasBeenUpdated,
icon: _imagePaths.icSelected);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).yourFilterHasBeenUpdated);
}
listEmailRule.value = success.listRulesUpdated;
listEmailRule.refresh();
@@ -239,11 +237,9 @@ class EmailRulesController extends BaseController {
void _handleDeleteEmailRuleSuccess(DeleteEmailRuleSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).toastMessageDeleteEmailRuleSuccessfully,
icon: _imagePaths.icSelected,
);
AppLocalizations.of(currentContext!).toastMessageDeleteEmailRuleSuccessfully);
}
if (success.rules?.isNotEmpty == true) {
@@ -151,11 +151,9 @@ class ForwardController extends BaseController {
void _handleDeleteRecipientSuccess(DeleteRecipientInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).toastMessageDeleteRecipientSuccessfully,
icon: _imagePaths.icSelected,
);
AppLocalizations.of(currentContext!).toastMessageDeleteRecipientSuccessfully);
}
currentForward.value = success.forward;
@@ -255,11 +253,9 @@ class ForwardController extends BaseController {
void _handleAddRecipientsSuccess(AddRecipientsInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).toastMessageAddRecipientsSuccessfully,
icon: _imagePaths.icSelected,
);
AppLocalizations.of(currentContext!).toastMessageAddRecipientsSuccessfully);
}
currentForward.value = success.forward;
@@ -283,13 +279,11 @@ class ForwardController extends BaseController {
void _handleEditLocalCopySuccess(EditLocalCopyInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: success.forward.localCopy ?
AppLocalizations.of(currentContext!).toastMessageLocalCopyEnable :
AppLocalizations.of(currentContext!).toastMessageLocalCopyDisable,
icon: _imagePaths.icSelected,
);
success.forward.localCopy
? AppLocalizations.of(currentContext!).toastMessageLocalCopyEnable
: AppLocalizations.of(currentContext!).toastMessageLocalCopyDisable);
}
currentForward.value = success.forward;
@@ -133,19 +133,9 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
controller.addRecipientAction(context, listRecipientsSelected);
},
onExceptionCallback: () {
_appToast.showBottomToast(
_appToast.showToastErrorMessage(
context,
AppLocalizations.of(context).incorrectEmailFormat,
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(context));
AppLocalizations.of(context).incorrectEmailFormat);
},
);
}
@@ -3,7 +3,6 @@ import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
@@ -41,7 +40,6 @@ class MailboxVisibilityController extends BaseMailboxController {
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
final _appToast = Get.find<AppToast>();
final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
final mailboxListScrollController = ScrollController();
MailboxVisibilityController(
@@ -209,29 +207,22 @@ class MailboxVisibilityController extends BaseMailboxController {
{List<MailboxId>? listDescendantMailboxIds}
) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMsgHideMailboxSuccess,
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () => _subscribeMailboxAction(
SubscribeMailboxRequest(
mailboxIdSubscribed,
MailboxSubscribeState.enabled,
MailboxSubscribeAction.subscribe
)
),
leadingIcon: SvgPicture.asset(
_imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill
),
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!)
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMsgHideMailboxSuccess,
actionName: AppLocalizations.of(currentContext!).undo,
onActionClick: () => _subscribeMailboxAction(
SubscribeMailboxRequest(
mailboxIdSubscribed,
MailboxSubscribeState.enabled,
MailboxSubscribeAction.subscribe
)
),
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icFolderMailbox,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
actionIcon: SvgPicture.asset(_imagePaths.icUndo),
);
}
}
@@ -41,7 +41,6 @@ import 'package:tmail_ui_user/main/routes/route_utils.dart';
class ManageAccountDashBoardController extends ReloadableController {
final _appToast = Get.find<AppToast>();
final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
GetAllVacationInteractor? _getAllVacationInteractor;
@@ -268,10 +267,9 @@ class ManageAccountDashBoardController extends ReloadableController {
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
icon: _imagePaths.icChecked);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
}
vacationResponse.value = success.listVacationResponse.first;
log('ManageAccountDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
@@ -189,10 +189,9 @@ class IdentitiesController extends BaseController {
void _createNewIdentitySuccess(CreateNewIdentitySuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).you_have_created_a_new_identity,
icon: _imagePaths.icSelected);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).you_have_created_a_new_identity);
}
_refreshAllIdentities();
@@ -200,10 +199,9 @@ class IdentitiesController extends BaseController {
void _createNewDefaultIdentitySuccess(CreateNewDefaultIdentitySuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).you_have_created_a_new_default_identity,
icon: _imagePaths.icSelected);
AppLocalizations.of(currentContext!).you_have_created_a_new_default_identity);
}
_refreshAllIdentities();
@@ -231,10 +229,10 @@ class IdentitiesController extends BaseController {
void _deleteIdentitySuccess(DeleteIdentitySuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).identity_has_been_deleted,
icon: _imagePaths.icDeleteToast);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).identity_has_been_deleted,
leadingSVGIcon: _imagePaths.icDeleteToast);
}
_refreshAllIdentities();
@@ -314,10 +312,9 @@ class IdentitiesController extends BaseController {
void _editIdentitySuccess(EditIdentitySuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).you_are_changed_your_identity_successfully,
icon: _imagePaths.icSelected);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).you_are_changed_your_identity_successfully);
}
_refreshAllIdentities();
@@ -29,7 +29,6 @@ class VacationController extends BaseController {
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
final _appToast = Get.find<AppToast>();
final _imagePaths = Get.find<ImagePaths>();
final _settingController = Get.find<SettingsController>();
final _richTextControllerForWeb = Get.find<RichTextWebController>(tag: VacationUtils.vacationTagName);
@@ -249,33 +248,33 @@ class VacationController extends BaseController {
if (vacationPresentation.value.isEnabled) {
final fromDate = vacationPresentation.value.fromDate;
if (fromDate == null) {
_appToast.showToastWithIcon(
context,
bgColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
message: AppLocalizations.of(context).errorMessageWhenStartDateVacationIsEmpty);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).errorMessageWhenStartDateVacationIsEmpty);
}
return;
}
final vacationStopEnabled = vacationPresentation.value.vacationStopEnabled;
final toDate = vacationPresentation.value.toDate;
if (vacationStopEnabled && toDate != null && toDate.isBefore(fromDate)) {
_appToast.showToastWithIcon(
context,
bgColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
message: AppLocalizations.of(context).errorMessageWhenEndDateVacationIsInValid);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).errorMessageWhenEndDateVacationIsInValid);
}
return;
}
final messagePlainText = messageTextController.text;
final messageHtmlText = (BuildUtils.isWeb ? _vacationMessageHtmlText : await _getMessageHtmlText()) ?? '';
if (messagePlainText.isEmpty && messageHtmlText.isEmpty && context.mounted) {
_appToast.showToastWithIcon(
context,
bgColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
message: AppLocalizations.of(context).errorMessageWhenMessageVacationIsEmpty);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).errorMessageWhenMessageVacationIsEmpty);
}
return;
}
@@ -307,11 +306,10 @@ class VacationController extends BaseController {
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).vacationSettingSaved,
icon: _imagePaths.icChecked);
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).vacationSettingSaved);
}
currentVacation = success.listVacationResponse.first;
log('VacationController::_handleUpdateVacationSuccess(): $currentVacation');
@@ -3,7 +3,6 @@ import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:core/core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/base/base_controller.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
@@ -14,7 +13,6 @@ class NetworkConnectionController extends BaseController {
final _imagePaths = Get.find<ImagePaths>();
final Connectivity _connectivity;
final AppToast _appToast = Get.find<AppToast>();
final ResponsiveUtils _responsiveUtils = Get.find<ResponsiveUtils>();
bool _isEnableShowToastDisconnection = true;
@@ -84,24 +82,18 @@ class NetworkConnectionController extends BaseController {
void _showToastLostConnection() {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
AppLocalizations.of(currentContext!).no_internet_connection,
actionName: AppLocalizations.of(currentContext!).skip,
onActionClick: () {
_isEnableShowToastDisconnection = false;
ToastView.dismiss();
},
leadingIcon: SvgPicture.asset(
_imagePaths.icNotConnection,
width: 24,
height: 24,
fit: BoxFit.fill),
backgroundColor: AppColor.textFieldErrorBorderColor,
textColor: Colors.white,
textActionColor: Colors.white,
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!),
infinityToast: true,
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).no_internet_connection,
actionName: AppLocalizations.of(currentContext!).skip,
onActionClick: () {
_isEnableShowToastDisconnection = false;
ToastView.dismiss();
},
leadingSVGIcon: _imagePaths.icNotConnection,
backgroundColor: AppColor.textFieldErrorBorderColor,
textColor: Colors.white,
infinityToast: true,
);
}
}
@@ -1,5 +1,4 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/app_toast.dart';
@@ -281,20 +280,22 @@ class RulesFilterCreatorController extends BaseMailboxController {
final errorAction = _getErrorStringByInputValue(context, mailboxSelected.value?.name?.name);
if (errorAction?.isNotEmpty == true) {
errorRuleActionValue.value = errorAction;
_appToast.showToastWithIcon(
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
textColor: AppColor.toastErrorBackgroundColor,
message: AppLocalizations.of(currentContext!).this_field_cannot_be_blank);
AppLocalizations.of(currentContext!).this_field_cannot_be_blank);
}
return;
}
if (ruleConditionFieldSelected.value == null ||
ruleConditionComparatorSelected.value == null ||
emailRuleFilterActionSelected.value == null) {
_appToast.showToastWithIcon(
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(
currentOverlayContext!,
textColor: AppColor.toastErrorBackgroundColor,
message: AppLocalizations.of(currentContext!).toastErrorMessageWhenCreateNewRule);
AppLocalizations.of(currentContext!).toastErrorMessageWhenCreateNewRule);
}
return;
}
@@ -332,7 +332,7 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
void _moveMailboxSuccess(MoveMailboxSuccess success) {
if (success.moveAction == MoveAction.moving && currentOverlayContext != null && currentContext != null) {
_appToast.showBottomToast(
_appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).moved_to_mailbox(success.destinationMailboxName?.name ?? AppLocalizations.of(currentContext!).allMailboxes),
actionName: AppLocalizations.of(currentContext!).undo,
@@ -344,17 +344,11 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
parentId: success.destinationMailboxId)
);
},
leadingIcon: SvgPicture.asset(
imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill),
leadingSVGIconColor: Colors.white,
leadingSVGIcon: imagePaths.icFolderMailbox,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(imagePaths.icUndo),
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!)
actionIcon: SvgPicture.asset(imagePaths.icUndo)
);
}
@@ -396,11 +390,9 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
void _deleteMultipleMailboxSuccess(List<MailboxId> listMailboxIdDeleted, jmap.State? currentMailboxState) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastSuccessMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).delete_mailboxes_successfully,
icon: imagePaths.icSelected
);
AppLocalizations.of(currentContext!).delete_mailboxes_successfully);
}
if (listMailboxIdDeleted.contains(dashboardController.selectedMailbox.value?.id)) {
@@ -413,11 +405,9 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
void _deleteMailboxFailure(DeleteMultipleMailboxFailure failure) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
_appToast.showToastErrorMessage(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).delete_mailboxes_failure,
icon: imagePaths.icDeleteToast
);
AppLocalizations.of(currentContext!).delete_mailboxes_failure);
}
}
@@ -503,7 +493,7 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
{List<MailboxId>? listDescendantMailboxIds}
) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showBottomToast(
_appToast.showToastMessage(
currentOverlayContext!,
subscribeAction.getToastMessageSuccess(currentContext!),
actionName: AppLocalizations.of(currentContext!).undo,
@@ -520,18 +510,11 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
);
}
},
leadingIcon: SvgPicture.asset(
imagePaths.icFolderMailbox,
width: 24,
height: 24,
colorFilter: Colors.white.asFilter(),
fit: BoxFit.fill
),
leadingSVGIconColor: Colors.white,
leadingSVGIcon: imagePaths.icFolderMailbox,
backgroundColor: AppColor.toastSuccessBackgroundColor,
textColor: Colors.white,
textActionColor: Colors.white,
actionIcon: SvgPicture.asset(imagePaths.icUndo),
maxWidth: responsiveUtils.getMaxWidthToast(currentContext!)
);
}
}
@@ -71,17 +71,23 @@ class SessionController extends ReloadableController {
log('SessionController::_handleSessionFailure(): $failure');
if (failure is GetSessionFailure) {
final sessionException = failure.exception;
var errorMessage = '';
if (_checkUrlError(sessionException) && currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).wrongUrlMessage);
errorMessage = AppLocalizations.of(currentContext!).wrongUrlMessage;
} else if (sessionException is BadCredentialsException && currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).badCredentials);
errorMessage = AppLocalizations.of(currentContext!).badCredentials;
} else if (sessionException is UnknownError && currentContext != null) {
if (sessionException.message != null) {
_appToast.showErrorToast('[${sessionException.code}] ${sessionException.message}');
errorMessage = '[${sessionException.code}] ${sessionException.message}';
} else {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).unknownError);
errorMessage = AppLocalizations.of(currentContext!).unknownError;
}
}
logError('SessionController::_handleSessionFailure():errorMessage: $errorMessage');
if (errorMessage.isNotEmpty && currentOverlayContext != null && currentContext != null) {
_appToast.showToastErrorMessage(currentOverlayContext!, errorMessage);
}
}
}
@@ -642,10 +642,11 @@ class ThreadController extends BaseController with EmailActionController {
mailboxDashBoardController.filterMessageOption.value = newFilterOption;
_appToast.showToastWithIcon(
currentOverlayContext!,
message: newFilterOption.getMessageToast(context),
icon: newFilterOption.getIconToast(_imagePaths));
_appToast.showToastMessage(
context,
newFilterOption.getMessageToast(context),
leadingSVGIcon: newFilterOption.getIconToast(_imagePaths),
);
if (searchController.isSearchEmailRunning) {
_searchEmail();
@@ -126,20 +126,18 @@ class ThreadView extends GetWidget<ThreadController>
if ((!BuildUtils.isWeb || (BuildUtils.isWeb && controller.isSelectionEnabled()
&& controller.isSearchActive() && !_responsiveUtils.isDesktop(context)))
&& controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected.isNotEmpty) {
return Column(children: [
const Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2),
Padding(
padding: const EdgeInsets.all(10),
child: (BottomBarThreadSelectionWidget(
context,
_imagePaths,
_responsiveUtils,
controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected,
controller.mailboxDashBoardController.selectedMailbox.value)
..addOnPressEmailSelectionActionClick((actionType, selectionEmail) =>
controller.pressEmailSelectionAction(context, actionType, selectionEmail)))
.build()),
]);
return BottomBarThreadSelectionWidget(
_imagePaths,
_responsiveUtils,
controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected,
controller.mailboxDashBoardController.selectedMailbox.value,
onPressEmailSelectionActionClick: (actionType, selectionEmail) =>
controller.pressEmailSelectionAction(
context,
actionType,
selectionEmail
)
);
} else {
return const SizedBox.shrink();
}
@@ -1,114 +1,120 @@
import 'package:core/core.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/views/button/button_builder.dart';
import 'package:core/utils/build_utils.dart';
import 'package:flutter/material.dart';
import 'package:model/model.dart';
import 'package:model/email/email_action_type.dart';
import 'package:model/email/presentation_email.dart';
import 'package:model/extensions/list_presentation_email_extension.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
typedef OnPressEmailSelectionActionClick = void Function(EmailActionType, List<PresentationEmail>);
class BottomBarThreadSelectionWidget {
class BottomBarThreadSelectionWidget extends StatelessWidget{
final BuildContext _context;
final ImagePaths _imagePaths;
final ResponsiveUtils _responsiveUtils;
final List<PresentationEmail> _listSelectionEmail;
final PresentationMailbox? _currentMailbox;
final OnPressEmailSelectionActionClick? onPressEmailSelectionActionClick;
OnPressEmailSelectionActionClick? _onPressEmailSelectionActionClick;
BottomBarThreadSelectionWidget(
this._context,
const BottomBarThreadSelectionWidget(
this._imagePaths,
this._responsiveUtils,
this._listSelectionEmail,
this._currentMailbox,
{
super.key,
this.onPressEmailSelectionActionClick,
}
);
void addOnPressEmailSelectionActionClick(OnPressEmailSelectionActionClick onPressEmailSelectionActionClick) {
_onPressEmailSelectionActionClick = onPressEmailSelectionActionClick;
}
Widget build() {
@override
Widget build(BuildContext context) {
return Container(
key: const Key('bottom_bar_thread_selection_widget'),
alignment: Alignment.center,
color: Colors.white,
child: MediaQuery(
data: const MediaQueryData(padding: EdgeInsets.zero),
child: _buildListOptionButton()
)
);
}
Widget _buildListOptionButton() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if(_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_listSelectionEmail.isAllEmailRead ? _imagePaths.icUnread : _imagePaths.icRead)
decoration: const BoxDecoration(
border: Border(top: BorderSide(
color: AppColor.lineItemListColor,
width: 0.2,
)),
color: Colors.white
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if(_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_listSelectionEmail.isAllEmailRead ? _imagePaths.icUnread : _imagePaths.icRead)
..key(const Key('button_mark_read_email'))
..paddingIcon(const EdgeInsets.symmetric(horizontal: 8, vertical: 4))
..padding(const EdgeInsets.all(8))
..radiusSplash(8)
..textStyle(const TextStyle(fontSize: 12, color: AppColor.colorTextButton))
..onPressActionClick(() {
if (_onPressEmailSelectionActionClick != null) {
_onPressEmailSelectionActionClick!(
_listSelectionEmail.isAllEmailRead ? EmailActionType.markAsUnread : EmailActionType.markAsRead,
_listSelectionEmail);
}})
..text(_textButtonMarkAsRead, isVertical: _responsiveUtils.isMobile(_context)))
onPressEmailSelectionActionClick?.call(
_listSelectionEmail.isAllEmailRead ? EmailActionType.markAsUnread : EmailActionType.markAsRead,
_listSelectionEmail
);
})
..text(_getTextButtonMarkAsRead(context), isVertical: _responsiveUtils.isMobile(context)))
.build()),
Expanded(child: (ButtonBuilder(_listSelectionEmail.isAllEmailStarred ? _imagePaths.icUnStar : _imagePaths.icStar)
Expanded(child: (ButtonBuilder(_listSelectionEmail.isAllEmailStarred ? _imagePaths.icUnStar : _imagePaths.icStar)
..key(const Key('button_mark_as_star_email'))
..paddingIcon(const EdgeInsets.symmetric(horizontal: 8, vertical: 4))
..padding(const EdgeInsets.all(8))
..radiusSplash(8)
..textStyle(const TextStyle(fontSize: 12, color: AppColor.colorTextButton))
..onPressActionClick(() {
if (_onPressEmailSelectionActionClick != null) {
_onPressEmailSelectionActionClick!(
_listSelectionEmail.isAllEmailStarred ? EmailActionType.unMarkAsStarred : EmailActionType.markAsStarred,
_listSelectionEmail);
}})
..text(_textButtonMarkAsStar, isVertical: _responsiveUtils.isMobile(_context)))
onPressEmailSelectionActionClick?.call(
_listSelectionEmail.isAllEmailStarred ? EmailActionType.unMarkAsStarred : EmailActionType.markAsStarred,
_listSelectionEmail
);
})
..text(_getTextButtonMarkAsStar(context), isVertical: _responsiveUtils.isMobile(context)))
.build()),
if (_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_imagePaths.icMove)
if (_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_imagePaths.icMove)
..key(const Key('button_move_to_mailbox'))
..paddingIcon(const EdgeInsets.symmetric(horizontal: 8, vertical: 4))
..padding(const EdgeInsets.all(8))
..radiusSplash(8)
..textStyle(const TextStyle(fontSize: 12, color: AppColor.colorTextButton))
..onPressActionClick(() {
if (_onPressEmailSelectionActionClick != null) {
_onPressEmailSelectionActionClick!(EmailActionType.moveToMailbox, _listSelectionEmail);
}})
..text(_textButtonMove, isVertical: _responsiveUtils.isMobile(_context)))
onPressEmailSelectionActionClick?.call(EmailActionType.moveToMailbox, _listSelectionEmail);
})
..text(_getTextButtonMove(context), isVertical: _responsiveUtils.isMobile(context)))
.build()),
if (_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_currentMailbox?.isSpam == true ? _imagePaths.icNotSpam : _imagePaths.icSpam)
if (_currentMailbox?.isDrafts == false)
Expanded(child: (ButtonBuilder(_currentMailbox?.isSpam == true ? _imagePaths.icNotSpam : _imagePaths.icSpam)
..key(const Key('button_move_to_spam'))
..paddingIcon(const EdgeInsets.symmetric(horizontal: 8, vertical: 4))
..padding(const EdgeInsets.all(8))
..radiusSplash(8)
..textStyle(const TextStyle(fontSize: 12, color: AppColor.colorTextButton))
..onPressActionClick(() {
if (_currentMailbox?.isSpam == true) {
_onPressEmailSelectionActionClick?.call(EmailActionType.unSpam, _listSelectionEmail);
onPressEmailSelectionActionClick?.call(EmailActionType.unSpam, _listSelectionEmail);
} else {
_onPressEmailSelectionActionClick?.call(EmailActionType.moveToSpam, _listSelectionEmail);
onPressEmailSelectionActionClick?.call(EmailActionType.moveToSpam, _listSelectionEmail);
}
})
..text(_textButtonSpam, isVertical: _responsiveUtils.isMobile(_context)))
..text(_getTextButtonSpam(context), isVertical: _responsiveUtils.isMobile(context)))
.build()),
Expanded(child: (ButtonBuilder(canDeletePermanently ? _imagePaths.icDeleteComposer : _imagePaths.icDelete)
Expanded(child: (ButtonBuilder(canDeletePermanently ? _imagePaths.icDeleteComposer : _imagePaths.icDelete)
..key(const Key('button_delete_email'))
..iconColor(canDeletePermanently ? AppColor.colorDeletePermanentlyButton : AppColor.primaryColor)
..paddingIcon(const EdgeInsets.symmetric(horizontal: 8, vertical: 4))
..padding(const EdgeInsets.all(8))
..radiusSplash(8)
..textStyle(const TextStyle(fontSize: 12, color: AppColor.colorTextButton))
..onPressActionClick(() {
if (canDeletePermanently) {
_onPressEmailSelectionActionClick?.call(EmailActionType.deletePermanently, _listSelectionEmail);
onPressEmailSelectionActionClick?.call(EmailActionType.deletePermanently, _listSelectionEmail);
} else {
_onPressEmailSelectionActionClick?.call(EmailActionType.moveToTrash, _listSelectionEmail);
onPressEmailSelectionActionClick?.call(EmailActionType.moveToTrash, _listSelectionEmail);
}
})
..text(_textButtonDelete, isVertical: _responsiveUtils.isMobile(_context)))
..text(_getTextButtonDelete(context), isVertical: _responsiveUtils.isMobile(context)))
.build())
]
]
)
);
}
@@ -116,43 +122,43 @@ class BottomBarThreadSelectionWidget {
return _currentMailbox?.isTrash == true || _currentMailbox?.isDrafts == true;
}
String? get _textButtonMarkAsRead {
if (!_isMailboxDashboardSplitView(_context)) {
String? _getTextButtonMarkAsRead(BuildContext context) {
if (!_isMailboxDashboardSplitView(context)) {
return _listSelectionEmail.isAllEmailRead
? AppLocalizations.of(_context).unread
: AppLocalizations.of(_context).read;
? AppLocalizations.of(context).unread
: AppLocalizations.of(context).read;
}
return null;
}
String? get _textButtonMarkAsStar {
if (!_isMailboxDashboardSplitView(_context)) {
String? _getTextButtonMarkAsStar(BuildContext context) {
if (!_isMailboxDashboardSplitView(context)) {
return _listSelectionEmail.isAllEmailStarred
? AppLocalizations.of(_context).un_star
: AppLocalizations.of(_context).star;
? AppLocalizations.of(context).un_star
: AppLocalizations.of(context).star;
}
return null;
}
String? get _textButtonMove {
if (!_isMailboxDashboardSplitView(_context)) {
return AppLocalizations.of(_context).move;
String? _getTextButtonMove(BuildContext context) {
if (!_isMailboxDashboardSplitView(context)) {
return AppLocalizations.of(context).move;
}
return null;
}
String? get _textButtonSpam {
if (!_isMailboxDashboardSplitView(_context)) {
String? _getTextButtonSpam(BuildContext context) {
if (!_isMailboxDashboardSplitView(context)) {
return _currentMailbox?.isSpam == true
? AppLocalizations.of(_context).un_spam
: AppLocalizations.of(_context).spam;
? AppLocalizations.of(context).un_spam
: AppLocalizations.of(context).spam;
}
return null;
}
String? get _textButtonDelete {
if (!_isMailboxDashboardSplitView(_context)) {
return AppLocalizations.of(_context).delete;
String? _getTextButtonDelete(BuildContext context) {
if (!_isMailboxDashboardSplitView(context)) {
return AppLocalizations.of(context).delete;
}
return null;
}
@@ -162,8 +168,8 @@ class BottomBarThreadSelectionWidget {
return _responsiveUtils.isTabletLarge(context);
} else {
return _responsiveUtils.isLandscapeTablet(context) ||
_responsiveUtils.isTabletLarge(context) ||
_responsiveUtils.isDesktop(context);
_responsiveUtils.isTabletLarge(context) ||
_responsiveUtils.isDesktop(context);
}
}
}
@@ -1,7 +1,6 @@
import 'package:async/async.dart';
import 'package:collection/collection.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
@@ -9,6 +8,7 @@ import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
import 'package:model/email/attachment.dart';
@@ -128,13 +128,13 @@ class UploadController extends BaseController {
if (failure is ErrorAttachmentUploadState) {
uploadInlineViewState.value = Left(failure);
_deleteInlineFileUploaded(failure.uploadId);
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).thisImageCannotBeAdded,
textColor: AppColor.toastErrorBackgroundColor,
iconColor: AppColor.toastErrorBackgroundColor,
icon: _imagePaths.icInsertImage
);
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).thisImageCannotBeAdded,
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icInsertImage);
}
}
},
@@ -241,21 +241,22 @@ class UploadController extends BaseController {
void _handleUploadAttachmentsFailure(ErrorAttachmentUploadState failure) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments,
textColor: AppColor.toastErrorBackgroundColor,
iconColor: AppColor.toastErrorBackgroundColor,
icon: _imagePaths.icAttachment);
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments,
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icAttachment);
}
}
void _handleUploadAttachmentsSuccess(SuccessAttachmentUploadState success) {
log('UploadController::_handleUploadAttachmentsSuccess(): $success');
if (currentContext != null && currentOverlayContext != null && _uploadingStateFiles.allSuccess) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).attachments_uploaded_successfully,
iconColor: AppColor.primaryColor,
icon: _imagePaths.icAttachment);
_appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).attachments_uploaded_successfully,
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icAttachment);
}
}
@@ -348,21 +349,19 @@ class UploadController extends BaseController {
if (failure is UploadAttachmentFailure) {
if (failure.isInline) {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).thisImageCannotBeAdded,
textColor: AppColor.toastErrorBackgroundColor,
iconColor: AppColor.toastErrorBackgroundColor,
icon: _imagePaths.icInsertImage
);
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).thisImageCannotBeAdded,
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icInsertImage);
}
} else {
if (currentContext != null && currentOverlayContext != null) {
_appToast.showToastWithIcon(currentOverlayContext!,
message: AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments,
textColor: AppColor.toastErrorBackgroundColor,
iconColor: AppColor.toastErrorBackgroundColor,
icon: _imagePaths.icAttachment
);
_appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).can_not_upload_this_file_as_attachments,
leadingSVGIconColor: Colors.white,
leadingSVGIcon: _imagePaths.icAttachment);
}
}
}