TW-4308 Add labels for several messages part 2 (#4431)
Add ChooseLabelModal, delegate, and update label UI components Wire add-labels action across Thread, Search, and Dashboard
This commit is contained in:
+3
-1
@@ -2,6 +2,7 @@ import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/add_a_label_to_an_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/remove_a_label_from_an_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dart';
|
||||
|
||||
class EmailActionInteractorBindings extends Bindings {
|
||||
|
||||
@@ -13,5 +14,6 @@ class EmailActionInteractorBindings extends Bindings {
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => AddALabelToAnEmailInteractor(_emailRepository));
|
||||
Get.lazyPut(() => RemoveALabelFromAnEmailInteractor(_emailRepository));
|
||||
Get.lazyPut(() => AddListLabelToListEmailsInteractor(_emailRepository));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ import 'package:tmail_ui_user/features/identity_creator/data/datasource_impl/loc
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/repository/identity_creator_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/repository/identity_creator_repository.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/usecase/get_identity_cache_on_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/labels/add_list_label_to_list_emails_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/delegates/add_list_label_to_list_emails_delegate.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/label_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart';
|
||||
@@ -212,6 +214,10 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.find<GetSpamMailboxCachedInteractor>()));
|
||||
|
||||
Get.put(LabelController());
|
||||
Get.put(AddListLabelToListEmailsDelegate(
|
||||
Get.find<LabelController>(),
|
||||
Get.find<AddListLabelToListEmailsInteractor>(),
|
||||
));
|
||||
|
||||
Get.lazyPut(() => ComposerManager());
|
||||
|
||||
|
||||
+22
-1
@@ -75,11 +75,32 @@ extension HandleLogicLabelExtension on MailboxDashBoardController {
|
||||
updateEmailFlagByEmailIds(
|
||||
[emailId],
|
||||
isLabelAdded: !shouldRemove,
|
||||
labelKeyword: labelKeyword,
|
||||
labelKeywords: [labelKeyword],
|
||||
);
|
||||
}
|
||||
|
||||
void _refreshLabelSettingEnabled() {
|
||||
labelController.isLabelSettingEnabled.refresh();
|
||||
}
|
||||
|
||||
void syncListLabelForListEmail(
|
||||
List<EmailId> emailIds,
|
||||
List<KeyWordIdentifier> labelKeywords,
|
||||
{bool shouldRemove = false}
|
||||
) {
|
||||
_syncLabelsForEmailList(emailIds, labelKeywords, shouldRemove);
|
||||
_refreshLabelSettingEnabled();
|
||||
}
|
||||
|
||||
void _syncLabelsForEmailList(
|
||||
List<EmailId> emailIds,
|
||||
List<KeyWordIdentifier> labelKeywords,
|
||||
bool shouldRemove,
|
||||
) {
|
||||
updateEmailFlagByEmailIds(
|
||||
emailIds,
|
||||
labelKeywords: labelKeywords,
|
||||
isLabelAdded: !shouldRemove,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-4
@@ -15,13 +15,13 @@ extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController {
|
||||
bool markAsAnswered = false,
|
||||
bool markAsForwarded = false,
|
||||
bool isLabelAdded = false,
|
||||
KeyWordIdentifier? labelKeyword,
|
||||
List<KeyWordIdentifier>? labelKeywords,
|
||||
}) {
|
||||
if (readAction == null &&
|
||||
markStarAction == null &&
|
||||
!markAsAnswered &&
|
||||
!markAsForwarded &&
|
||||
labelKeyword == null) {
|
||||
labelKeywords?.isNotEmpty != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController {
|
||||
_updateKeyword(email, KeyWordIdentifier.emailForwarded, true);
|
||||
}
|
||||
|
||||
if (labelKeyword != null) {
|
||||
_updateKeyword(email, labelKeyword, isLabelAdded);
|
||||
if (labelKeywords?.isNotEmpty == true) {
|
||||
_updateListKeywords(email, labelKeywords!, isLabelAdded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,16 @@ extension UpdateCurrentEmailsFlagsExtension on MailboxDashBoardController {
|
||||
}
|
||||
}
|
||||
|
||||
void _updateListKeywords(
|
||||
PresentationEmail presentationEmail,
|
||||
List<KeyWordIdentifier> keywords,
|
||||
bool value,
|
||||
) {
|
||||
for (var keyword in keywords) {
|
||||
_updateKeyword(presentationEmail, keyword, value);
|
||||
}
|
||||
}
|
||||
|
||||
void updateEmailAnswered(EmailId emailId) {
|
||||
dispatchThreadDetailUIAction(UpdatedEmailKeywordsAction(
|
||||
emailId,
|
||||
|
||||
@@ -395,6 +395,8 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
||||
listEmailSelected,
|
||||
controller.mapMailboxById,
|
||||
controller.imagePaths,
|
||||
isLabelAvailable: controller.isLabelAvailable,
|
||||
labels: controller.labelController.labels,
|
||||
onCancelSelection: () =>
|
||||
controller.dispatchAction(CancelSelectionAllEmailAction()),
|
||||
onEmailActionTypeAction: (listEmails, actionType) =>
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:labels/model/label.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';
|
||||
@@ -20,6 +21,8 @@ class TopBarThreadSelection extends StatelessWidget{
|
||||
final OnEmailActionTypeAction? onEmailActionTypeAction;
|
||||
final VoidCallback? onCancelSelection;
|
||||
final ImagePaths imagePaths;
|
||||
final bool isLabelAvailable;
|
||||
final List<Label> labels;
|
||||
|
||||
const TopBarThreadSelection (
|
||||
this.listEmail,
|
||||
@@ -27,6 +30,8 @@ class TopBarThreadSelection extends StatelessWidget{
|
||||
this.imagePaths,
|
||||
{
|
||||
super.key,
|
||||
required this.isLabelAvailable,
|
||||
required this.labels,
|
||||
this.onEmailActionTypeAction,
|
||||
this.onCancelSelection,
|
||||
}
|
||||
@@ -104,6 +109,18 @@ class TopBarThreadSelection extends StatelessWidget{
|
||||
EmailActionType.moveToMailbox,
|
||||
),
|
||||
),
|
||||
if (isLabelAvailable && labels.isNotEmpty)
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: imagePaths.icTag,
|
||||
iconSize: TopBarThreadSelectionStyle.iconSize,
|
||||
iconColor: TopBarThreadSelectionStyle.iconColor,
|
||||
tooltipMessage: AppLocalizations.of(context).labelAs,
|
||||
backgroundColor: Colors.transparent,
|
||||
onTapActionCallback: () => onEmailActionTypeAction?.call(
|
||||
List.from(listEmail),
|
||||
EmailActionType.labelAs,
|
||||
),
|
||||
),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: !isMarkAsSpamEnabled ? imagePaths.icNotSpam : imagePaths.icSpam,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
||||
Reference in New Issue
Block a user