TF-234 Display selection multiple mailbox
This commit is contained in:
@@ -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<MailboxAPI>()));
|
||||
_bindingsUtils();
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
void _bindingsUtils() {
|
||||
Get.lazyPut(() => TreeBuilder());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => DestinationPickerController(
|
||||
Get.find<GetAllMailboxInteractor>(),
|
||||
Get.find<TreeBuilder>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<MailboxDataSource>(() => Get.find<MailboxDataSourceImpl>());
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => MailboxDataSourceImpl(Get.find<MailboxAPI>()));
|
||||
Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find<MailboxCacheManager>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
Get.lazyPut(() => MailboxRepositoryImpl(
|
||||
{
|
||||
DataSourceType.network: Get.find<MailboxDataSource>(),
|
||||
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>()
|
||||
},
|
||||
Get.find<StateDataSource>()
|
||||
));
|
||||
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => TreeBuilder());
|
||||
Get.lazyPut(() => DestinationPickerController(
|
||||
Get.find<GetAllMailboxInteractor>(),
|
||||
Get.find<TreeBuilder>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => MailboxRepositoryImpl(
|
||||
{
|
||||
DataSourceType.network: Get.find<MailboxDataSource>(),
|
||||
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>()
|
||||
},
|
||||
Get.find<StateDataSource>()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController> {
|
||||
defaultMailboxList[index],
|
||||
mailboxDisplayed: MailboxDisplayed.destinationPicker,
|
||||
isLastElement: index == defaultMailboxList.length - 1)
|
||||
..onOpenMailboxAction((mailbox) =>
|
||||
..addOnOpenMailboxAction((mailbox) =>
|
||||
controller.selectMailboxAction(mailbox.toPresentationMailboxWithMailboxPath(mailbox.name?.name ?? ''))))
|
||||
.build());
|
||||
} else {
|
||||
|
||||
@@ -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<EmailAPI>()));
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.put(EmailController(
|
||||
Get.find<GetEmailContentInteractor>(),
|
||||
Get.find<MarkAsEmailReadInteractor>(),
|
||||
Get.find<DownloadAttachmentsInteractor>(),
|
||||
Get.find<DeviceManager>(),
|
||||
Get.find<AppToast>(),
|
||||
Get.find<ExportAttachmentInteractor>(),
|
||||
Get.find<MoveToMailboxInteractor>(),
|
||||
Get.find<MarkAsStarEmailInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>());
|
||||
Get.lazyPut(() => HtmlDataSourceImpl(
|
||||
Get.find<HtmlAnalyzer>(),
|
||||
Get.find<DioClient>()));
|
||||
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>());
|
||||
Get.lazyPut(() => EmailRepositoryImpl(
|
||||
Get.find<EmailDataSource>(),
|
||||
Get.find<HtmlDataSource>()));
|
||||
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
|
||||
Get.lazyPut(() => GetEmailContentInteractor(
|
||||
Get.find<EmailRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>()));
|
||||
Get.lazyPut(() => HtmlDataSourceImpl(
|
||||
Get.find<HtmlAnalyzer>(),
|
||||
Get.find<DioClient>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetEmailContentInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut(() => DownloadAttachmentsInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>()));
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>(),
|
||||
));
|
||||
Get.lazyPut(() => ExportAttachmentInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>()));
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>(),
|
||||
));
|
||||
Get.lazyPut(() => MoveToMailboxInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find<EmailRepository>()));
|
||||
Get.put(EmailController(
|
||||
Get.find<GetEmailContentInteractor>(),
|
||||
Get.find<MarkAsEmailReadInteractor>(),
|
||||
Get.find<DownloadAttachmentsInteractor>(),
|
||||
Get.find<DeviceManager>(),
|
||||
Get.find<AppToast>(),
|
||||
Get.find<ExportAttachmentInteractor>(),
|
||||
Get.find<MoveToMailboxInteractor>(),
|
||||
Get.find<MarkAsStarEmailInteractor>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => EmailRepositoryImpl(
|
||||
Get.find<EmailDataSource>(),
|
||||
Get.find<HtmlDataSource>(),
|
||||
));
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
}
|
||||
}
|
||||
@@ -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<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut(() => GetCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
Get.lazyPut(() => CleanupDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CleanupDataSource>(() => Get.find<CleanupDataSourceImpl>());
|
||||
Get.lazyPut(() => CleanupRepositoryImpl(Get.find<CleanupDataSource>()));
|
||||
Get.lazyPut<CleanupRepository>(() => Get.find<CleanupRepositoryImpl>());
|
||||
Get.lazyPut(() => CleanupEmailCacheInteractor(Get.find<CleanupRepository>()));
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => HomeController(
|
||||
Get.find<GetCredentialInteractor>(),
|
||||
Get.find<DynamicUrlInterceptors>(),
|
||||
Get.find<AuthorizationInterceptors>(),
|
||||
Get.find<CleanupEmailCacheInteractor>()));
|
||||
Get.find<GetCredentialInteractor>(),
|
||||
Get.find<DynamicUrlInterceptors>(),
|
||||
Get.find<AuthorizationInterceptors>(),
|
||||
Get.find<CleanupEmailCacheInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<CleanupDataSource>(() => Get.find<CleanupDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => CleanupDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<SharedPreferences>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
Get.lazyPut(() => CleanupEmailCacheInteractor(Get.find<CleanupRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut<CleanupRepository>(() => Get.find<CleanupRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut(() => CleanupRepositoryImpl(Get.find<CleanupDataSource>()));
|
||||
}
|
||||
}
|
||||
@@ -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<AuthenticationDataSource>(() => Get.find<AuthenticationDataSourceImpl>());
|
||||
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
|
||||
Get.lazyPut(() => AuthenticationRepositoryImpl(Get.find<AuthenticationDataSource>()));
|
||||
Get.lazyPut<AuthenticationRepository>(() => Get.find<AuthenticationRepositoryImpl>());
|
||||
|
||||
Get.lazyPut(() => AuthenticationInteractor(Get.find<AuthenticationRepository>(), Get.find<CredentialRepository>()));
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => LoginController(
|
||||
Get.find<AuthenticationInteractor>(),
|
||||
Get.find<DynamicUrlInterceptors>(),
|
||||
Get.find<AuthorizationInterceptors>())
|
||||
);
|
||||
Get.find<AuthenticationInteractor>(),
|
||||
Get.find<DynamicUrlInterceptors>(),
|
||||
Get.find<AuthorizationInterceptors>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<AuthenticationDataSource>(() => Get.find<AuthenticationDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => AuthenticationDataSourceImpl());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => AuthenticationInteractor(
|
||||
Get.find<AuthenticationRepository>(),
|
||||
Get.find<CredentialRepository>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut<AuthenticationRepository>(() => Get.find<AuthenticationRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut(() => AuthenticationRepositoryImpl(Get.find<AuthenticationDataSource>()));
|
||||
}
|
||||
}
|
||||
@@ -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<MailboxNode> {
|
||||
@@ -15,4 +17,29 @@ extension ListMailboxNodeExtensions on List<MailboxNode> {
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<MailboxNode>? 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<MailboxNode>? 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();
|
||||
}
|
||||
}
|
||||
@@ -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<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut(() => DeleteCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
Get.lazyPut(() => MailboxDataSourceImpl(Get.find<MailboxAPI>()));
|
||||
_bindingsUtils();
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
void _bindingsUtils() {
|
||||
Get.lazyPut(() => TreeBuilder());
|
||||
Get.lazyPut(() => Uuid());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.put(MailboxController(
|
||||
Get.find<GetAllMailboxInteractor>(),
|
||||
Get.find<DeleteCredentialInteractor>(),
|
||||
Get.find<RefreshAllMailboxInteractor>(),
|
||||
Get.find<CreateNewMailboxInteractor>(),
|
||||
Get.find<SearchMailboxInteractor>(),
|
||||
Get.find<TreeBuilder>(),
|
||||
Get.find<Uuid>(),
|
||||
Get.find<AppToast>(),
|
||||
Get.find<ImagePaths>(),
|
||||
Get.find<ResponsiveUtils>(),
|
||||
Get.find<CachingManager>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<MailboxDataSource>(() => Get.find<MailboxDataSourceImpl>());
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => MailboxDataSourceImpl(Get.find<MailboxAPI>()));
|
||||
Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find<MailboxCacheManager>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => DeleteCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
Get.lazyPut(() => GetAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => RefreshAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => CreateNewMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => SearchMailboxInteractor());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>());
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut(() => MailboxRepositoryImpl(
|
||||
{
|
||||
DataSourceType.network: Get.find<MailboxDataSource>(),
|
||||
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>()
|
||||
},
|
||||
Get.find<StateDataSource>()
|
||||
Get.find<StateDataSource>(),
|
||||
));
|
||||
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>());
|
||||
Get.lazyPut(() => GetAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => RefreshAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => TreeBuilder());
|
||||
Get.lazyPut(() => CreateNewMailboxInteractor(Get.find<MailboxRepository>()));
|
||||
Get.lazyPut(() => SearchMailboxInteractor());
|
||||
Get.lazyPut(() => Uuid());
|
||||
Get.lazyPut(() => TextEditingController());
|
||||
Get.lazyPut(() => FocusNode());
|
||||
Get.put(MailboxController(
|
||||
Get.find<GetAllMailboxInteractor>(),
|
||||
Get.find<DeleteCredentialInteractor>(),
|
||||
Get.find<RefreshAllMailboxInteractor>(),
|
||||
Get.find<CreateNewMailboxInteractor>(),
|
||||
Get.find<SearchMailboxInteractor>(),
|
||||
Get.find<TreeBuilder>(),
|
||||
Get.find<Uuid>(),
|
||||
Get.find<AppToast>(),
|
||||
Get.find<ImagePaths>(),
|
||||
Get.find<ResponsiveUtils>(),
|
||||
Get.find<CachingManager>()));
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ class MailboxController extends BaseController {
|
||||
final listMailboxSearched = <PresentationMailbox>[].obs;
|
||||
final searchState = SearchState.initial().obs;
|
||||
final searchQuery = SearchQuery.initial().obs;
|
||||
final currentSelectMode = SelectMode.INACTIVE.obs;
|
||||
|
||||
MailboxTree folderMailboxTree = MailboxTree(MailboxNode.root());
|
||||
List<PresentationMailbox> allMailboxes = <PresentationMailbox>[];
|
||||
@@ -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<PresentationMailbox> defaultMailboxList, List<PresentationMailbox> 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();
|
||||
}
|
||||
|
||||
@@ -63,10 +63,14 @@ class MailboxView extends GetWidget<MailboxController> {
|
||||
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<MailboxController> {
|
||||
|
||||
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<MailboxController> {
|
||||
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<MailboxController> {
|
||||
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<MailboxController> {
|
||||
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<MailboxController> {
|
||||
listMailbox[index],
|
||||
isSearchActive: controller.isSearchActive(),
|
||||
isLastElement: index == listMailbox.length - 1)
|
||||
..onOpenMailboxAction((mailbox) => controller.selectMailbox(context, mailbox)))
|
||||
..addOnOpenMailboxAction((mailbox) => controller.openMailbox(context, mailbox)))
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
@@ -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<MailboxNode>? 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<MailboxNode>? toggleSelectNode(MailboxNode selectedMailboxMode, {MailboxNode? parent}) {
|
||||
List<MailboxNode>? _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<MailboxNode>? toSelectedNode({required SelectMode selectMode, ExpandMode? newExpandMode, MailboxNode? parent}) {
|
||||
List<MailboxNode>? _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<Object?> get props => [item, childrenItems];
|
||||
}
|
||||
|
||||
extension MailboxNodeExtension on MailboxNode {
|
||||
MailboxNode copyWith({ExpandMode? newExpandMode, List<MailboxNode>? mailboxNodes}) {
|
||||
MailboxNode copyWith({
|
||||
SelectMode? newSelectMode,
|
||||
ExpandMode? newExpandMode,
|
||||
List<MailboxNode>? 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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<VerifyNameInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => VerifyNameInteractor());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {}
|
||||
}
|
||||
@@ -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<SessionAPI>()));
|
||||
Get.lazyPut<SessionDataSource>(() => Get.find<SessionDataSourceImpl>());
|
||||
Get.lazyPut(() => SessionRepositoryImpl(Get.find<SessionDataSource>()));
|
||||
Get.lazyPut<SessionRepository>(() => Get.find<SessionRepositoryImpl>());
|
||||
Get.lazyPut(() => GetSessionInteractor(Get.find<SessionRepository>()));
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut(() => DeleteCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => SessionController(
|
||||
Get.find<GetSessionInteractor>(),
|
||||
Get.find<DeleteCredentialInteractor>(),
|
||||
Get.find<CachingManager>()));
|
||||
Get.find<GetSessionInteractor>(),
|
||||
Get.find<DeleteCredentialInteractor>(),
|
||||
Get.find<CachingManager>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<SessionDataSource>(() => Get.find<SessionDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => SessionDataSourceImpl(Get.find<SessionAPI>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetSessionInteractor(Get.find<SessionRepository>()));
|
||||
Get.lazyPut(() => DeleteCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<SessionRepository>(() => Get.find<SessionRepositoryImpl>());
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => SessionRepositoryImpl(Get.find<SessionDataSource>()));
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
}
|
||||
}
|
||||
@@ -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<ThreadAPI>()));
|
||||
Get.lazyPut<ThreadDataSource>(() => Get.find<ThreadDataSourceImpl>());
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
Get.lazyPut(() => ThreadRepositoryImpl(
|
||||
{
|
||||
DataSourceType.network: Get.find<ThreadDataSource>(),
|
||||
DataSourceType.local: Get.find<LocalThreadDataSourceImpl>()
|
||||
},
|
||||
Get.find<StateDataSource>()
|
||||
));
|
||||
Get.lazyPut<ThreadRepository>(() => Get.find<ThreadRepositoryImpl>());
|
||||
Get.lazyPut(() => GetEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
super.dependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => ScrollController());
|
||||
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>()));
|
||||
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>());
|
||||
Get.lazyPut(() => HtmlDataSourceImpl(
|
||||
Get.find<HtmlAnalyzer>(),
|
||||
Get.find<DioClient>()));
|
||||
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>());
|
||||
Get.lazyPut(() => EmailRepositoryImpl(
|
||||
Get.find<EmailDataSource>(),
|
||||
Get.find<HtmlDataSource>()));
|
||||
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
|
||||
Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsMultipleEmailReadInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MoveToMailboxInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsStarMultipleEmailInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => RefreshChangesEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => LoadMoreEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => SearchEmailInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => SearchMoreEmailInteractor(Get.find<ThreadRepository>()));
|
||||
Get.put(ThreadController(
|
||||
Get.find<ResponsiveUtils>(),
|
||||
Get.find<GetEmailsInMailboxInteractor>(),
|
||||
@@ -86,4 +59,60 @@ class ThreadBindings extends Bindings {
|
||||
Get.find<SearchMoreEmailInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<ThreadDataSource>(() => Get.find<ThreadDataSourceImpl>());
|
||||
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>());
|
||||
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => ThreadDataSourceImpl(Get.find<ThreadAPI>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
|
||||
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>()));
|
||||
Get.lazyPut(() => HtmlDataSourceImpl(
|
||||
Get.find<HtmlAnalyzer>(),
|
||||
Get.find<DioClient>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsMultipleEmailReadInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MoveToMailboxInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => MarkAsStarMultipleEmailInteractor(Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => RefreshChangesEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => LoadMoreEmailsInMailboxInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => SearchEmailInteractor(Get.find<ThreadRepository>()));
|
||||
Get.lazyPut(() => SearchMoreEmailInteractor(Get.find<ThreadRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<ThreadRepository>(() => Get.find<ThreadRepositoryImpl>());
|
||||
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => ThreadRepositoryImpl(
|
||||
{
|
||||
DataSourceType.network: Get.find<ThreadDataSource>(),
|
||||
DataSourceType.local: Get.find<LocalThreadDataSourceImpl>()
|
||||
},
|
||||
Get.find<StateDataSource>()
|
||||
));
|
||||
Get.lazyPut(() => EmailRepositoryImpl(
|
||||
Get.find<EmailDataSource>(),
|
||||
Get.find<HtmlDataSource>()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user