TF-1865: Update UI and replace task in workmanager when update sending email
(cherry picked from commit 15168421c994c5f928873e0794bcbf0c36b015c9)
This commit is contained in:
@@ -14,4 +14,6 @@ extension ListSendingEmailExtension on List<SendingEmail> {
|
||||
bool isAllSelected() => every((sendingEmail) => sendingEmail.isSelected);
|
||||
|
||||
bool isAllUnSelected() => every((sendingEmail) => !sendingEmail.isSelected);
|
||||
|
||||
List<SendingEmail> listSelected() => where((sendingEmail) => sendingEmail.isSelected).toList();
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:model/extensions/list_email_content_extension.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/mixin/message_dialog_action_mixin.dart';
|
||||
@@ -35,6 +36,7 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
final _appToast = getBinding<AppToast>();
|
||||
|
||||
final listSendingEmailController = ScrollController();
|
||||
final listSendingEmailSelected = <SendingEmail>[].obs;
|
||||
|
||||
final selectionState = Rx<SelectMode>(SelectMode.INACTIVE);
|
||||
|
||||
@@ -69,6 +71,8 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||
? SelectMode.INACTIVE
|
||||
: SelectMode.ACTIVE;
|
||||
|
||||
listSendingEmailSelected.value = newListSendingEmail.listSelected();
|
||||
}
|
||||
|
||||
void toggleSelectionSendingEmail(SendingEmail sendingEmail) {
|
||||
@@ -78,6 +82,8 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
selectionState.value = newListSendingEmail.isAllUnSelected()
|
||||
? SelectMode.INACTIVE
|
||||
: SelectMode.ACTIVE;
|
||||
|
||||
listSendingEmailSelected.value = newListSendingEmail.listSelected();
|
||||
}
|
||||
|
||||
bool get isAllUnSelected => dashboardController!.listSendingEmails.isAllUnSelected();
|
||||
@@ -178,7 +184,8 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
emailActionType: EmailActionType.edit,
|
||||
presentationEmail: sendingEmail.presentationEmail,
|
||||
mailboxRole: dashboardController?.selectedMailbox.value?.role,
|
||||
emailContents: sendingEmail.email.subject,
|
||||
emailContents: sendingEmail.presentationEmail.emailContentList.asHtmlString,
|
||||
sendingEmail: sendingEmail
|
||||
);
|
||||
|
||||
dashboardController?.goToComposer(arguments);
|
||||
@@ -212,55 +219,4 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
_sendingQueueIsolateManager?.release();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
//
|
||||
// void pressEmailAction(
|
||||
// BuildContext context,
|
||||
// EmailActionType actionType,
|
||||
// PresentationEmail selectedEmail,
|
||||
// {PresentationMailbox? mailboxContain}
|
||||
// ) {
|
||||
// switch(actionType) {
|
||||
// case EmailActionType.edit:
|
||||
// editEmail(selectedEmail);
|
||||
// break;
|
||||
// case EmailActionType.selection:
|
||||
// selectEmail(context, selectedEmail);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void pressEmailSelectionAction(
|
||||
// BuildContext context,
|
||||
// EmailActionType actionType,
|
||||
// List<PresentationEmail> selectionEmail
|
||||
// ) {
|
||||
// switch(actionType) {
|
||||
// case EmailActionType.edit:
|
||||
// editEmail(selectionEmail.first);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// bool isSelectionEnabled() => currentSelectMode.value == SelectMode.ACTIVE;
|
||||
//
|
||||
// bool? _isUnSelectedAll() {
|
||||
// return dashboardController?.sendingEmailsInCurrentMailbox.every((email) => email.selectMode == SelectMode.INACTIVE);
|
||||
// }
|
||||
//
|
||||
// void cancelSelectEmail() {
|
||||
// final newEmailList = dashboardController?.sendingEmailsInCurrentMailbox
|
||||
// .map((email) => email.toSelectedEmail(selectMode: SelectMode.INACTIVE))
|
||||
// .toList();
|
||||
// updateEmailList(newEmailList);
|
||||
// currentSelectMode.value = SelectMode.INACTIVE;
|
||||
// listEmailSelected.clear();
|
||||
// }
|
||||
|
||||
// List<PresentationEmail> get listEmailSelected => dashboardController?.sendingEmailsInCurrentMailbox.listEmailSelected ?? [];
|
||||
|
||||
}
|
||||
@@ -22,12 +22,14 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Obx(() => AppBarSendingQueueWidget(
|
||||
listSendingEmails: controller.dashboardController!.listSendingEmails,
|
||||
onOpenMailboxMenu: controller.openMailboxMenu,
|
||||
onBackAction: controller.disableSelectionMode,
|
||||
selectMode: controller.selectionState.value,
|
||||
)),
|
||||
Obx(() {
|
||||
return AppBarSendingQueueWidget(
|
||||
listSendingEmails: controller.listSendingEmailSelected,
|
||||
onOpenMailboxMenu: controller.openMailboxMenu,
|
||||
onBackAction: controller.disableSelectionMode,
|
||||
selectMode: controller.selectionState.value,
|
||||
);
|
||||
}),
|
||||
const Divider(color: AppColor.colorDividerComposer, height: 1),
|
||||
const BannerMessageSendingQueueWidget(),
|
||||
Expanded(child: _buildListSendingEmails(context)),
|
||||
@@ -36,7 +38,7 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return BottomBarSendingQueueWidget(
|
||||
listSendingEmails: controller.dashboardController!.listSendingEmails,
|
||||
listSendingEmails: controller.listSendingEmailSelected,
|
||||
onHandleSendingEmailActionType: (actionType, listSendingEmails) => controller.handleSendingEmailActionType(context, actionType, listSendingEmails),
|
||||
);
|
||||
}
|
||||
@@ -60,8 +62,9 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
||||
sendingEmail: controller.dashboardController!.listSendingEmails[index],
|
||||
selectMode: controller.selectionState.value,
|
||||
onLongPressAction: controller.handleOnLongPressAction,
|
||||
onSelectAction: controller.toggleSelectionSendingEmail,
|
||||
));
|
||||
onSelectLeadingAction: controller.toggleSelectionSendingEmail,
|
||||
onTapAction: (actionType, listSendingEmails) =>
|
||||
controller.handleSendingEmailActionType(context, actionType, [listSendingEmails])));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
|
||||
+11
-9
@@ -5,6 +5,7 @@ import 'package:core/presentation/views/button/button_builder.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/sending_email.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';
|
||||
|
||||
typedef OnHandleSendingEmailActionType = void Function(SendingEmailActionType, List<SendingEmail>);
|
||||
@@ -35,15 +36,16 @@ class BottomBarSendingQueueWidget extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(child: (ButtonBuilder(imagePaths.icEdit)
|
||||
..key(Key(SendingEmailActionType.edit.getButtonKey()))
|
||||
..iconColor(SendingEmailActionType.edit.getButtonIconColor())
|
||||
..padding(const EdgeInsets.all(8))
|
||||
..radiusSplash(8)
|
||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.edit.getButtonTitleColor()))
|
||||
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.edit, listSendingEmails))
|
||||
..text(SendingEmailActionType.edit.getButtonTitle(context), isVertical: true)
|
||||
).build()),
|
||||
if (!listSendingEmails.isAllSelected() || listSendingEmails.length < 2)
|
||||
Expanded(child: (ButtonBuilder(imagePaths.icEdit)
|
||||
..key(Key(SendingEmailActionType.edit.getButtonKey()))
|
||||
..iconColor(SendingEmailActionType.edit.getButtonIconColor())
|
||||
..padding(const EdgeInsets.all(8))
|
||||
..radiusSplash(8)
|
||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.edit.getButtonTitleColor()))
|
||||
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.edit, listSendingEmails))
|
||||
..text(SendingEmailActionType.edit.getButtonTitle(context), isVertical: true)
|
||||
).build()),
|
||||
Expanded(child: (ButtonBuilder(imagePaths.icDeleteComposer)
|
||||
..key(Key(SendingEmailActionType.delete.getButtonKey()))
|
||||
..iconColor(SendingEmailActionType.delete.getButtonIconColor())
|
||||
|
||||
@@ -8,24 +8,27 @@ import 'package:get/get.dart';
|
||||
import 'package:model/extensions/presentation_email_extension.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/sending_queue/presentation/model/sending_email_action_type.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
typedef OnLongPressSendingEmailItemAction = void Function(SendingEmail);
|
||||
typedef OnSelectSendingEmailItemAction = void Function(SendingEmail);
|
||||
typedef OnSelectSendingEmailItemAction = void Function(SendingEmailActionType, SendingEmail);
|
||||
typedef OnSelectLeadingSendingEmailItemAction = void Function(SendingEmail);
|
||||
|
||||
class SendingEmailTileWidget extends StatelessWidget {
|
||||
|
||||
final SendingEmail sendingEmail;
|
||||
final SelectMode selectMode;
|
||||
final OnLongPressSendingEmailItemAction? onLongPressAction;
|
||||
final OnSelectSendingEmailItemAction? onSelectAction;
|
||||
|
||||
final OnSelectSendingEmailItemAction? onTapAction;
|
||||
final OnSelectLeadingSendingEmailItemAction? onSelectLeadingAction;
|
||||
const SendingEmailTileWidget({
|
||||
super.key,
|
||||
required this.sendingEmail,
|
||||
required this.selectMode,
|
||||
this.onLongPressAction,
|
||||
this.onSelectAction
|
||||
this.onTapAction,
|
||||
this.onSelectLeadingAction,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -35,7 +38,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => {},
|
||||
onTap: () => onTapAction?.call(SendingEmailActionType.edit ,sendingEmail),
|
||||
onLongPress: () => onLongPressAction?.call(sendingEmail),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -63,7 +66,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
height: 24
|
||||
),
|
||||
),
|
||||
onTap: () => onSelectAction?.call(sendingEmail),
|
||||
onTap: () => onSelectLeadingAction?.call(sendingEmail),
|
||||
)
|
||||
else
|
||||
SvgPicture.asset(
|
||||
|
||||
Reference in New Issue
Block a user