diff --git a/assets/images/ic_read_toast.svg b/assets/images/ic_read_toast.svg new file mode 100644 index 000000000..ddd8057d6 --- /dev/null +++ b/assets/images/ic_read_toast.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/images/ic_unread_toast.svg b/assets/images/ic_unread_toast.svg new file mode 100644 index 000000000..d2d9a05ad --- /dev/null +++ b/assets/images/ic_unread_toast.svg @@ -0,0 +1,4 @@ + + + + diff --git a/core/lib/presentation/resources/image_paths.dart b/core/lib/presentation/resources/image_paths.dart index e5b4fa53c..fd3e05d83 100644 --- a/core/lib/presentation/resources/image_paths.dart +++ b/core/lib/presentation/resources/image_paths.dart @@ -59,6 +59,8 @@ class ImagePaths { String get icSpamV2 => _getImagePath('ic_spam_v2.svg'); String get icMoveV2 => _getImagePath('ic_move_v2.svg'); String get icFlagV2 => _getImagePath('ic_flag_v2.svg'); + String get icReadToast => _getImagePath('ic_read_toast.svg'); + String get icUnreadToast => _getImagePath('ic_unread_toast.svg'); String _getImagePath(String imageName) { return AssetsPaths.images + imageName; diff --git a/core/lib/presentation/utils/app_toast.dart b/core/lib/presentation/utils/app_toast.dart index 6bd384d3d..5a2c2e8df 100644 --- a/core/lib/presentation/utils/app_toast.dart +++ b/core/lib/presentation/utils/app_toast.dart @@ -1,10 +1,14 @@ +import 'package:core/core.dart'; import 'package:core/presentation/extensions/color_extension.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:getwidget/components/toast/gf_toast.dart'; import 'package:getwidget/getwidget.dart'; +import 'package:get/get.dart'; class AppToast { + final fToast = Get.find(); + void showToast(String message) { Fluttertoast.showToast( msg: message, @@ -55,4 +59,38 @@ class AppToast { toastDuration: 3 ); } + + void showToastWithIcon(BuildContext context, + {String? message, String? icon, Color? bgColor, double? radius, EdgeInsets? padding, TextStyle? textStyle}) { + final toast = Material( + color: bgColor ?? Colors.white, + elevation: 10, + shadowColor: Colors.black54, + borderRadius: BorderRadius.all(Radius.circular(radius ?? 10)), + child: Container( + padding: padding ?? EdgeInsets.symmetric(horizontal: 12.0, vertical: 14), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(radius ?? 10.0), + color: Colors.white, + ), + width: 320, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (icon != null) SvgPicture.asset(icon, width: 24, height: 24, fit: BoxFit.fill), + SizedBox(width: 10.0), + Expanded(child: Text( + message ?? '', + style: textStyle ?? TextStyle(fontSize: 15, color: Colors.black))), + ], + ), + ), + ); + fToast.init(context); + fToast.showToast( + child: toast, + gravity: ToastGravity.BOTTOM, + toastDuration: Duration(seconds: 2), + ); + } } diff --git a/lib/features/thread/presentation/thread_bindings.dart b/lib/features/thread/presentation/thread_bindings.dart index 73cd9d3a8..b4e295ade 100644 --- a/lib/features/thread/presentation/thread_bindings.dart +++ b/lib/features/thread/presentation/thread_bindings.dart @@ -77,6 +77,7 @@ class ThreadBindings extends Bindings { Get.find(), Get.find(), Get.find(), + Get.find(), Get.find(), Get.find(), Get.find(), diff --git a/lib/features/thread/presentation/thread_controller.dart b/lib/features/thread/presentation/thread_controller.dart index b98cdd8a8..1e477d943 100644 --- a/lib/features/thread/presentation/thread_controller.dart +++ b/lib/features/thread/presentation/thread_controller.dart @@ -52,6 +52,7 @@ class ThreadController extends BaseController { final MarkAsMultipleEmailReadInteractor _markAsMultipleEmailReadInteractor; final AppToast _appToast; final ResponsiveUtils responsiveUtils; + final ImagePaths _imagePaths; final ScrollController listEmailController; final MoveMultipleEmailToMailboxInteractor _moveMultipleEmailToMailboxInteractor; final MarkAsStarEmailInteractor _markAsStarEmailInteractor; @@ -89,6 +90,7 @@ class ThreadController extends BaseController { this.listEmailController, this._markAsMultipleEmailReadInteractor, this._appToast, + this._imagePaths, this._moveMultipleEmailToMailboxInteractor, this._markAsStarEmailInteractor, this._markAsStarMultipleEmailInteractor, @@ -373,20 +375,21 @@ class ThreadController extends BaseController { mailboxDashBoardController.dispatchState(Right(success)); ReadActions? readActions; - int countMarkAsReadSuccess = 0; if (success is MarkAsMultipleEmailReadAllSuccess) { readActions = success.readActions; - countMarkAsReadSuccess = success.countMarkAsReadSuccess; } else if (success is MarkAsMultipleEmailReadHasSomeEmailFailure) { readActions = success.readActions; - countMarkAsReadSuccess = success.countMarkAsReadSuccess; } - if (Get.context != null && readActions != null) { - _appToast.showSuccessToast(readActions == ReadActions.markAsUnread - ? AppLocalizations.of(Get.context!).marked_multiple_item_as_unread(countMarkAsReadSuccess) - : AppLocalizations.of(Get.context!).marked_multiple_item_as_read(countMarkAsReadSuccess)); + if (Get.context != null && readActions != null && Get.overlayContext != null) { + final message = readActions == ReadActions.markAsUnread + ? AppLocalizations.of(Get.context!).marked_message_toast(AppLocalizations.of(Get.context!).unread) + : AppLocalizations.of(Get.context!).marked_message_toast(AppLocalizations.of(Get.context!).read); + _appToast.showToastWithIcon( + Get.overlayContext!, + message: message, + icon: readActions == ReadActions.markAsUnread ? _imagePaths.icUnreadToast : _imagePaths.icReadToast); } } diff --git a/lib/main/bindings/core/core_bindings.dart b/lib/main/bindings/core/core_bindings.dart index e297d8fad..f569cdd71 100644 --- a/lib/main/bindings/core/core_bindings.dart +++ b/lib/main/bindings/core/core_bindings.dart @@ -1,6 +1,6 @@ import 'package:core/core.dart'; -import 'package:core/presentation/utils/app_toast.dart'; import 'package:device_info/device_info.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tmail_ui_user/features/email/data/local/html_analyzer.dart'; @@ -39,6 +39,7 @@ class CoreBindings extends Bindings { } void _bindingToast() { + Get.put(FToast()); Get.put(AppToast()); } diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index 83ed644d9..f4f3e29ec 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -518,4 +518,12 @@ class AppLocalizations { 'This feature is under development.', name: 'the_feature_is_under_development'); } + + String marked_message_toast(String action) { + return Intl.message( + 'You’ve marked messages as "$action"', + name: 'marked_message_toast', + args: [action] + ); + } } \ No newline at end of file