TF-1866 Implement delete sending email in Sending Queue
(cherry picked from commit 0b45b10231fd4ec4fd7936c71de6cdcda0e92d02)
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:model/extensions/email_extension.dart';
|
|||||||
import 'package:model/extensions/email_id_extensions.dart';
|
import 'package:model/extensions/email_id_extensions.dart';
|
||||||
import 'package:model/extensions/identity_id_extension.dart';
|
import 'package:model/extensions/identity_id_extension.dart';
|
||||||
import 'package:model/extensions/mailbox_id_extension.dart';
|
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||||
|
import 'package:model/mailbox/select_mode.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/model/email_request.dart';
|
import 'package:tmail_ui_user/features/composer/domain/model/email_request.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
import 'package:tmail_ui_user/features/offline_mode/model/sending_email_hive_cache.dart';
|
import 'package:tmail_ui_user/features/offline_mode/model/sending_email_hive_cache.dart';
|
||||||
@@ -33,4 +34,36 @@ extension SendingEmailExtension on SendingEmail {
|
|||||||
identityId: identityId
|
identityId: identityId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendingEmail toggleSelection() {
|
||||||
|
return SendingEmail(
|
||||||
|
sendingId: sendingId,
|
||||||
|
email: email,
|
||||||
|
emailActionType: emailActionType,
|
||||||
|
createTime: createTime,
|
||||||
|
sentMailboxId: sentMailboxId,
|
||||||
|
emailIdDestroyed: emailIdDestroyed,
|
||||||
|
emailIdAnsweredOrForwarded: emailIdAnsweredOrForwarded,
|
||||||
|
identityId: identityId,
|
||||||
|
mailboxNameRequest: mailboxNameRequest,
|
||||||
|
creationIdRequest: creationIdRequest,
|
||||||
|
selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
SendingEmail unSelected() {
|
||||||
|
return SendingEmail(
|
||||||
|
sendingId: sendingId,
|
||||||
|
email: email,
|
||||||
|
emailActionType: emailActionType,
|
||||||
|
createTime: createTime,
|
||||||
|
sentMailboxId: sentMailboxId,
|
||||||
|
emailIdDestroyed: emailIdDestroyed,
|
||||||
|
emailIdAnsweredOrForwarded: emailIdAnsweredOrForwarded,
|
||||||
|
identityId: identityId,
|
||||||
|
mailboxNameRequest: mailboxNameRequest,
|
||||||
|
creationIdRequest: creationIdRequest,
|
||||||
|
selectMode: SelectMode.INACTIVE
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,14 @@ class WorkSchedulerController {
|
|||||||
|
|
||||||
Future<void> cancelByWorkType(WorkerType type) => Workmanager().cancelByTag(type.name);
|
Future<void> cancelByWorkType(WorkerType type) => Workmanager().cancelByTag(type.name);
|
||||||
|
|
||||||
Future<void> cancelByUniqueId(String uniqueId) => Workmanager().cancelByUniqueName(uniqueId);
|
Future<void> cancelByUniqueId(String uniqueId) {
|
||||||
|
try {
|
||||||
|
return Workmanager().cancelByUniqueName(uniqueId);
|
||||||
|
} catch (e) {
|
||||||
|
logError('WorkSchedulerController::cancelByUniqueId():EXCEPTION: $e');
|
||||||
|
return Future.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> cancelAll() => Workmanager().cancelAll();
|
Future<void> cancelAll() => Workmanager().cancelAll();
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/delete_multiple_sending_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/sending_queue_controller.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/sending_queue_controller.dart';
|
||||||
|
|
||||||
class SendingQueueBindings extends Bindings {
|
class SendingQueueBindings extends Bindings {
|
||||||
@@ -10,6 +11,6 @@ class SendingQueueBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _bindingsController() {
|
void _bindingsController() {
|
||||||
Get.put(SendingQueueController());
|
Get.put(SendingQueueController(Get.find<DeleteMultipleSendingEmailInteractor>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -5,6 +5,8 @@ import 'package:tmail_ui_user/features/base/interactors_bindings.dart';
|
|||||||
import 'package:tmail_ui_user/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart';
|
import 'package:tmail_ui_user/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/data/repository/sending_queue_repository_impl.dart';
|
import 'package:tmail_ui_user/features/sending_queue/data/repository/sending_queue_repository_impl.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/domain/repository/sending_queue_repository.dart';
|
import 'package:tmail_ui_user/features/sending_queue/domain/repository/sending_queue_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/delete_multiple_sending_email_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/delete_single_sending_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/get_all_sending_email_interactor.dart';
|
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/get_all_sending_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/offline_mode/manager/detailed_email_cache_manager.dart';
|
import 'package:tmail_ui_user/features/offline_mode/manager/detailed_email_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/offline_mode/manager/detailed_email_cache_worker_queue.dart';
|
import 'package:tmail_ui_user/features/offline_mode/manager/detailed_email_cache_worker_queue.dart';
|
||||||
@@ -35,6 +37,8 @@ class SendingQueueInteractorBindings extends InteractorsBindings {
|
|||||||
@override
|
@override
|
||||||
void bindingsInteractor() {
|
void bindingsInteractor() {
|
||||||
Get.lazyPut(() => GetAllSendingEmailInteractor(Get.find<SendingQueueRepository>()));
|
Get.lazyPut(() => GetAllSendingEmailInteractor(Get.find<SendingQueueRepository>()));
|
||||||
|
Get.lazyPut(() => DeleteSingleSendingEmailInteractor(Get.find<SendingQueueRepository>()));
|
||||||
|
Get.lazyPut(() => DeleteMultipleSendingEmailInteractor(Get.find<DeleteSingleSendingEmailInteractor>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -1,24 +1,47 @@
|
|||||||
|
|
||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:model/mailbox/select_mode.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/features/base/mixin/message_dialog_action_mixin.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/offline_mode/scheduler/worker_state.dart';
|
import 'package:tmail_ui_user/features/offline_mode/scheduler/worker_state.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/utils/sending_queue_isolate_manager.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/utils/sending_queue_isolate_manager.dart';
|
||||||
|
import 'package:tmail_ui_user/features/offline_mode/controller/work_scheduler_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/domain/state/delete_multiple_sending_email_state.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/delete_multiple_sending_email_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/presentation/extensions/list_sending_email_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
|
|
||||||
class SendingQueueController extends BaseController {
|
class SendingQueueController extends BaseController with MessageDialogActionMixin {
|
||||||
|
|
||||||
|
final DeleteMultipleSendingEmailInteractor _deleteMultipleSendingEmailInteractor;
|
||||||
|
|
||||||
final dashboardController = getBinding<MailboxDashBoardController>();
|
final dashboardController = getBinding<MailboxDashBoardController>();
|
||||||
final sendingQueueIsolateManager = getBinding<SendingQueueIsolateManager>();
|
final _sendingQueueIsolateManager = getBinding<SendingQueueIsolateManager>();
|
||||||
|
final _imagePaths = getBinding<ImagePaths>();
|
||||||
|
final _appToast = getBinding<AppToast>();
|
||||||
|
|
||||||
final listSendingEmailController = ScrollController();
|
final listSendingEmailController = ScrollController();
|
||||||
|
|
||||||
|
final selectionState = Rx<SelectMode>(SelectMode.INACTIVE);
|
||||||
|
|
||||||
|
SendingQueueController(this._deleteMultipleSendingEmailInteractor);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
sendingQueueIsolateManager?.initial(
|
_sendingQueueIsolateManager?.initial(
|
||||||
onData: _handleSendingQueueEvent,
|
onData: _handleSendingQueueEvent,
|
||||||
onError: (error, stackTrace) {
|
onError: (error, stackTrace) {
|
||||||
logError('SendingQueueController::onInit():onError:error: $error | stackTrace: $stackTrace');
|
logError('SendingQueueController::onInit():onError:error: $error | stackTrace: $stackTrace');
|
||||||
@@ -37,18 +60,140 @@ class SendingQueueController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleOnLongPressAction(SendingEmail sendingEmail) {
|
||||||
|
final newListSendingEmail = dashboardController!.listSendingEmails.toggleSelection(sendingEmailSelected: sendingEmail);
|
||||||
|
dashboardController!.listSendingEmails.value = newListSendingEmail;
|
||||||
|
|
||||||
|
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||||
|
? SelectMode.INACTIVE
|
||||||
|
: SelectMode.ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleSelectionSendingEmail(SendingEmail sendingEmail) {
|
||||||
|
final newListSendingEmail = dashboardController!.listSendingEmails.toggleSelection(sendingEmailSelected: sendingEmail);
|
||||||
|
dashboardController!.listSendingEmails.value = newListSendingEmail;
|
||||||
|
|
||||||
|
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||||
|
? SelectMode.INACTIVE
|
||||||
|
: SelectMode.ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get isAllUnSelected => dashboardController!.listSendingEmails.isAllUnSelected();
|
||||||
|
|
||||||
void _refreshSendingQueue({bool needToReopen = false}) {
|
void _refreshSendingQueue({bool needToReopen = false}) {
|
||||||
dashboardController?.getAllSendingEmails(needToReopen: needToReopen);
|
dashboardController!.getAllSendingEmails(needToReopen: needToReopen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openMailboxMenu() {
|
void openMailboxMenu() {
|
||||||
dashboardController?.openMailboxMenuDrawer();
|
dashboardController!.openMailboxMenuDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableSelectionMode() {
|
||||||
|
final newListSendingEmail = dashboardController!.listSendingEmails.unAllSelected();
|
||||||
|
dashboardController!.listSendingEmails.value = newListSendingEmail;
|
||||||
|
selectionState.value = SelectMode.INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleSendingEmailActionType(
|
||||||
|
BuildContext context,
|
||||||
|
SendingEmailActionType actionType,
|
||||||
|
List<SendingEmail> listSendingEmails
|
||||||
|
) {
|
||||||
|
switch(actionType) {
|
||||||
|
case SendingEmailActionType.delete:
|
||||||
|
_deleteSendingEmailAction(context, listSendingEmails);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _deleteSendingEmailAction(BuildContext context, List<SendingEmail> listSendingEmails) {
|
||||||
|
showConfirmDialogAction(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context).messageDialogDeleteSendingEmail,
|
||||||
|
AppLocalizations.of(currentContext!).delete,
|
||||||
|
title: AppLocalizations.of(currentContext!).deleteOfflineEmail,
|
||||||
|
icon: SvgPicture.asset(_imagePaths!.icDeleteDialogRecipients),
|
||||||
|
alignCenter: true,
|
||||||
|
messageStyle: const TextStyle(
|
||||||
|
color: AppColor.colorTitleSendingItem,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.normal
|
||||||
|
),
|
||||||
|
titleStyle: const TextStyle(
|
||||||
|
color: AppColor.colorDeletePermanentlyButton,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold
|
||||||
|
),
|
||||||
|
actionButtonColor: AppColor.colorDeletePermanentlyButton,
|
||||||
|
actionStyle: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
cancelStyle: const TextStyle(
|
||||||
|
color: AppColor.colorDeletePermanentlyButton,
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
onConfirmAction: () => _handleDeleteSendingEmail(listSendingEmails),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleDeleteSendingEmail(List<SendingEmail> listSendingEmails) async {
|
||||||
|
final accountId = dashboardController!.accountId.value;
|
||||||
|
final session = dashboardController!.sessionCurrent;
|
||||||
|
|
||||||
|
if (accountId != null && session != null) {
|
||||||
|
final sendingIds = listSendingEmails.map((sendingEmail) => sendingEmail.sendingId).toSet().toList();
|
||||||
|
|
||||||
|
await Future.wait(
|
||||||
|
sendingIds.map((sendingId) => WorkSchedulerController().cancelByUniqueId(sendingId)),
|
||||||
|
eagerError: true
|
||||||
|
);
|
||||||
|
|
||||||
|
consumeState(_deleteMultipleSendingEmailInteractor.execute(accountId, session.username, sendingIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleDeleteSendingEmailSuccess() {
|
||||||
|
if (currentContext != null && currentOverlayContext != null) {
|
||||||
|
selectionState.value = SelectMode.INACTIVE;
|
||||||
|
|
||||||
|
_appToast!.showToastSuccessMessage(
|
||||||
|
currentOverlayContext!,
|
||||||
|
AppLocalizations.of(currentContext!).deleteSomeOfflineEmailSuccessfully
|
||||||
|
);
|
||||||
|
|
||||||
|
_refreshSendingQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleDeleteSendingEmailFailure() {
|
||||||
|
selectionState.value = SelectMode.INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is DeleteMultipleSendingEmailAllSuccess ||
|
||||||
|
success is DeleteMultipleSendingEmailHasSomeSuccess) {
|
||||||
|
_handleDeleteSendingEmailSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is DeleteMultipleSendingEmailAllFailure ||
|
||||||
|
failure is DeleteMultipleSendingEmailFailure) {
|
||||||
|
_handleDeleteSendingEmailFailure();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
listSendingEmailController.dispose();
|
listSendingEmailController.dispose();
|
||||||
sendingQueueIsolateManager?.release();
|
_sendingQueueIsolateManager?.release();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import 'package:tmail_ui_user/features/sending_queue/presentation/sending_queue_
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/app_bar_sending_queue_widget.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/app_bar_sending_queue_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/banner_message_sending_queue_widget.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/banner_message_sending_queue_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/sending_email_tile_widget.dart';
|
import 'package:tmail_ui_user/features/sending_queue/presentation/widgets/sending_email_tile_widget.dart';
|
||||||
|
|
||||||
class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderMixin {
|
class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderMixin {
|
||||||
@@ -18,23 +19,32 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
body: GestureDetector(
|
body: SafeArea(
|
||||||
onTap: FocusScope.of(context).unfocus,
|
child: Column(
|
||||||
child: SafeArea(
|
children: [
|
||||||
child: Column(
|
Obx(() => AppBarSendingQueueWidget(
|
||||||
children: [
|
listSendingEmails: controller.dashboardController!.listSendingEmails,
|
||||||
AppBarSendingQueueWidget(onOpenMailboxMenu: controller.openMailboxMenu),
|
onOpenMailboxMenu: controller.openMailboxMenu,
|
||||||
const Divider(color: AppColor.colorDividerComposer, height: 1),
|
onBackAction: controller.disableSelectionMode,
|
||||||
const BannerMessageSendingQueueWidget(),
|
selectMode: controller.selectionState.value,
|
||||||
Expanded(child: _buildListSendingEmails(context))
|
)),
|
||||||
]
|
const Divider(color: AppColor.colorDividerComposer, height: 1),
|
||||||
),
|
const BannerMessageSendingQueueWidget(),
|
||||||
|
Expanded(child: _buildListSendingEmails(context)),
|
||||||
|
Obx(() {
|
||||||
|
if (controller.isAllUnSelected) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
} else {
|
||||||
|
return BottomBarSendingQueueWidget(
|
||||||
|
listSendingEmails: controller.dashboardController!.listSendingEmails,
|
||||||
|
onHandleSendingEmailActionType: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, listSendingEmails),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: ComposeFloatingButton(
|
floatingActionButton: _buildFloatingButtonCompose(),
|
||||||
scrollController: controller.listSendingEmailController,
|
|
||||||
onTap: () => controller.dashboardController!.goToComposer(ComposerArguments())
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +55,37 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
|||||||
controller: controller.listSendingEmailController,
|
controller: controller.listSendingEmailController,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: controller.dashboardController!.listSendingEmails.length,
|
itemCount: controller.dashboardController!.listSendingEmails.length,
|
||||||
itemBuilder: (context, index) => SendingEmailTileWidget(
|
itemBuilder: (context, index) {
|
||||||
sendingEmail: controller.dashboardController!.listSendingEmails[index]
|
return Obx(() => SendingEmailTileWidget(
|
||||||
)
|
sendingEmail: controller.dashboardController!.listSendingEmails[index],
|
||||||
|
selectMode: controller.selectionState.value,
|
||||||
|
onLongPressAction: controller.handleOnLongPressAction,
|
||||||
|
onSelectAction: controller.toggleSelectionSendingEmail,
|
||||||
|
));
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildFloatingButtonCompose() {
|
||||||
|
return Obx(() {
|
||||||
|
if (controller.isAllUnSelected) {
|
||||||
|
return ComposeFloatingButton(
|
||||||
|
scrollController: controller.listSendingEmailController,
|
||||||
|
onTap: () => controller.dashboardController!.goToComposer(ComposerArguments())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(bottom: 70),
|
||||||
|
child: ComposeFloatingButton(
|
||||||
|
scrollController: controller.listSendingEmailController,
|
||||||
|
onTap: () => controller.dashboardController!.goToComposer(ComposerArguments())
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:model/mailbox/select_mode.dart';
|
import 'package:model/mailbox/select_mode.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||||
|
|
||||||
@@ -15,12 +16,14 @@ class AppBarSendingQueueWidget extends StatelessWidget {
|
|||||||
final VoidCallback? onBackAction;
|
final VoidCallback? onBackAction;
|
||||||
final VoidCallback? onOpenMailboxMenu;
|
final VoidCallback? onOpenMailboxMenu;
|
||||||
final SelectMode selectMode;
|
final SelectMode selectMode;
|
||||||
|
final List<SendingEmail> listSendingEmails;
|
||||||
|
|
||||||
const AppBarSendingQueueWidget({
|
const AppBarSendingQueueWidget({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.listSendingEmails,
|
||||||
this.onBackAction,
|
this.onBackAction,
|
||||||
this.onOpenMailboxMenu,
|
this.onOpenMailboxMenu,
|
||||||
this.selectMode = SelectMode.INACTIVE,
|
this.selectMode = SelectMode.INACTIVE
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -44,14 +47,40 @@ class AppBarSendingQueueWidget extends StatelessWidget {
|
|||||||
onTap: onOpenMailboxMenu
|
onTap: onOpenMailboxMenu
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
buildIconWeb(
|
Padding(
|
||||||
icon: SvgPicture.asset(
|
padding: const EdgeInsets.only(left: 8),
|
||||||
AppUtils.isDirectionRTL(context) ? imagePaths.icCollapseFolder : imagePaths.icBack,
|
child: Material(
|
||||||
colorFilter: AppColor.colorTextButton.asFilter(),
|
color: Colors.transparent,
|
||||||
fit: BoxFit.fill
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onBackAction,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
AppUtils.isDirectionRTL(context) ? imagePaths.icCollapseFolder : imagePaths.icBack,
|
||||||
|
colorFilter: AppColor.colorTextButton.asFilter(),
|
||||||
|
fit: BoxFit.fill
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
listSendingEmails.length.toString(),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
color: AppColor.colorTextButton
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
tooltip: AppLocalizations.of(context).back,
|
|
||||||
onTap: onBackAction
|
|
||||||
),
|
),
|
||||||
Expanded(child: Text(
|
Expanded(child: Text(
|
||||||
AppLocalizations.of(context).sendingQueue,
|
AppLocalizations.of(context).sendingQueue,
|
||||||
|
|||||||
@@ -6,17 +6,26 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:model/extensions/presentation_email_extension.dart';
|
import 'package:model/extensions/presentation_email_extension.dart';
|
||||||
import 'package:model/model.dart';
|
import 'package:model/mailbox/select_mode.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
typedef OnLongPressSendingEmailItemAction = void Function(SendingEmail);
|
||||||
|
typedef OnSelectSendingEmailItemAction = void Function(SendingEmail);
|
||||||
|
|
||||||
class SendingEmailTileWidget extends StatelessWidget {
|
class SendingEmailTileWidget extends StatelessWidget {
|
||||||
|
|
||||||
final SendingEmail sendingEmail;
|
final SendingEmail sendingEmail;
|
||||||
|
final SelectMode selectMode;
|
||||||
|
final OnLongPressSendingEmailItemAction? onLongPressAction;
|
||||||
|
final OnSelectSendingEmailItemAction? onSelectAction;
|
||||||
|
|
||||||
const SendingEmailTileWidget({
|
const SendingEmailTileWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.sendingEmail
|
required this.sendingEmail,
|
||||||
|
required this.selectMode,
|
||||||
|
this.onLongPressAction,
|
||||||
|
this.onSelectAction
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -27,6 +36,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => {},
|
onTap: () => {},
|
||||||
|
onLongPress: () => onLongPressAction?.call(sendingEmail),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -34,14 +44,36 @@ class SendingEmailTileWidget extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
if (selectMode == SelectMode.ACTIVE)
|
||||||
sendingEmail.presentationEmail.numberOfAllEmailAddress() == 1
|
GestureDetector(
|
||||||
? imagePath.icAvatarPersonal
|
child: Container(
|
||||||
: imagePath.icAvatarGroup,
|
width: 60,
|
||||||
fit: BoxFit.fill,
|
height: 60,
|
||||||
width: 60,
|
decoration: const BoxDecoration(
|
||||||
height: 60,
|
color: Colors.white,
|
||||||
),
|
borderRadius: BorderRadius.all(Radius.circular(30))
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
sendingEmail.isSelected
|
||||||
|
? imagePath.icSelected
|
||||||
|
: imagePath.icUnSelected,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
width: 24,
|
||||||
|
height: 24
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => onSelectAction?.call(sendingEmail),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
SvgPicture.asset(
|
||||||
|
sendingEmail.presentationEmail.numberOfAllEmailAddress() == 1
|
||||||
|
? imagePath.icAvatarPersonal
|
||||||
|
: imagePath.icAvatarGroup,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
width: 60,
|
||||||
|
height: 60,
|
||||||
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(child: Column(
|
Expanded(child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2023-06-01T13:42:51.121212",
|
"@@last_modified": "2023-06-05T09:10:02.535366",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2863,5 +2863,29 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"messageHasBeenSentSuccessfully": "Message has been sent successfully.",
|
||||||
|
"@messageHasBeenSentSuccessfully": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"deleteOfflineEmail": "Delete offline email",
|
||||||
|
"@deleteOfflineEmail": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"messageDialogDeleteSendingEmail": "Deleting an offline email will erase its content permanently. You won't be able to undo this action or recover the email from the Trash mailbox.",
|
||||||
|
"@messageDialogDeleteSendingEmail": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"deleteSomeOfflineEmailSuccessfully": "Delete some offline email successfully.",
|
||||||
|
"@deleteSomeOfflineEmailSuccessfully": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2953,4 +2953,25 @@ class AppLocalizations {
|
|||||||
name: 'messageHasBeenSentSuccessfully',
|
name: 'messageHasBeenSentSuccessfully',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get deleteOfflineEmail {
|
||||||
|
return Intl.message(
|
||||||
|
'Delete offline email',
|
||||||
|
name: 'deleteOfflineEmail'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get messageDialogDeleteSendingEmail {
|
||||||
|
return Intl.message(
|
||||||
|
'Deleting an offline email will erase its content permanently. You won\'t be able to undo this action or recover the email from the Trash mailbox.',
|
||||||
|
name: 'messageDialogDeleteSendingEmail'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get deleteSomeOfflineEmailSuccessfully {
|
||||||
|
return Intl.message(
|
||||||
|
'Delete some offline email successfully.',
|
||||||
|
name: 'deleteSomeOfflineEmailSuccessfully',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user