diff --git a/lib/features/destination_picker/presentation/destination_picker_bindings.dart b/lib/features/destination_picker/presentation/destination_picker_bindings.dart index 80b173f0d..c231f4f6c 100644 --- a/lib/features/destination_picker/presentation/destination_picker_bindings.dart +++ b/lib/features/destination_picker/presentation/destination_picker_bindings.dart @@ -1,5 +1,6 @@ import 'package:core/core.dart'; import 'package:get/get.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; import 'package:tmail_ui_user/features/destination_picker/presentation/destination_picker_controller.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart'; @@ -14,26 +15,57 @@ import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_reposit import 'package:tmail_ui_user/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart'; -class DestinationPickerBindings extends Bindings { +class DestinationPickerBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => MailboxDataSourceImpl(Get.find())); + _bindingsUtils(); + super.dependencies(); + } + + void _bindingsUtils() { + Get.lazyPut(() => TreeBuilder()); + } + + @override + void bindingsController() { + Get.lazyPut(() => DestinationPickerController( + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => MailboxDataSourceImpl(Get.find())); Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find())); Get.lazyPut(() => StateDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => MailboxRepositoryImpl( - { - DataSourceType.network: Get.find(), - DataSourceType.local: Get.find() - }, - Get.find() - )); - Get.lazyPut(() => Get.find()); + } + + @override + void bindingsInteractor() { Get.lazyPut(() => GetAllMailboxInteractor(Get.find())); - Get.lazyPut(() => TreeBuilder()); - Get.lazyPut(() => DestinationPickerController( - Get.find(), - Get.find())); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => MailboxRepositoryImpl( + { + DataSourceType.network: Get.find(), + DataSourceType.local: Get.find() + }, + Get.find() + )); } } \ No newline at end of file diff --git a/lib/features/destination_picker/presentation/destination_picker_view.dart b/lib/features/destination_picker/presentation/destination_picker_view.dart index aedba5a13..cee096a26 100644 --- a/lib/features/destination_picker/presentation/destination_picker_view.dart +++ b/lib/features/destination_picker/presentation/destination_picker_view.dart @@ -240,7 +240,7 @@ class DestinationPickerView extends GetWidget { defaultMailboxList[index], mailboxDisplayed: MailboxDisplayed.destinationPicker, isLastElement: index == defaultMailboxList.length - 1) - ..onOpenMailboxAction((mailbox) => + ..addOnOpenMailboxAction((mailbox) => controller.selectMailboxAction(mailbox.toPresentationMailboxWithMailboxPath(mailbox.name?.name ?? '')))) .build()); } else { diff --git a/lib/features/email/presentation/email_bindings.dart b/lib/features/email/presentation/email_bindings.dart index 78bc530ea..c87b35b7f 100644 --- a/lib/features/email/presentation/email_bindings.dart +++ b/lib/features/email/presentation/email_bindings.dart @@ -1,6 +1,7 @@ import 'package:core/core.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart'; import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart'; import 'package:tmail_ui_user/features/email/data/datasource_impl/email_datasource_impl.dart'; @@ -19,40 +20,70 @@ import 'package:tmail_ui_user/features/email/presentation/email_controller.dart' import 'package:tmail_ui_user/features/login/data/repository/credential_repository_impl.dart'; import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart'; -class EmailBindings extends Bindings { +class EmailBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => EmailDataSourceImpl(Get.find())); + super.dependencies(); + } + + @override + void bindingsController() { + Get.put(EmailController( + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { Get.lazyPut(() => Get.find()); - Get.lazyPut(() => HtmlDataSourceImpl( - Get.find(), - Get.find())); Get.lazyPut(() => Get.find()); - Get.lazyPut(() => EmailRepositoryImpl( - Get.find(), - Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => GetEmailContentInteractor( - Get.find())); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => EmailDataSourceImpl(Get.find())); + Get.lazyPut(() => HtmlDataSourceImpl( + Get.find(), + Get.find(), + )); + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => GetEmailContentInteractor(Get.find())); Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); - Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); Get.lazyPut(() => DownloadAttachmentsInteractor( - Get.find(), - Get.find())); + Get.find(), + Get.find(), + )); Get.lazyPut(() => ExportAttachmentInteractor( - Get.find(), - Get.find())); + Get.find(), + Get.find(), + )); Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find())); - Get.put(EmailController( - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find())); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => EmailRepositoryImpl( + Get.find(), + Get.find(), + )); + Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); } } \ No newline at end of file diff --git a/lib/features/home/presentation/home_bindings.dart b/lib/features/home/presentation/home_bindings.dart index 6dca2f6ea..112615af2 100644 --- a/lib/features/home/presentation/home_bindings.dart +++ b/lib/features/home/presentation/home_bindings.dart @@ -1,6 +1,7 @@ import 'package:core/core.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/cleanup/data/datasource/cleanup_datasource.dart'; import 'package:tmail_ui_user/features/cleanup/data/datasource_impl/cleanup_datasource_impl.dart'; import 'package:tmail_ui_user/features/cleanup/data/repository/cleanup_repository_impl.dart'; @@ -12,23 +13,51 @@ import 'package:tmail_ui_user/features/login/domain/repository/credential_reposi import 'package:tmail_ui_user/features/login/domain/usecases/get_credential_interactor.dart'; import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart'; -class HomeBindings extends Bindings { +class HomeBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => GetCredentialInteractor(Get.find())); - Get.lazyPut(() => CleanupDataSourceImpl( - Get.find(), - Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => CleanupRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => CleanupEmailCacheInteractor(Get.find())); + super.dependencies(); + } + + @override + void bindingsController() { Get.lazyPut(() => HomeController( - Get.find(), - Get.find(), - Get.find(), - Get.find())); + Get.find(), + Get.find(), + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => CleanupDataSourceImpl( + Get.find(), + Get.find(), + )); + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => GetCredentialInteractor(Get.find())); + Get.lazyPut(() => CleanupEmailCacheInteractor(Get.find())); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); + Get.lazyPut(() => CleanupRepositoryImpl(Get.find())); } } \ No newline at end of file diff --git a/lib/features/login/presentation/login_bindings.dart b/lib/features/login/presentation/login_bindings.dart index bc4c61fb7..662e8794c 100644 --- a/lib/features/login/presentation/login_bindings.dart +++ b/lib/features/login/presentation/login_bindings.dart @@ -1,6 +1,7 @@ import 'package:core/core.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/login/data/datasource/authentication_datasource.dart'; import 'package:tmail_ui_user/features/login/data/datasource_impl/authentication_datasource_impl.dart'; import 'package:tmail_ui_user/features/login/data/repository/authentication_repository_impl.dart'; @@ -10,24 +11,49 @@ import 'package:tmail_ui_user/features/login/domain/repository/credential_reposi import 'package:tmail_ui_user/features/login/domain/usecases/authentication_user_interactor.dart'; import 'package:tmail_ui_user/features/login/presentation/login_controller.dart'; -class LoginBindings extends Bindings { +class LoginBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => AuthenticationDataSourceImpl()); - Get.lazyPut(() => Get.find()); - - Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - - Get.lazyPut(() => AuthenticationRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - - Get.lazyPut(() => AuthenticationInteractor(Get.find(), Get.find())); + super.dependencies(); + } + @override + void bindingsController() { Get.lazyPut(() => LoginController( - Get.find(), - Get.find(), - Get.find()) - ); + Get.find(), + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => AuthenticationDataSourceImpl()); + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => AuthenticationInteractor( + Get.find(), + Get.find(), + )); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); + Get.lazyPut(() => AuthenticationRepositoryImpl(Get.find())); } } \ No newline at end of file diff --git a/lib/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart b/lib/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart index 79ddcaeb0..42454eb9a 100644 --- a/lib/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart +++ b/lib/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart @@ -1,5 +1,7 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; +import 'package:model/mailbox/expand_mode.dart'; +import 'package:model/mailbox/select_mode.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart'; extension ListMailboxNodeExtensions on List { @@ -15,4 +17,29 @@ extension ListMailboxNodeExtensions on List { } }).toList(); } + + List? toggleSelectMailboxNode(MailboxNode selectedMailboxMode) { + return map((MailboxNode child) { + if (child.item.id == selectedMailboxMode.item.id) { + return child.toggleSelectMailboxNode(); + } else { + if (child.hasChildren()) { + return child.copyWith(mailboxNodes: child.toggleSelectNode(selectedMailboxMode)); + } + return child; + } + }).toList(); + } + + List? toSelectMailboxNode({required SelectMode selectMode, ExpandMode? newExpandMode}) { + return map((MailboxNode child) { + if (child.hasChildren()) { + return child.copyWith( + mailboxNodes: child.toSelectedNode(selectMode: selectMode, newExpandMode: newExpandMode), + newSelectMode: selectMode, + newExpandMode: newExpandMode); + } + return child.toSelectedMailboxNode(selectMode: selectMode, newExpandMode: newExpandMode); + }).toList(); + } } \ No newline at end of file diff --git a/lib/features/mailbox/presentation/mailbox_bindings.dart b/lib/features/mailbox/presentation/mailbox_bindings.dart index 67c129073..1be0fa2d6 100644 --- a/lib/features/mailbox/presentation/mailbox_bindings.dart +++ b/lib/features/mailbox/presentation/mailbox_bindings.dart @@ -1,7 +1,7 @@ import 'package:core/core.dart'; -import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/caching/caching_manager.dart'; import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; import 'package:tmail_ui_user/features/login/data/repository/credential_repository_impl.dart'; @@ -12,8 +12,8 @@ import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource. import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_cache_datasource_impl.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_datasource_impl.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/state_datasource_impl.dart'; -import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart'; import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart'; import 'package:tmail_ui_user/features/mailbox/data/repository/mailbox_repository_impl.dart'; import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart'; import 'package:tmail_ui_user/features/mailbox/domain/usecases/create_new_mailbox_interactor.dart'; @@ -24,44 +24,76 @@ import 'package:tmail_ui_user/features/mailbox/presentation/mailbox_controller.d import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart'; import 'package:uuid/uuid.dart'; -class MailboxBindings extends Bindings { +class MailboxBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => DeleteCredentialInteractor(Get.find())); - Get.lazyPut(() => MailboxDataSourceImpl(Get.find())); + _bindingsUtils(); + super.dependencies(); + } + + void _bindingsUtils() { + Get.lazyPut(() => TreeBuilder()); + Get.lazyPut(() => Uuid()); + } + + @override + void bindingsController() { + Get.put(MailboxController( + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => MailboxDataSourceImpl(Get.find())); Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find())); Get.lazyPut(() => StateDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); + + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => DeleteCredentialInteractor(Get.find())); + Get.lazyPut(() => GetAllMailboxInteractor(Get.find())); + Get.lazyPut(() => RefreshAllMailboxInteractor(Get.find())); + Get.lazyPut(() => CreateNewMailboxInteractor(Get.find())); + Get.lazyPut(() => SearchMailboxInteractor()); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); Get.lazyPut(() => MailboxRepositoryImpl( { DataSourceType.network: Get.find(), DataSourceType.local: Get.find() }, - Get.find() + Get.find(), )); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => GetAllMailboxInteractor(Get.find())); - Get.lazyPut(() => RefreshAllMailboxInteractor(Get.find())); - Get.lazyPut(() => TreeBuilder()); - Get.lazyPut(() => CreateNewMailboxInteractor(Get.find())); - Get.lazyPut(() => SearchMailboxInteractor()); - Get.lazyPut(() => Uuid()); - Get.lazyPut(() => TextEditingController()); - Get.lazyPut(() => FocusNode()); - Get.put(MailboxController( - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find(), - Get.find())); } } \ No newline at end of file diff --git a/lib/features/mailbox/presentation/mailbox_controller.dart b/lib/features/mailbox/presentation/mailbox_controller.dart index fc7b5d8f5..28e17b603 100644 --- a/lib/features/mailbox/presentation/mailbox_controller.dart +++ b/lib/features/mailbox/presentation/mailbox_controller.dart @@ -61,6 +61,7 @@ class MailboxController extends BaseController { final listMailboxSearched = [].obs; final searchState = SearchState.initial().obs; final searchQuery = SearchQuery.initial().obs; + final currentSelectMode = SelectMode.INACTIVE.obs; MailboxTree folderMailboxTree = MailboxTree(MailboxNode.root()); List allMailboxes = []; @@ -191,9 +192,11 @@ class MailboxController extends BaseController { final newMailboxNodeList = folderMailboxNodeList.updateNode( mailboxNode.item.id, - mailboxNode.copyWith(newExpandMode: newExpandMode)) ?? []; + mailboxNode.copyWith(newExpandMode: newExpandMode)); - folderMailboxNodeList.value = newMailboxNodeList; + if (newMailboxNodeList != null) { + folderMailboxNodeList.value = newMailboxNodeList; + } } void _setUpMapMailboxIdDefault(List defaultMailboxList, List folderMailboxList) { @@ -241,13 +244,7 @@ class MailboxController extends BaseController { } } - SelectMode getSelectMode(PresentationMailbox presentationMailbox, PresentationMailbox? selectedMailbox) { - return presentationMailbox.id == selectedMailbox?.id - ? SelectMode.ACTIVE - : SelectMode.INACTIVE; - } - - void selectMailbox( + void openMailbox( BuildContext context, PresentationMailbox presentationMailboxSelected ) { @@ -372,6 +369,57 @@ class MailboxController extends BaseController { listMailboxSearched.clear(); } + void enableSelectionMailbox() { + currentSelectMode.value = SelectMode.ACTIVE; + } + + void disableSelectionMailbox() { + _cancelSelectMailbox(); + } + + void selectMailbox(BuildContext context, PresentationMailbox mailboxSelected) { + if (isSearchActive()) { + listMailboxSearched.value = listMailboxSearched + .map((mailbox) => mailbox.id == mailboxSelected.id + ? mailbox.toggleSelectPresentationMailbox() + : mailbox) + .toList(); + } else { + defaultMailboxList.value = defaultMailboxList + .map((mailbox) => mailbox.id == mailboxSelected.id + ? mailbox.toggleSelectPresentationMailbox() + : mailbox) + .toList(); + } + } + + void selectMailboxNode(BuildContext context, MailboxNode mailboxNodeSelected) { + final newMailboxNodeList = folderMailboxNodeList.toggleSelectMailboxNode(mailboxNodeSelected); + if (newMailboxNodeList != null) { + folderMailboxNodeList.value = newMailboxNodeList; + } + } + + void _cancelSelectMailbox() { + if (isSearchActive()) { + listMailboxSearched.value = listMailboxSearched + .map((mailbox) => mailbox.toSelectedPresentationMailbox(selectMode: SelectMode.INACTIVE)) + .toList(); + } else { + defaultMailboxList.value = defaultMailboxList + .map((mailbox) => mailbox.toSelectedPresentationMailbox(selectMode: SelectMode.INACTIVE)) + .toList(); + + final newMailboxNodeList = folderMailboxNodeList.toSelectMailboxNode( + selectMode: SelectMode.INACTIVE, + newExpandMode: ExpandMode.COLLAPSE); + if (newMailboxNodeList != null) { + folderMailboxNodeList.value = newMailboxNodeList; + } + } + currentSelectMode.value = SelectMode.INACTIVE; + } + void closeMailboxScreen(BuildContext context) { mailboxDashBoardController.closeDrawer(); } diff --git a/lib/features/mailbox/presentation/mailbox_view.dart b/lib/features/mailbox/presentation/mailbox_view.dart index ce5ffef7d..b2ff48f11 100644 --- a/lib/features/mailbox/presentation/mailbox_view.dart +++ b/lib/features/mailbox/presentation/mailbox_view.dart @@ -63,10 +63,14 @@ class MailboxView extends GetWidget { bottom: 10), child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ !responsiveUtils.isDesktop(context) ? _buildCloseScreenButton(context) : SizedBox(width: 50), + Obx(() => controller.currentSelectMode.value == SelectMode.INACTIVE + ? SizedBox(width: 40) + : SizedBox(width: 49)), Expanded(child: Text( AppLocalizations.of(context).folders, textAlign: TextAlign.center, - style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),)), + style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700))), + Obx(() => _buildEditMailboxButton(context, controller.currentSelectMode.value)), _buildAddNewFolderButton(context), ])), Divider(color: AppColor.colorDividerMailbox, height: 0.5, thickness: 0.2), @@ -85,13 +89,28 @@ class MailboxView extends GetWidget { Widget _buildAddNewFolderButton(BuildContext context) { return Padding( - padding: EdgeInsets.only(left: 16, right: 16), + padding: EdgeInsets.only(right: 10), child: IconButton( key: Key('create_new_mailbox_button'), onPressed: () => controller.goToCreateNewMailboxView(), icon: SvgPicture.asset(imagePaths.icAddNewFolder, width: 30, height: 30, fit: BoxFit.fill))); } + Widget _buildEditMailboxButton(BuildContext context, SelectMode selectMode) { + return Material( + borderRadius: BorderRadius.circular(20), + color: Colors.transparent, + child: TextButton( + child: Text( + selectMode == SelectMode.INACTIVE ? AppLocalizations.of(context).edit : AppLocalizations.of(context).cancel, + style: TextStyle(fontSize: 17, color: AppColor.colorTextButton)), + onPressed: () => selectMode == SelectMode.INACTIVE + ? controller.enableSelectionMailbox() + : controller.disableSelectionMailbox() + ) + ); + } + Widget _buildUserInformationWidget(BuildContext context) { return Padding( padding: EdgeInsets.only(left: 16, top: 8.0, right: 16), @@ -175,11 +194,10 @@ class MailboxView extends GetWidget { Obx(() => (MailboxTileBuilder( imagePaths, defaultMailbox[index], - selectMode: controller.getSelectMode( - defaultMailbox[index], - controller.mailboxDashBoardController.selectedMailbox.value), + allSelectMode: controller.currentSelectMode.value, isLastElement: index == defaultMailbox.length - 1) - ..onOpenMailboxAction((mailbox) => controller.selectMailbox(context, mailbox))) + ..addOnOpenMailboxAction((mailbox) => controller.openMailbox(context, mailbox)) + ..addOnSelectMailboxActionClick((mailbox) => controller.selectMailbox(context, mailbox))) .build())); } @@ -211,11 +229,10 @@ class MailboxView extends GetWidget { context, imagePaths, mailboxNode, - selectMode: controller.getSelectMode( - mailboxNode.item, - controller.mailboxDashBoardController.selectedMailbox.value)) - ..addOnSelectMailboxFolderClick((mailboxNode) => controller.selectMailbox(context, mailboxNode.item)) - ..addOnExpandFolderActionClick((mailboxNode) => controller.toggleMailboxFolder(mailboxNode))) + allSelectMode: controller.currentSelectMode.value) + ..addOnOpenMailboxFolderClick((mailboxNode) => controller.openMailbox(context, mailboxNode.item)) + ..addOnExpandFolderActionClick((mailboxNode) => controller.toggleMailboxFolder(mailboxNode)) + ..addOnSelectMailboxFolderClick((mailboxNode) => controller.selectMailboxNode(context, mailboxNode))) .build()), children: _buildListChildTileWidget(context, mailboxNode.childrenItems!) ).build()) @@ -225,10 +242,9 @@ class MailboxView extends GetWidget { context, imagePaths, mailboxNode, - selectMode: controller.getSelectMode( - mailboxNode.item, - controller.mailboxDashBoardController.selectedMailbox.value)) - ..addOnSelectMailboxFolderClick((mailboxNode) => controller.selectMailbox(context, mailboxNode.item))) + allSelectMode: controller.currentSelectMode.value) + ..addOnOpenMailboxFolderClick((mailboxNode) => controller.openMailbox(context, mailboxNode.item)) + ..addOnSelectMailboxFolderClick((mailboxNode) => controller.selectMailboxNode(context, mailboxNode))) .build(), ))) .toList(); @@ -294,7 +310,7 @@ class MailboxView extends GetWidget { listMailbox[index], isSearchActive: controller.isSearchActive(), isLastElement: index == listMailbox.length - 1) - ..onOpenMailboxAction((mailbox) => controller.selectMailbox(context, mailbox))) + ..addOnOpenMailboxAction((mailbox) => controller.openMailbox(context, mailbox))) .build())); } } \ No newline at end of file diff --git a/lib/features/mailbox/presentation/model/mailbox_node.dart b/lib/features/mailbox/presentation/model/mailbox_node.dart index dc4cfad87..e10717724 100644 --- a/lib/features/mailbox/presentation/model/mailbox_node.dart +++ b/lib/features/mailbox/presentation/model/mailbox_node.dart @@ -3,6 +3,7 @@ import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; import 'package:model/mailbox/expand_mode.dart'; import 'package:model/mailbox/presentation_mailbox.dart'; +import 'package:model/mailbox/select_mode.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree.dart'; class MailboxNode with EquatableMixin{ @@ -11,6 +12,7 @@ class MailboxNode with EquatableMixin{ PresentationMailbox item; List? childrenItems; ExpandMode expandMode; + SelectMode selectMode; factory MailboxNode.root() => MailboxNode(_root); @@ -18,7 +20,14 @@ class MailboxNode with EquatableMixin{ bool hasChildren() => childrenItems?.isNotEmpty ?? false; - MailboxNode(this.item, {this.childrenItems, this.expandMode = ExpandMode.COLLAPSE}); + MailboxNode( + this.item, + { + this.childrenItems, + this.expandMode = ExpandMode.COLLAPSE, + this.selectMode = SelectMode.INACTIVE + } + ); void addChildNode(MailboxNode node) { if (childrenItems == null) { @@ -72,15 +81,66 @@ class MailboxNode with EquatableMixin{ }).toList(); } + List? toggleSelectNode(MailboxNode selectedMailboxMode, {MailboxNode? parent}) { + List? _children = parent == null ? this.childrenItems : parent.childrenItems; + return _children?.map((MailboxNode child) { + if (child.item.id == selectedMailboxMode.item.id) { + return child.toggleSelectMailboxNode(); + } else { + if (child.hasChildren()) { + return child.copyWith(mailboxNodes: toggleSelectNode(selectedMailboxMode, parent: child)); + } + return child; + } + }).toList(); + } + + List? toSelectedNode({required SelectMode selectMode, ExpandMode? newExpandMode, MailboxNode? parent}) { + List? _children = parent == null ? this.childrenItems : parent.childrenItems; + return _children?.map((MailboxNode child) { + if (child.hasChildren()) { + return child.copyWith( + mailboxNodes: toSelectedNode(selectMode: selectMode, newExpandMode: newExpandMode, parent: child), + newSelectMode: selectMode, + newExpandMode: newExpandMode); + } + return child.toSelectedMailboxNode(selectMode: selectMode, newExpandMode: newExpandMode); + }).toList(); + } + @override List get props => [item, childrenItems]; } extension MailboxNodeExtension on MailboxNode { - MailboxNode copyWith({ExpandMode? newExpandMode, List? mailboxNodes}) { + MailboxNode copyWith({ + SelectMode? newSelectMode, + ExpandMode? newExpandMode, + List? mailboxNodes + }) { return MailboxNode( item, childrenItems: mailboxNodes ?? childrenItems, - expandMode: newExpandMode ?? expandMode); + expandMode: newExpandMode ?? expandMode, + selectMode: newSelectMode ?? selectMode, + ); + } + + MailboxNode toggleSelectMailboxNode() { + return MailboxNode( + item, + childrenItems: childrenItems, + expandMode: expandMode, + selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE, + ); + } + + MailboxNode toSelectedMailboxNode({required SelectMode selectMode, ExpandMode? newExpandMode}) { + return MailboxNode( + item, + childrenItems: childrenItems, + expandMode: newExpandMode ?? expandMode, + selectMode: selectMode, + ); } } diff --git a/lib/features/mailbox/presentation/widgets/mailbox_folder_tile_builder.dart b/lib/features/mailbox/presentation/widgets/mailbox_folder_tile_builder.dart index b9503a300..56cea6485 100644 --- a/lib/features/mailbox/presentation/widgets/mailbox_folder_tile_builder.dart +++ b/lib/features/mailbox/presentation/widgets/mailbox_folder_tile_builder.dart @@ -6,18 +6,20 @@ import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_displa import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; -typedef OnExpandFolderActionClick = void Function(MailboxNode mailboxNode); -typedef OnSelectMailboxFolderClick = void Function(MailboxNode mailboxNode); +typedef OnExpandFolderActionClick = void Function(MailboxNode); +typedef OnOpenMailboxFolderClick = void Function(MailboxNode); +typedef OnSelectMailboxFolderClick = void Function(MailboxNode); class MailBoxFolderTileBuilder { final MailboxNode _mailboxNode; final BuildContext _context; final ImagePaths _imagePaths; - final SelectMode selectMode; + final SelectMode allSelectMode; final MailboxDisplayed mailboxDisplayed; OnExpandFolderActionClick? _onExpandFolderActionClick; + OnOpenMailboxFolderClick? _onOpenMailboxFolderClick; OnSelectMailboxFolderClick? _onSelectMailboxFolderClick; MailBoxFolderTileBuilder( @@ -25,7 +27,7 @@ class MailBoxFolderTileBuilder { this._imagePaths, this._mailboxNode, { - this.selectMode = SelectMode.INACTIVE, + this.allSelectMode = SelectMode.INACTIVE, this.mailboxDisplayed = MailboxDisplayed.mailbox, } ); @@ -34,6 +36,10 @@ class MailBoxFolderTileBuilder { this._onExpandFolderActionClick = onExpandFolderActionClick; } + void addOnOpenMailboxFolderClick(OnOpenMailboxFolderClick onOpenMailboxFolderClick) { + this._onOpenMailboxFolderClick = onOpenMailboxFolderClick; + } + void addOnSelectMailboxFolderClick(OnSelectMailboxFolderClick onSelectMailboxFolderClick) { this._onSelectMailboxFolderClick = onSelectMailboxFolderClick; } @@ -54,15 +60,11 @@ class MailBoxFolderTileBuilder { data: MediaQueryData(padding: EdgeInsets.zero), child: Column(children: [ ListTile( - onTap: () { - if (_onSelectMailboxFolderClick != null) { - _onSelectMailboxFolderClick!(_mailboxNode); - } - }, + onTap: () => _onOpenMailboxFolderClick?.call(_mailboxNode), contentPadding: EdgeInsets.zero, - leading: Padding( - padding: EdgeInsets.only(left: 8), - child: SvgPicture.asset(_imagePaths.icFolderMailbox, width: 28, height: 28, fit: BoxFit.fill)), + leading: allSelectMode == SelectMode.ACTIVE + ? _buildSelectModeIcon() + : _buildMailboxIcon(), title: _buildTitleFolderItem(), trailing: _mailboxNode.hasChildren() ? Padding( @@ -72,18 +74,14 @@ class MailBoxFolderTileBuilder { color: AppColor.primaryColor, icon: SvgPicture.asset( _mailboxNode.expandMode == ExpandMode.EXPAND ? _imagePaths.icExpandFolder : _imagePaths.icFolderArrow, - color: selectMode == SelectMode.ACTIVE ? AppColor.mailboxSelectedIconColor : AppColor.colorArrowUserMailbox, + color: AppColor.colorArrowUserMailbox, fit: BoxFit.fill), - onPressed: () { - if (_onExpandFolderActionClick != null) { - _onExpandFolderActionClick!(_mailboxNode); - } - } + onPressed: () => _onExpandFolderActionClick?.call(_mailboxNode) )) : null ), Padding( - padding: EdgeInsets.only(left: 45), + padding: EdgeInsets.only(left: allSelectMode == SelectMode.ACTIVE ? 50 : 45), child: Divider(color: AppColor.lineItemListColor, height: 0.5, thickness: 0.2)), ]) ) @@ -94,6 +92,10 @@ class MailBoxFolderTileBuilder { Widget _buildTitleFolderItem() { return Row( children: [ + if (allSelectMode == SelectMode.ACTIVE) + Transform( + transform: Matrix4.translationValues(-16.0, 0.0, 0.0), + child: _buildMailboxIcon()), Expanded(child: Transform( transform: Matrix4.translationValues(-10.0, 0.0, 0.0), child: Text( @@ -120,7 +122,7 @@ class MailBoxFolderTileBuilder { padding: EdgeInsets.only(left: 8, right: 8, top: 2.5, bottom: 2.5), decoration:BoxDecoration( borderRadius: BorderRadius.circular(8), - color: selectMode == SelectMode.ACTIVE ? AppColor.backgroundCounterMailboxSelectedColor : AppColor.backgroundCounterMailboxColor), + color: AppColor.backgroundCounterMailboxColor), child: Text( '${_mailboxNode.item.getCountUnReadEmails()} ${AppLocalizations.of(_context).unread_email_notification}', maxLines: 1, @@ -128,4 +130,34 @@ class MailBoxFolderTileBuilder { style: TextStyle(fontSize: 12, color: AppColor.colorNameEmail), )); } + + Widget _buildMailboxIcon() { + return Padding( + padding: EdgeInsets.only( + left: allSelectMode == SelectMode.ACTIVE ? 0 : 8, + right: allSelectMode == SelectMode.ACTIVE ? 8 : 0), + child: SvgPicture.asset( + _imagePaths.icFolderMailbox, + width: 28, + height: 28, + fit: BoxFit.fill + ) + ); + } + + Widget _buildSelectModeIcon() { + return Material( + borderRadius: BorderRadius.circular(10), + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.zero, + icon: SvgPicture.asset( + _mailboxNode.selectMode == SelectMode.ACTIVE ? _imagePaths.icSelectedV2 : _imagePaths.icUnSelectedV2, + width: 20, + height: 20, + fit: BoxFit.fill), + onPressed: () => _onSelectMailboxFolderClick?.call(_mailboxNode) + ) + ); + } } \ No newline at end of file diff --git a/lib/features/mailbox/presentation/widgets/mailbox_tile_builder.dart b/lib/features/mailbox/presentation/widgets/mailbox_tile_builder.dart index 55e6f5854..92c41fd7b 100644 --- a/lib/features/mailbox/presentation/widgets/mailbox_tile_builder.dart +++ b/lib/features/mailbox/presentation/widgets/mailbox_tile_builder.dart @@ -5,34 +5,40 @@ import 'package:model/model.dart'; import 'package:tmail_ui_user/features/mailbox/domain/extensions/presentation_mailbox_extension.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_displayed.dart'; -typedef OnOpenMailboxActionClick = void Function(PresentationMailbox mailbox); +typedef OnOpenMailboxActionClick = void Function(PresentationMailbox); +typedef OnSelectMailboxActionClick = void Function(PresentationMailbox); class MailboxTileBuilder { final PresentationMailbox _presentationMailbox; - final SelectMode selectMode; + final SelectMode allSelectMode; final ImagePaths _imagePaths; final MailboxDisplayed mailboxDisplayed; final bool isLastElement; final bool isSearchActive; OnOpenMailboxActionClick? _onOpenMailboxActionClick; + OnSelectMailboxActionClick? _onSelectMailboxActionClick; MailboxTileBuilder( this._imagePaths, this._presentationMailbox, { - this.selectMode = SelectMode.INACTIVE, + this.allSelectMode = SelectMode.INACTIVE, this.mailboxDisplayed = MailboxDisplayed.mailbox, this.isLastElement = false, this.isSearchActive = false, } ); - void onOpenMailboxAction(OnOpenMailboxActionClick onOpenMailboxActionClick) { + void addOnOpenMailboxAction(OnOpenMailboxActionClick onOpenMailboxActionClick) { _onOpenMailboxActionClick = onOpenMailboxActionClick; } + void addOnSelectMailboxActionClick(OnSelectMailboxActionClick onSelectMailboxActionClick) { + _onSelectMailboxActionClick = onSelectMailboxActionClick; + } + Widget build() { return Theme( data: ThemeData( @@ -50,21 +56,17 @@ class MailboxTileBuilder { child: Column(children: [ ListTile( contentPadding: EdgeInsets.zero, - onTap: () => { - if (_onOpenMailboxActionClick != null) { - _onOpenMailboxActionClick!(_presentationMailbox) - } - }, - leading: Padding( - padding: EdgeInsets.only(left: 8), - child: SvgPicture.asset( - '${_presentationMailbox.getMailboxIcon(_imagePaths)}', - width: 28, - height: 28, - fit: BoxFit.fill)), + onTap: () => _onOpenMailboxActionClick?.call(_presentationMailbox), + leading: allSelectMode == SelectMode.ACTIVE + ? _buildSelectModeIcon() + : _buildMailboxIcon(), title: Transform( transform: Matrix4.translationValues(-10.0, 0.0, 0.0), child: Row(children: [ + if (allSelectMode == SelectMode.ACTIVE) + Transform( + transform: Matrix4.translationValues(-10.0, 0.0, 0.0), + child: _buildMailboxIcon()), Expanded(child: Text( '${_presentationMailbox.name?.name ?? ''}', maxLines: 1, @@ -96,22 +98,48 @@ class MailboxTileBuilder { child: IconButton( color: AppColor.primaryColor, icon: SvgPicture.asset(_imagePaths.icFolderArrow, color: AppColor.colorArrowUserMailbox, fit: BoxFit.fill), - onPressed: () { - if (_onOpenMailboxActionClick != null) { - _onOpenMailboxActionClick!(_presentationMailbox); - } - } + onPressed: () => _onOpenMailboxActionClick?.call(_presentationMailbox) ) ) : null ), if (!isLastElement) Padding( - padding: EdgeInsets.only(left: 45), + padding: EdgeInsets.only(left: allSelectMode == SelectMode.ACTIVE ? 50 : 45), child: Divider(color: AppColor.lineItemListColor, height: 0.5, thickness: 0.2)), ]), ) ) ); } + + Widget _buildMailboxIcon() { + return Padding( + padding: EdgeInsets.only( + left: allSelectMode == SelectMode.ACTIVE ? 4 : 8, + right: allSelectMode == SelectMode.ACTIVE ? 4 : 0), + child: SvgPicture.asset( + '${_presentationMailbox.getMailboxIcon(_imagePaths)}', + width: 28, + height: 28, + fit: BoxFit.fill + ) + ); + } + + Widget _buildSelectModeIcon() { + return Material( + borderRadius: BorderRadius.circular(10), + color: Colors.transparent, + child: IconButton( + padding: EdgeInsets.zero, + icon: SvgPicture.asset( + _presentationMailbox.selectMode == SelectMode.ACTIVE ? _imagePaths.icSelectedV2 : _imagePaths.icUnSelectedV2, + width: 20, + height: 20, + fit: BoxFit.fill), + onPressed: () => _onSelectMailboxActionClick?.call(_presentationMailbox) + ) + ); + } } \ No newline at end of file diff --git a/lib/features/mailbox_creator/presentation/mailbox_creator_bindings.dart b/lib/features/mailbox_creator/presentation/mailbox_creator_bindings.dart index 107d6020b..377d79351 100644 --- a/lib/features/mailbox_creator/presentation/mailbox_creator_bindings.dart +++ b/lib/features/mailbox_creator/presentation/mailbox_creator_bindings.dart @@ -1,15 +1,36 @@ import 'package:get/get.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart'; import 'package:tmail_ui_user/features/mailbox_creator/presentation/mailbox_creator_controller.dart'; -class MailboxCreatorBindings extends Bindings { +class MailboxCreatorBindings extends BaseBindings { @override void dependencies() { - Get.lazyPut(() => VerifyNameInteractor()); + super.dependencies(); + } + @override + void bindingsController() { Get.lazyPut(() => MailboxCreatorController( Get.find(), )); } + + @override + void bindingsDataSource() {} + + @override + void bindingsDataSourceImpl() {} + + @override + void bindingsInteractor() { + Get.lazyPut(() => VerifyNameInteractor()); + } + + @override + void bindingsRepository() {} + + @override + void bindingsRepositoryImpl() {} } \ No newline at end of file diff --git a/lib/features/session/presentation/session_bindings.dart b/lib/features/session/presentation/session_bindings.dart index 407d67431..b3d25f0a7 100644 --- a/lib/features/session/presentation/session_bindings.dart +++ b/lib/features/session/presentation/session_bindings.dart @@ -1,5 +1,6 @@ import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/caching/caching_manager.dart'; import 'package:tmail_ui_user/features/login/data/repository/credential_repository_impl.dart'; import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart'; @@ -12,20 +13,47 @@ import 'package:tmail_ui_user/features/session/domain/repository/session_reposit import 'package:tmail_ui_user/features/session/domain/usecases/get_session_interactor.dart'; import 'package:tmail_ui_user/features/session/presentation/session_controller.dart'; -class SessionBindings extends Bindings { +class SessionBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => SessionDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => SessionRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => GetSessionInteractor(Get.find())); - Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => DeleteCredentialInteractor(Get.find())); + super.dependencies(); + } + + @override + void bindingsController() { Get.lazyPut(() => SessionController( - Get.find(), - Get.find(), - Get.find())); + Get.find(), + Get.find(), + Get.find(), + )); + } + + @override + void bindingsDataSource() { + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => SessionDataSourceImpl(Get.find())); + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => GetSessionInteractor(Get.find())); + Get.lazyPut(() => DeleteCredentialInteractor(Get.find())); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => SessionRepositoryImpl(Get.find())); + Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); } } \ No newline at end of file diff --git a/lib/features/thread/presentation/thread_bindings.dart b/lib/features/thread/presentation/thread_bindings.dart index 354a57bc0..212999d4c 100644 --- a/lib/features/thread/presentation/thread_bindings.dart +++ b/lib/features/thread/presentation/thread_bindings.dart @@ -1,6 +1,7 @@ import 'package:core/core.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; +import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart'; import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart'; @@ -32,44 +33,16 @@ import 'package:tmail_ui_user/features/thread/domain/usecases/search_email_inter import 'package:tmail_ui_user/features/thread/domain/usecases/search_more_email_interactor.dart'; import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart'; -class ThreadBindings extends Bindings { +class ThreadBindings extends BaseBindings { + @override void dependencies() { - Get.lazyPut(() => ThreadDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find())); - Get.lazyPut(() => StateDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => ThreadRepositoryImpl( - { - DataSourceType.network: Get.find(), - DataSourceType.local: Get.find() - }, - Get.find() - )); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => GetEmailsInMailboxInteractor(Get.find())); + super.dependencies(); + } + + @override + void bindingsController() { Get.lazyPut(() => ScrollController()); - Get.lazyPut(() => EmailDataSourceImpl(Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => HtmlDataSourceImpl( - Get.find(), - Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => EmailRepositoryImpl( - Get.find(), - Get.find())); - Get.lazyPut(() => Get.find()); - Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); - Get.lazyPut(() => MarkAsMultipleEmailReadInteractor(Get.find())); - Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); - Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor(Get.find())); - Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find())); - Get.lazyPut(() => MarkAsStarMultipleEmailInteractor(Get.find())); - Get.lazyPut(() => RefreshChangesEmailsInMailboxInteractor(Get.find())); - Get.lazyPut(() => LoadMoreEmailsInMailboxInteractor(Get.find())); - Get.lazyPut(() => SearchEmailInteractor(Get.find())); - Get.lazyPut(() => SearchMoreEmailInteractor(Get.find())); Get.put(ThreadController( Get.find(), Get.find(), @@ -86,4 +59,60 @@ class ThreadBindings extends Bindings { Get.find(), )); } + + @override + void bindingsDataSource() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsDataSourceImpl() { + Get.lazyPut(() => ThreadDataSourceImpl(Get.find())); + Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find())); + Get.lazyPut(() => StateDataSourceImpl(Get.find())); + Get.lazyPut(() => EmailDataSourceImpl(Get.find())); + Get.lazyPut(() => HtmlDataSourceImpl( + Get.find(), + Get.find(), + )); + } + + @override + void bindingsInteractor() { + Get.lazyPut(() => GetEmailsInMailboxInteractor(Get.find())); + Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); + Get.lazyPut(() => MarkAsMultipleEmailReadInteractor(Get.find())); + Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); + Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor(Get.find())); + Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find())); + Get.lazyPut(() => MarkAsStarMultipleEmailInteractor(Get.find())); + Get.lazyPut(() => RefreshChangesEmailsInMailboxInteractor(Get.find())); + Get.lazyPut(() => LoadMoreEmailsInMailboxInteractor(Get.find())); + Get.lazyPut(() => SearchEmailInteractor(Get.find())); + Get.lazyPut(() => SearchMoreEmailInteractor(Get.find())); + } + + @override + void bindingsRepository() { + Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); + } + + @override + void bindingsRepositoryImpl() { + Get.lazyPut(() => ThreadRepositoryImpl( + { + DataSourceType.network: Get.find(), + DataSourceType.local: Get.find() + }, + Get.find() + )); + Get.lazyPut(() => EmailRepositoryImpl( + Get.find(), + Get.find() + )); + } } \ No newline at end of file diff --git a/model/lib/extensions/mailbox_extension.dart b/model/lib/extensions/mailbox_extension.dart index f8f4ac645..8b86a7078 100644 --- a/model/lib/extensions/mailbox_extension.dart +++ b/model/lib/extensions/mailbox_extension.dart @@ -6,7 +6,7 @@ extension MailboxExtension on Mailbox { bool hasRole() => role != null && role!.value.isNotEmpty; - PresentationMailbox toPresentationMailbox({SelectMode selectMode = SelectMode.INACTIVE}) { + PresentationMailbox toPresentationMailbox() { return PresentationMailbox( id!, name: name, @@ -19,7 +19,6 @@ extension MailboxExtension on Mailbox { unreadThreads: unreadThreads, myRights: myRights, isSubscribed: isSubscribed, - selectMode: selectMode ); } diff --git a/model/lib/extensions/presentation_mailbox_extension.dart b/model/lib/extensions/presentation_mailbox_extension.dart index 191d027b3..2b06e95f1 100644 --- a/model/lib/extensions/presentation_mailbox_extension.dart +++ b/model/lib/extensions/presentation_mailbox_extension.dart @@ -36,4 +36,40 @@ extension PresentationMailboxExtension on PresentationMailbox { isSubscribed: isSubscribed ); } + + PresentationMailbox toggleSelectPresentationMailbox() { + return PresentationMailbox( + id, + name: name, + parentId: parentId, + role: role, + sortOrder: sortOrder, + totalEmails: totalEmails, + unreadEmails: unreadEmails, + totalThreads: totalThreads, + unreadThreads: unreadThreads, + myRights: myRights, + isSubscribed: isSubscribed, + mailboxPath: mailboxPath, + selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE, + ); + } + + PresentationMailbox toSelectedPresentationMailbox({required SelectMode selectMode}) { + return PresentationMailbox( + id, + name: name, + parentId: parentId, + role: role, + sortOrder: sortOrder, + totalEmails: totalEmails, + unreadEmails: unreadEmails, + totalThreads: totalThreads, + unreadThreads: unreadThreads, + myRights: myRights, + isSubscribed: isSubscribed, + mailboxPath: mailboxPath, + selectMode: selectMode, + ); + } } \ No newline at end of file