TF-4195 Implement add a Label to an email on mobile
This commit is contained in:
@@ -391,7 +391,7 @@ abstract class BaseMailboxController extends BaseController
|
||||
);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox is PresentationMailbox) {
|
||||
@@ -660,7 +660,7 @@ abstract class BaseMailboxController extends BaseController
|
||||
);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.destinationPicker,
|
||||
arguments: arguments,
|
||||
)
|
||||
|
||||
@@ -59,8 +59,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
MessageDialogActionManager().isDialogOpened ||
|
||||
EmailActionReactor.isDialogOpened ||
|
||||
ColorDialogPicker().isOpened.isTrue ||
|
||||
DialogRouter.isRuleFilterDialogOpened.isTrue ||
|
||||
DialogRouter.isDialogOpened;
|
||||
DialogRouter().isRuleFilterDialogOpened.isTrue ||
|
||||
DialogRouter().isDialogOpened;
|
||||
|
||||
if (isOverlayEnabled) {
|
||||
return Positioned.fill(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.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/get_email_content_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_email_read_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_star_email_interactor.dart';
|
||||
@@ -23,6 +24,7 @@ class EmailBindings extends Bindings {
|
||||
Get.find<MarkAsStarEmailInteractor>(),
|
||||
Get.find<GetAllIdentitiesInteractor>(),
|
||||
Get.find<StoreOpenedEmailInteractor>(),
|
||||
Get.find<AddALabelToAnEmailInteractor>(),
|
||||
Get.find<PrintEmailInteractor>(),
|
||||
currentEmailId: currentEmailId,
|
||||
), tag: tag);
|
||||
|
||||
@@ -118,6 +118,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
final GetAllIdentitiesInteractor _getAllIdentitiesInteractor;
|
||||
final StoreOpenedEmailInteractor _storeOpenedEmailInteractor;
|
||||
final PrintEmailInteractor _printEmailInteractor;
|
||||
final AddALabelToAnEmailInteractor addALabelToAnEmailInteractor;
|
||||
final EmailId? _currentEmailId;
|
||||
|
||||
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
|
||||
@@ -128,7 +129,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
RejectCalendarEventInteractor? _rejectCalendarEventInteractor;
|
||||
AcceptCounterCalendarEventInteractor? _acceptCounterCalendarEventInteractor;
|
||||
ThreadDetailController? _threadDetailController;
|
||||
AddALabelToAnEmailInteractor? addALabelToAnEmailInteractor;
|
||||
|
||||
final emailContents = RxnString();
|
||||
final attachments = <Attachment>[].obs;
|
||||
@@ -188,6 +188,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
this._markAsStarEmailInteractor,
|
||||
this._getAllIdentitiesInteractor,
|
||||
this._storeOpenedEmailInteractor,
|
||||
this.addALabelToAnEmailInteractor,
|
||||
this._printEmailInteractor, {
|
||||
EmailId? currentEmailId,
|
||||
}) : _currentEmailId = currentEmailId;
|
||||
@@ -220,6 +221,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
@override
|
||||
void handleSuccessViewState(Success success) {
|
||||
log('SingleEmailController::handleSuccessViewState(): $success');
|
||||
if (success is GetEmailContentSuccess) {
|
||||
_getEmailContentSuccess(success);
|
||||
} else if (success is GetEmailContentFromCacheSuccess) {
|
||||
@@ -253,6 +255,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
@override
|
||||
void handleFailureViewState(Failure failure) {
|
||||
logError('SingleEmailController::handleFailureViewState(): $failure');
|
||||
if (failure is MarkAsEmailReadFailure) {
|
||||
_handleMarkAsEmailReadFailure(failure);
|
||||
} else if (failure is ParseCalendarEventFailure) {
|
||||
@@ -895,6 +898,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
case EmailActionType.compose:
|
||||
pressEmailAction(actionType, presentationEmail);
|
||||
break;
|
||||
case EmailActionType.labelAs:
|
||||
openAddLabelToEmailDialogModal(presentationEmail);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -600,8 +600,8 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
MessageDialogActionManager().isDialogOpened ||
|
||||
EmailActionReactor.isDialogOpened ||
|
||||
ColorDialogPicker().isOpened.isTrue ||
|
||||
DialogRouter.isRuleFilterDialogOpened.isTrue ||
|
||||
DialogRouter.isDialogOpened;
|
||||
DialogRouter().isRuleFilterDialogOpened.isTrue ||
|
||||
DialogRouter().isDialogOpened;
|
||||
|
||||
if (isOverlayEnabled) {
|
||||
return Positioned.fill(
|
||||
|
||||
@@ -6,17 +6,19 @@ import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:labels/extensions/label_extension.dart';
|
||||
import 'package:labels/model/label.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/add_a_label_to_an_email_state.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/presentation/controller/single_email_controller.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/email_loaded_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/presentation_email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/labels/domain/exceptions/label_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/widgets/add_label_to_email_modal.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/update_current_emails_flags_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/map_keywords_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/extensions/presentation_email_map_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread_detail/domain/extensions/list_email_in_thread_detail_info_extension.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/routes/dialog_router.dart';
|
||||
|
||||
extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
bool get isLabelFeatureEnabled {
|
||||
@@ -68,24 +70,12 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
return;
|
||||
}
|
||||
|
||||
addALabelToAnEmailInteractor = getBinding<AddALabelToAnEmailInteractor>();
|
||||
if (addALabelToAnEmailInteractor != null) {
|
||||
consumeState(addALabelToAnEmailInteractor!.execute(
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
label.safeDisplayName,
|
||||
));
|
||||
} else {
|
||||
consumeState(
|
||||
Stream.value(
|
||||
Left(AddALabelToAnEmailFailure(
|
||||
exception: LabelInteractorIsNull(),
|
||||
labelDisplay: labelDisplay,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
consumeState(addALabelToAnEmailInteractor.execute(
|
||||
accountId,
|
||||
emailId,
|
||||
labelKeyword,
|
||||
label.safeDisplayName,
|
||||
));
|
||||
}
|
||||
|
||||
void handleAddLabelToEmailSuccess(AddALabelToAnEmailSuccess success) {
|
||||
@@ -105,36 +95,43 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
required EmailId emailId,
|
||||
required KeyWordIdentifier labelKeyword,
|
||||
}) {
|
||||
if (PlatformInfo.isMobile && !isThreadDetailEnabled) {
|
||||
_updateLabelInEmailWithThreadDisabledOnMobile(
|
||||
emailId: emailId,
|
||||
labelKeyword: labelKeyword,
|
||||
);
|
||||
} else {
|
||||
_updateLabelInEmailWithThreadEnabled(
|
||||
emailId: emailId,
|
||||
labelKeyword: labelKeyword,
|
||||
);
|
||||
}
|
||||
_updateLabelInEmailOnMemory(
|
||||
emailId: emailId,
|
||||
labelKeyword: labelKeyword,
|
||||
isMobileThreadDisabled: PlatformInfo.isMobile && !isThreadDetailEnabled,
|
||||
);
|
||||
}
|
||||
|
||||
void _updateLabelInEmailWithThreadDisabledOnMobile({
|
||||
void _updateLabelInEmailOnMemory({
|
||||
required EmailId emailId,
|
||||
required KeyWordIdentifier labelKeyword,
|
||||
required bool isMobileThreadDisabled,
|
||||
}) {
|
||||
final selectedEmail = mailboxDashBoardController.selectedEmail.value;
|
||||
final selectedEmailId = selectedEmail?.id;
|
||||
if (selectedEmail == null ||
|
||||
selectedEmailId == null ||
|
||||
selectedEmailId != emailId) {
|
||||
return;
|
||||
if (isMobileThreadDisabled) {
|
||||
final selectedEmail = mailboxDashBoardController.selectedEmail.value;
|
||||
if (selectedEmail?.id == emailId) {
|
||||
mailboxDashBoardController.selectedEmail.value?.keywords
|
||||
?.addKeyword(labelKeyword);
|
||||
}
|
||||
} else {
|
||||
final controller = threadDetailController;
|
||||
if (controller != null) {
|
||||
controller.emailIdsPresentation.value =
|
||||
controller.emailIdsPresentation.addEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
);
|
||||
|
||||
controller.emailsInThreadDetailInfo.value =
|
||||
controller.emailsInThreadDetailInfo.addEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mailboxDashBoardController.selectedEmail.value =
|
||||
selectedEmail.addKeyword(labelKeyword);
|
||||
|
||||
final emailLoaded = currentEmailLoaded.value;
|
||||
if (emailLoaded != null) {
|
||||
if (emailLoaded != null && emailLoaded.emailCurrent?.id == emailId) {
|
||||
currentEmailLoaded.value = emailLoaded.addEmailKeyword(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
@@ -146,42 +143,26 @@ extension HandleLabelForEmailExtension on SingleEmailController {
|
||||
isLabelAdded: true,
|
||||
labelKeyword: labelKeyword,
|
||||
);
|
||||
|
||||
mailboxDashBoardController.labelController.isLabelSettingEnabled.refresh();
|
||||
}
|
||||
|
||||
void _updateLabelInEmailWithThreadEnabled({
|
||||
required EmailId emailId,
|
||||
required KeyWordIdentifier labelKeyword,
|
||||
}) {
|
||||
final controller = threadDetailController;
|
||||
if (controller == null) return;
|
||||
|
||||
final currentEmailId = currentEmail?.id;
|
||||
if (currentEmailId == null || currentEmailId != emailId) return;
|
||||
|
||||
controller.emailIdsPresentation.value =
|
||||
controller.emailIdsPresentation.addEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
);
|
||||
|
||||
controller.emailsInThreadDetailInfo.value =
|
||||
controller.emailsInThreadDetailInfo.addEmailKeywordById(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
);
|
||||
|
||||
final emailLoaded = controller.currentEmailLoaded.value;
|
||||
if (emailLoaded != null) {
|
||||
controller.currentEmailLoaded.value = emailLoaded.addEmailKeyword(
|
||||
emailId: emailId,
|
||||
keyword: labelKeyword,
|
||||
);
|
||||
Future<void> openAddLabelToEmailDialogModal(PresentationEmail email) async {
|
||||
final labels = mailboxDashBoardController.labelController.labels;
|
||||
final emailLabels = email.getLabelList(labels);
|
||||
final emailId = email.id;
|
||||
if (emailId == null || labels.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
mailboxDashBoardController.updateEmailFlagByEmailIds(
|
||||
[emailId],
|
||||
isLabelAdded: true,
|
||||
labelKeyword: labelKeyword,
|
||||
await DialogRouter().openDialogModal(
|
||||
child: AddLabelToEmailModal(
|
||||
labels: labels,
|
||||
emailLabels: emailLabels,
|
||||
emailId: emailId,
|
||||
onAddLabelToEmailCallback: toggleLabelToEmail,
|
||||
),
|
||||
dialogLabel: 'add-label-to-email-modal',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -296,7 +296,7 @@ class EmailActionReactor {
|
||||
);
|
||||
|
||||
final newRuleFilterRequest = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.rulesFilterCreator,
|
||||
arguments: arguments,
|
||||
)
|
||||
@@ -593,7 +593,9 @@ class EmailActionReactor {
|
||||
actions: popupMenuItemEmailActions,
|
||||
submenuController: submenuController,
|
||||
onActionSelected: (action) {
|
||||
handleEmailAction(presentationEmail, action.action);
|
||||
if (action.action != EmailActionType.labelAs) {
|
||||
handleEmailAction(presentationEmail, action.action);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -738,7 +740,7 @@ class EmailActionReactor {
|
||||
);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox is PresentationMailbox) {
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
class LabelInteractorIsNull implements Exception {}
|
||||
|
||||
class LabelKeywordIsNull implements Exception {}
|
||||
class LabelKeywordIsNull implements Exception {}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
@@ -22,12 +21,12 @@ import 'package:tmail_ui_user/features/manage_account/domain/state/get_label_set
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_label_setting_state_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/logic_exception.dart';
|
||||
import 'package:tmail_ui_user/main/routes/dialog_router.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class LabelController extends BaseController {
|
||||
final labels = <Label>[].obs;
|
||||
final labelListExpandMode = Rx(ExpandMode.EXPAND);
|
||||
final isCreateNewLabelModalVisible = RxBool(false);
|
||||
final isLabelSettingEnabled = RxBool(false);
|
||||
|
||||
GetAllLabelInteractor? _getAllLabelInteractor;
|
||||
@@ -72,22 +71,13 @@ class LabelController extends BaseController {
|
||||
}
|
||||
|
||||
Future<void> openCreateNewLabelModal(AccountId? accountId) async {
|
||||
if (PlatformInfo.isWeb) {
|
||||
isCreateNewLabelModalVisible.value = true;
|
||||
}
|
||||
|
||||
await Get.generalDialog(
|
||||
barrierDismissible: true,
|
||||
barrierLabel: 'create-new-label-modal',
|
||||
pageBuilder: (_, __, ___) => CreateNewLabelModal(
|
||||
await DialogRouter().openDialogModal(
|
||||
child: CreateNewLabelModal(
|
||||
labels: labels,
|
||||
onCreateNewLabelCallback: (label) => _createNewLabel(accountId, label),
|
||||
),
|
||||
).whenComplete(() {
|
||||
if (PlatformInfo.isWeb) {
|
||||
isCreateNewLabelModalVisible.value = false;
|
||||
}
|
||||
});
|
||||
dialogLabel: 'create-new-label-modal',
|
||||
);
|
||||
}
|
||||
|
||||
void _createNewLabel(AccountId? accountId, Label label) {
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/button/default_close_button_widget.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:labels/labels.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/widgets/label_item_context_menu.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
typedef OnAddLabelToEmailCallback = Function(
|
||||
EmailId emailId,
|
||||
Label label,
|
||||
bool isSelected,
|
||||
);
|
||||
|
||||
class AddLabelToEmailModal extends StatefulWidget {
|
||||
final List<Label> labels;
|
||||
final List<Label> emailLabels;
|
||||
final EmailId emailId;
|
||||
final OnAddLabelToEmailCallback onAddLabelToEmailCallback;
|
||||
|
||||
const AddLabelToEmailModal({
|
||||
super.key,
|
||||
required this.labels,
|
||||
required this.emailLabels,
|
||||
required this.emailId,
|
||||
required this.onAddLabelToEmailCallback,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AddLabelToEmailModal> createState() => _AddLabelToEmailModalState();
|
||||
}
|
||||
|
||||
class _AddLabelToEmailModalState extends State<AddLabelToEmailModal> {
|
||||
final ImagePaths _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appLocalizations = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return LayoutBuilder(builder: (_, constraints) {
|
||||
final currentScreenWidth = constraints.maxWidth;
|
||||
final currentScreenHeight = constraints.maxHeight;
|
||||
final maxHeight = math.min(currentScreenHeight, 450).toDouble();
|
||||
|
||||
Widget bodyWidget = Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.08),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.08),
|
||||
blurRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
width: math.min(
|
||||
currentScreenWidth - 32,
|
||||
554,
|
||||
),
|
||||
constraints: BoxConstraints(maxHeight: maxHeight),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 64,
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: 32,
|
||||
end: 32,
|
||||
top: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
child: Text(
|
||||
appLocalizations.addLabel,
|
||||
style: theme.textTheme.headlineSmall?.copyWith(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Container(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: 22,
|
||||
end: 22,
|
||||
bottom: 16,
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: widget.labels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final label = widget.labels[index];
|
||||
final isSelected = widget.emailLabels.contains(label);
|
||||
return LabelItemContextMenu(
|
||||
label: label,
|
||||
imagePaths: _imagePaths,
|
||||
isSelected: isSelected,
|
||||
onSelectLabelAction: _onSelectLabel,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
DefaultCloseButtonWidget(
|
||||
iconClose: _imagePaths.icCloseDialog,
|
||||
onTapActionCallback: _onCloseModal,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
bodyWidget = Center(child: bodyWidget);
|
||||
|
||||
if (PlatformInfo.isMobile) {
|
||||
bodyWidget = GestureDetector(
|
||||
onTap: _onCloseModal,
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColor.blackAlpha20,
|
||||
body: bodyWidget,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return bodyWidget;
|
||||
});
|
||||
}
|
||||
|
||||
void _onSelectLabel(Label label, bool isSelected) {
|
||||
widget.onAddLabelToEmailCallback(widget.emailId, label, isSelected);
|
||||
popBack();
|
||||
}
|
||||
|
||||
void _onCloseModal() {
|
||||
popBack();
|
||||
}
|
||||
}
|
||||
@@ -894,7 +894,7 @@ class MailboxController extends BaseMailboxController
|
||||
final arguments = MailboxCreatorArguments(allMailboxes, parentMailbox);
|
||||
|
||||
final result = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.mailboxCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.mailboxCreator, arguments: arguments)
|
||||
: await push(AppRoutes.mailboxCreator, arguments: arguments);
|
||||
|
||||
if (result != null && result is NewMailboxArguments) {
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ class AdvancedFilterController extends BaseController {
|
||||
);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.destinationPicker,
|
||||
arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
+6
-6
@@ -1342,7 +1342,7 @@ class MailboxDashBoardController extends ReloadableController
|
||||
);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox != null &&
|
||||
@@ -2201,7 +2201,7 @@ class MailboxDashBoardController extends ReloadableController
|
||||
contactViewTitle: '${appLocalizations.findEmails} ${appLocalizations.from_email_address_prefix.toLowerCase()}'
|
||||
);
|
||||
|
||||
final newListContact = await DialogRouter.pushGeneralDialog(
|
||||
final newListContact = await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.contact,
|
||||
arguments: contactArgument);
|
||||
|
||||
@@ -2224,7 +2224,7 @@ class MailboxDashBoardController extends ReloadableController
|
||||
contactViewTitle: '${appLocalizations.findEmails} ${appLocalizations.to_email_address_prefix.toLowerCase()}'
|
||||
);
|
||||
|
||||
final newListContact = await DialogRouter.pushGeneralDialog(
|
||||
final newListContact = await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.contact,
|
||||
arguments: contactArgument);
|
||||
|
||||
@@ -2249,7 +2249,7 @@ class MailboxDashBoardController extends ReloadableController
|
||||
mailboxIdSelected: mailboxIdSelected);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.destinationPicker,
|
||||
arguments: destinationArgument)
|
||||
: await push(
|
||||
@@ -3275,8 +3275,8 @@ class MailboxDashBoardController extends ReloadableController
|
||||
if (currentAccountId != null && currentSession != null) {
|
||||
final arguments = EmailRecoveryArguments(currentAccountId, currentSession);
|
||||
|
||||
final result = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
final result = PlatformInfo.isWeb
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.emailRecovery,
|
||||
arguments: arguments,
|
||||
)
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ extension HandleCreateNewRuleFilter on MailboxDashBoardController {
|
||||
);
|
||||
|
||||
final newRuleFilterRequest = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.rulesFilterCreator,
|
||||
arguments: arguments,
|
||||
)
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ extension VerifyDisplayOverlayViewOnIframeExtension
|
||||
isAppGridDialogDisplayed.isTrue ||
|
||||
isDrawerOpened.isTrue ||
|
||||
isContextMenuOpened.isTrue ||
|
||||
isPopupMenuOpened.isTrue ||
|
||||
labelController.isCreateNewLabelModalVisible.isTrue;
|
||||
isPopupMenuOpened.isTrue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class EmailRulesController extends BaseController {
|
||||
final arguments = RulesFilterCreatorArguments(accountId, session);
|
||||
|
||||
final newRuleFilterRequest = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.rulesFilterCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.rulesFilterCreator, arguments: arguments)
|
||||
: await push(AppRoutes.rulesFilterCreator, arguments: arguments);
|
||||
|
||||
if (newRuleFilterRequest is CreateNewEmailRuleFilterRequest) {
|
||||
@@ -139,7 +139,7 @@ class EmailRulesController extends BaseController {
|
||||
tMailRule: rule);
|
||||
|
||||
final newRuleFilterRequest = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.rulesFilterCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.rulesFilterCreator, arguments: arguments)
|
||||
: await push(AppRoutes.rulesFilterCreator, arguments: arguments);
|
||||
|
||||
if (newRuleFilterRequest is EditEmailRuleFilterRequest) {
|
||||
|
||||
@@ -230,7 +230,7 @@ class IdentitiesController extends ReloadableController implements BeforeReconne
|
||||
);
|
||||
|
||||
newIdentityArguments = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
: await push(AppRoutes.identityCreator, arguments: arguments);
|
||||
|
||||
if (newIdentityArguments is CreateNewIdentityRequest) {
|
||||
@@ -382,7 +382,7 @@ class IdentitiesController extends ReloadableController implements BeforeReconne
|
||||
actionType: IdentityActionType.edit);
|
||||
|
||||
newIdentityArguments = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
: await push(AppRoutes.identityCreator, arguments: arguments);
|
||||
|
||||
if (newIdentityArguments is CreateNewIdentityRequest) {
|
||||
@@ -480,7 +480,7 @@ class IdentitiesController extends ReloadableController implements BeforeReconne
|
||||
actionType: identityCache.identityActionType);
|
||||
|
||||
newIdentityArguments = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.identityCreator, arguments: arguments)
|
||||
: await push(AppRoutes.identityCreator, arguments: arguments);
|
||||
|
||||
if (newIdentityArguments == null) {
|
||||
|
||||
@@ -30,8 +30,8 @@ class SignatureBuilder extends StatelessWidget {
|
||||
if (PlatformInfo.isWeb) {
|
||||
final iframeOverlay = Obx(() {
|
||||
if (MessageDialogActionManager().isDialogOpened ||
|
||||
DialogRouter.isDialogOpened ||
|
||||
DialogRouter.isRuleFilterDialogOpened.isTrue) {
|
||||
DialogRouter().isDialogOpened ||
|
||||
DialogRouter().isRuleFilterDialogOpened.isTrue) {
|
||||
return Positioned.fill(
|
||||
child: PointerInterceptor(
|
||||
child: const SizedBox.expand(),
|
||||
|
||||
@@ -441,7 +441,7 @@ class RulesFilterCreatorController extends BaseMailboxController {
|
||||
_session);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox is PresentationMailbox && context.mounted) {
|
||||
|
||||
@@ -705,7 +705,7 @@ class SearchEmailController extends BaseController
|
||||
mailboxIdSelected: mailbox?.id);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox is! PresentationMailbox) return;
|
||||
|
||||
@@ -827,7 +827,7 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
|
||||
final arguments = MailboxCreatorArguments(allMailboxes, parentMailbox);
|
||||
|
||||
final result = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.mailboxCreator, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.mailboxCreator, arguments: arguments)
|
||||
: await push(AppRoutes.mailboxCreator, arguments: arguments);
|
||||
|
||||
if (result != null && result is NewMailboxArguments) {
|
||||
|
||||
@@ -16,4 +16,8 @@ extension MapKeywordsExtension on Map<KeyWordIdentifier, bool>? {
|
||||
Map<KeyWordIdentifier, bool> withoutKeyword(KeyWordIdentifier keyword) {
|
||||
return Map<KeyWordIdentifier, bool>.from(this ?? {})..remove(keyword);
|
||||
}
|
||||
|
||||
void addKeyword(KeyWordIdentifier keyword) {
|
||||
this?[keyword] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ mixin EmailActionController {
|
||||
mailboxIdSelected: mailboxContain.mailboxId);
|
||||
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
? await DialogRouter().pushGeneralDialog(routeName: AppRoutes.destinationPicker, arguments: arguments)
|
||||
: await push(AppRoutes.destinationPicker, arguments: arguments);
|
||||
|
||||
if (destinationMailbox != null &&
|
||||
|
||||
+1
-1
@@ -211,7 +211,7 @@ extension OnThreadDetailActionClick on ThreadDetailController {
|
||||
mailboxIdSelected: mailboxIdSelected,
|
||||
);
|
||||
final destinationMailbox = PlatformInfo.isWeb
|
||||
? await DialogRouter.pushGeneralDialog(
|
||||
? await DialogRouter().pushGeneralDialog(
|
||||
routeName: AppRoutes.destinationPicker,
|
||||
arguments: arguments,
|
||||
)
|
||||
|
||||
@@ -5315,5 +5315,11 @@
|
||||
"placeholders": {
|
||||
"labelName": {}
|
||||
}
|
||||
},
|
||||
"addLabel": "Add label",
|
||||
"@addLabel": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
@@ -5642,4 +5642,11 @@ class AppLocalizations {
|
||||
args: [labelName],
|
||||
);
|
||||
}
|
||||
|
||||
String get addLabel {
|
||||
return Intl.message(
|
||||
'Add label',
|
||||
name: 'addLabel',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/contact/presentation/contact_bindings.dart';
|
||||
@@ -17,12 +17,19 @@ import 'package:tmail_ui_user/features/rules_filter_creator/presentation/rules_f
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
|
||||
class DialogRouter {
|
||||
static final _instance = DialogRouter._();
|
||||
|
||||
static Future<dynamic> pushGeneralDialog({
|
||||
factory DialogRouter() => _instance;
|
||||
|
||||
DialogRouter._();
|
||||
|
||||
Future<dynamic> pushGeneralDialog({
|
||||
required String routeName,
|
||||
required Object? arguments
|
||||
}) async {
|
||||
_isDialogOpened.value = true;
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isDialogOpened.value = true;
|
||||
}
|
||||
_bindingDI(routeName);
|
||||
|
||||
final returnedValue = await Get.generalDialog(
|
||||
@@ -32,19 +39,21 @@ class DialogRouter {
|
||||
pageBuilder: (_, __, ___) => _generateView(routeName: routeName)
|
||||
);
|
||||
|
||||
_isDialogOpened.value = false;
|
||||
if (routeName == AppRoutes.rulesFilterCreator) {
|
||||
isRuleFilterDialogOpened.value = false;
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isDialogOpened.value = false;
|
||||
if (routeName == AppRoutes.rulesFilterCreator) {
|
||||
isRuleFilterDialogOpened.value = false;
|
||||
}
|
||||
}
|
||||
return returnedValue;
|
||||
}
|
||||
|
||||
static final RxBool _isDialogOpened = false.obs;
|
||||
static final RxBool isRuleFilterDialogOpened = false.obs;
|
||||
final RxBool _isDialogOpened = false.obs;
|
||||
final RxBool isRuleFilterDialogOpened = false.obs;
|
||||
|
||||
static bool get isDialogOpened => _isDialogOpened.value;
|
||||
bool get isDialogOpened => _isDialogOpened.value;
|
||||
|
||||
static void _bindingDI(String routeName) {
|
||||
void _bindingDI(String routeName) {
|
||||
log('DialogRouter::_bindingDI():routeName: $routeName');
|
||||
switch(routeName) {
|
||||
case AppRoutes.mailboxCreator:
|
||||
@@ -69,7 +78,7 @@ class DialogRouter {
|
||||
}
|
||||
}
|
||||
|
||||
static Widget _generateView({required String routeName}) {
|
||||
Widget _generateView({required String routeName}) {
|
||||
switch(routeName) {
|
||||
case AppRoutes.mailboxCreator:
|
||||
return MailboxCreatorView();
|
||||
@@ -87,4 +96,23 @@ class DialogRouter {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> openDialogModal({
|
||||
required Widget child,
|
||||
String? dialogLabel,
|
||||
}) async {
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isDialogOpened.value = true;
|
||||
}
|
||||
|
||||
await Get.generalDialog(
|
||||
barrierDismissible: true,
|
||||
barrierLabel: dialogLabel,
|
||||
pageBuilder: (_, __, ___) => child,
|
||||
).whenComplete(() {
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isDialogOpened.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -105,9 +105,6 @@ class MockLabelController extends Mock implements LabelController {
|
||||
|
||||
@override
|
||||
Rx<ExpandMode> get labelListExpandMode => Rx(ExpandMode.EXPAND);
|
||||
|
||||
@override
|
||||
RxBool get isCreateNewLabelModalVisible => RxBool(false);
|
||||
}
|
||||
|
||||
class MockMailboxDashBoardController extends Mock implements MailboxDashBoardController {
|
||||
|
||||
@@ -27,6 +27,7 @@ import 'package:tmail_ui_user/features/email/data/repository/calendar_event_repo
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/get_email_content_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.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/calendar_event_accept_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_reject_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/get_email_content_interactor.dart';
|
||||
@@ -73,6 +74,7 @@ const fallbackGenerators = {
|
||||
MockSpec<MarkAsStarEmailInteractor>(),
|
||||
MockSpec<GetAllIdentitiesInteractor>(),
|
||||
MockSpec<StoreOpenedEmailInteractor>(),
|
||||
MockSpec<AddALabelToAnEmailInteractor>(),
|
||||
MockSpec<MailboxDashBoardController>(fallbackGenerators: fallbackGenerators),
|
||||
MockSpec<DownloadController>(fallbackGenerators: fallbackGenerators),
|
||||
MockSpec<DownloadManager>(fallbackGenerators: fallbackGenerators),
|
||||
@@ -106,6 +108,7 @@ void main() {
|
||||
final markAsStarEmailInteractor = MockMarkAsStarEmailInteractor();
|
||||
final getAllIdentitiesInteractor = MockGetAllIdentitiesInteractor();
|
||||
final storeOpenedEmailInteractor = MockStoreOpenedEmailInteractor();
|
||||
final addALabelToAnEmailInteractor = MockAddALabelToAnEmailInteractor();
|
||||
final mailboxDashboardController = MockMailboxDashBoardController();
|
||||
final downloadController = MockDownloadController();
|
||||
final downloadManager = MockDownloadManager();
|
||||
@@ -171,6 +174,7 @@ void main() {
|
||||
markAsStarEmailInteractor,
|
||||
getAllIdentitiesInteractor,
|
||||
storeOpenedEmailInteractor,
|
||||
addALabelToAnEmailInteractor,
|
||||
printEmailInteractor,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user