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