TF-3478 Use tag to inject composer binding

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-02-11 21:48:52 +07:00
committed by Dat H. Pham
parent 332e2af683
commit 42b5711769
3 changed files with 238 additions and 111 deletions
@@ -72,40 +72,53 @@ import 'package:uuid/uuid.dart';
class ComposerBindings extends BaseBindings {
final String? composerId;
ComposerBindings({this.composerId});
@override
void bindingsDataSourceImpl() {
Get.lazyPut(() => AttachmentUploadDataSourceImpl(
Get.find<FileUploader>(),
Get.find<FileUploader>(tag: composerId),
Get.find<Uuid>(),
Get.find<RemoteExceptionThrower>()
));
Get.lazyPut(() => ComposerDataSourceImpl(Get.find<DownloadClient>(), Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => ContactDataSourceImpl(Get.find<CacheExceptionThrower>()));
Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => ComposerDataSourceImpl(
Get.find<DownloadClient>(),
Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => ContactDataSourceImpl(
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => MailboxDataSourceImpl(
Get.find<MailboxAPI>(),
Get.find<MailboxIsolateWorker>(),
Get.find<RemoteExceptionThrower>()));
Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => MailboxCacheDataSourceImpl(
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>()));
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailDataSourceImpl(
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(),
Get.find<CacheExceptionThrower>()));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => StateDataSourceImpl(
Get.find<StateCacheManager>(),
Get.find<IOSSharingManager>(),
Get.find<CacheExceptionThrower>()
));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => PrintFileDataSourceImpl(
Get.find<PrintUtils>(),
Get.find<ImagePaths>(),
Get.find<FileUtils>(),
Get.find<HtmlAnalyzer>(),
Get.find<CacheExceptionThrower>()
));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailHiveCacheDataSourceImpl(
Get.find<NewEmailCacheManager>(),
Get.find<OpenedEmailCacheManager>(),
@@ -114,127 +127,197 @@ class ComposerBindings extends BaseBindings {
Get.find<EmailCacheManager>(),
Get.find<SendingEmailCacheManager>(),
Get.find<FileUtils>(),
Get.find<CacheExceptionThrower>()));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailLocalStorageDataSourceImpl(
Get.find<LocalStorageManager>(),
Get.find<CacheExceptionThrower>()));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailSessionStorageDatasourceImpl(
Get.find<SessionStorageManager>(),
Get.find<CacheExceptionThrower>()));
Get.find<CacheExceptionThrower>(),
), tag: composerId);
}
@override
void bindingsDataSource() {
Get.lazyPut<AttachmentUploadDataSource>(() => Get.find<AttachmentUploadDataSourceImpl>());
Get.lazyPut<ComposerDataSource>(() => Get.find<ComposerDataSourceImpl>());
Get.lazyPut<ContactDataSource>(() => Get.find<ContactDataSourceImpl>());
Get.lazyPut<MailboxDataSource>(() => Get.find<MailboxDataSourceImpl>());
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>());
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>());
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
Get.lazyPut<PrintFileDataSource>(() => Get.find<PrintFileDataSourceImpl>());
Get.lazyPut<AttachmentUploadDataSource>(
() => Get.find<AttachmentUploadDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<ComposerDataSource>(
() => Get.find<ComposerDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<ContactDataSource>(
() => Get.find<ContactDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<MailboxDataSource>(
() => Get.find<MailboxDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<EmailDataSource>(
() => Get.find<EmailDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<HtmlDataSource>(
() => Get.find<HtmlDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<StateDataSource>(
() => Get.find<StateDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<PrintFileDataSource>(
() => Get.find<PrintFileDataSourceImpl>(tag: composerId),
tag: composerId,
);
}
@override
void bindingsRepositoryImpl() {
Get.lazyPut(() => ComposerRepositoryImpl(
Get.find<AttachmentUploadDataSource>(),
Get.find<ComposerDataSource>(),
Get.find<HtmlDataSource>(),
Get.find<AttachmentUploadDataSource>(tag: composerId),
Get.find<ComposerDataSource>(tag: composerId),
Get.find<HtmlDataSource>(tag: composerId),
Get.find<ApplicationManager>(),
Get.find<Uuid>(),
));
Get.lazyPut(() => ContactRepositoryImpl(Get.find<ContactDataSource>()));
), tag: composerId);
Get.lazyPut(
() => ContactRepositoryImpl(Get.find<ContactDataSource>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => MailboxRepositoryImpl(
{
DataSourceType.network: Get.find<MailboxDataSource>(),
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>()
DataSourceType.network: Get.find<MailboxDataSource>(tag: composerId),
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>(tag: composerId)
},
Get.find<StateDataSource>(),
));
Get.find<StateDataSource>(tag: composerId),
), tag: composerId);
Get.lazyPut(() => EmailRepositoryImpl(
{
DataSourceType.network: Get.find<EmailDataSource>(),
DataSourceType.hiveCache: Get.find<EmailHiveCacheDataSourceImpl>(),
DataSourceType.local: Get.find<EmailLocalStorageDataSourceImpl>(),
DataSourceType.session: Get.find<EmailSessionStorageDatasourceImpl>(),
DataSourceType.network: Get.find<EmailDataSource>(tag: composerId),
DataSourceType.hiveCache: Get.find<EmailHiveCacheDataSourceImpl>(tag: composerId),
DataSourceType.local: Get.find<EmailLocalStorageDataSourceImpl>(tag: composerId),
DataSourceType.session: Get.find<EmailSessionStorageDatasourceImpl>(tag: composerId),
},
Get.find<HtmlDataSource>(),
Get.find<StateDataSource>(),
Get.find<PrintFileDataSource>(),
));
Get.find<HtmlDataSource>(tag: composerId),
Get.find<StateDataSource>(tag: composerId),
Get.find<PrintFileDataSource>(tag: composerId),
), tag: composerId);
}
@override
void bindingsRepository() {
Get.lazyPut<ComposerRepository>(() => Get.find<ComposerRepositoryImpl>());
Get.lazyPut<ContactRepository>(() => Get.find<ContactRepositoryImpl>());
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>());
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
Get.lazyPut<ComposerRepository>(
() => Get.find<ComposerRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<ContactRepository>(
() => Get.find<ContactRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<MailboxRepository>(
() => Get.find<MailboxRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<EmailRepository>(
() => Get.find<EmailRepositoryImpl>(tag: composerId),
tag: composerId,
);
}
@override
void bindingsInteractor() {
Get.lazyPut(() => LocalFilePickerInteractor());
Get.lazyPut(() => LocalImagePickerInteractor());
Get.lazyPut(() => UploadAttachmentInteractor(Get.find<ComposerRepository>()));
Get.lazyPut(() => GetEmailContentInteractor(Get.find<EmailRepository>()));
Get.lazyPut(() => RemoveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>()));
Get.lazyPut(
() => LocalFilePickerInteractor(),
tag: composerId,
);
Get.lazyPut(
() => LocalImagePickerInteractor(),
tag: composerId,
);
Get.lazyPut(
() => UploadAttachmentInteractor(Get.find<ComposerRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => GetEmailContentInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => RemoveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => SaveComposerCacheOnWebInteractor(
Get.find<ComposerCacheRepository>(),
Get.find<ComposerRepository>(),
));
Get.lazyPut(() => DownloadImageAsBase64Interactor(Get.find<ComposerRepository>()));
Get.lazyPut(() => TransformHtmlEmailContentInteractor(Get.find<EmailRepository>()));
Get.find<ComposerCacheRepository>(tag: composerId),
Get.find<ComposerRepository>(tag: composerId),
), tag: composerId);
Get.lazyPut(
() => DownloadImageAsBase64Interactor(Get.find<ComposerRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => TransformHtmlEmailContentInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => CreateNewAndSendEmailInteractor(
Get.find<EmailRepository>(),
Get.find<ComposerRepository>(),
));
Get.find<EmailRepository>(tag: composerId),
Get.find<ComposerRepository>(tag: composerId),
), tag: composerId);
Get.lazyPut(() => CreateNewAndSaveEmailToDraftsInteractor(
Get.find<EmailRepository>(),
Get.find<ComposerRepository>(),
));
Get.lazyPut(() => RestoreEmailInlineImagesInteractor(
Get.find<ComposerCacheRepository>()));
Get.lazyPut(() => PrintEmailInteractor(
Get.find<EmailRepository>()));
Get.find<EmailRepository>(tag: composerId),
Get.find<ComposerRepository>(tag: composerId),
), tag: composerId);
Get.lazyPut(
() => RestoreEmailInlineImagesInteractor(Get.find<ComposerCacheRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => PrintEmailInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
IdentityInteractorsBindings().dependencies();
IdentityInteractorsBindings(composerId: composerId).dependencies();
PreferencesInteractorsBindings().dependencies();
}
@override
void bindingsController() {
if (PlatformInfo.isWeb) {
Get.lazyPut(() => RichTextWebController());
Get.lazyPut(() => RichTextWebController(), tag: composerId);
} else {
Get.lazyPut(() => RichTextMobileTabletController());
Get.lazyPut(() => RichTextMobileTabletController(), tag: composerId);
}
Get.lazyPut(() => UploadController(Get.find<UploadAttachmentInteractor>()));
Get.lazyPut(
() => UploadController(Get.find<UploadAttachmentInteractor>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => ComposerController(
Get.find<LocalFilePickerInteractor>(),
Get.find<LocalImagePickerInteractor>(),
Get.find<GetEmailContentInteractor>(),
Get.find<GetAllIdentitiesInteractor>(),
Get.find<UploadController>(),
Get.find<RemoveComposerCacheOnWebInteractor>(),
Get.find<SaveComposerCacheOnWebInteractor>(),
Get.find<DownloadImageAsBase64Interactor>(),
Get.find<TransformHtmlEmailContentInteractor>(),
Get.find<GetServerSettingInteractor>(),
Get.find<CreateNewAndSendEmailInteractor>(),
Get.find<CreateNewAndSaveEmailToDraftsInteractor>(),
Get.find<PrintEmailInteractor>(),
));
Get.find<LocalFilePickerInteractor>(tag: composerId),
Get.find<LocalImagePickerInteractor>(tag: composerId),
Get.find<GetEmailContentInteractor>(tag: composerId),
Get.find<GetAllIdentitiesInteractor>(tag: composerId),
Get.find<UploadController>(tag: composerId),
Get.find<RemoveComposerCacheOnWebInteractor>(tag: composerId),
Get.find<SaveComposerCacheOnWebInteractor>(tag: composerId),
Get.find<DownloadImageAsBase64Interactor>(tag: composerId),
Get.find<TransformHtmlEmailContentInteractor>(tag: composerId),
Get.find<GetServerSettingInteractor>(tag: composerId),
Get.find<CreateNewAndSendEmailInteractor>(tag: composerId),
Get.find<CreateNewAndSaveEmailToDraftsInteractor>(tag: composerId),
Get.find<PrintEmailInteractor>(tag: composerId),
), tag: composerId);
}
void dispose() {
if (PlatformInfo.isWeb) {
Get.delete<RichTextWebController>();
Get.delete<RichTextWebController>(tag: composerId);
} else {
Get.delete<RichTextMobileTabletController>();
Get.delete<RichTextMobileTabletController>(tag: composerId);
}
Get.delete<UploadController>();
Get.delete<ComposerController>();
Get.delete<UploadController>(tag: composerId);
Get.delete<ComposerController>(tag: composerId);
}
}
@@ -28,7 +28,12 @@ import 'package:tmail_ui_user/features/composer/presentation/widgets/web/toolbar
class ComposerView extends GetWidget<ComposerController> {
const ComposerView({Key? key}) : super(key: key);
final String? composerId;
const ComposerView({super.key, this.composerId});
@override
ComposerController get controller => Get.find<ComposerController>(tag: composerId);
@override
Widget build(BuildContext context) {
@@ -24,6 +24,10 @@ import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
class IdentityInteractorsBindings extends InteractorsBindings {
final String? composerId;
IdentityInteractorsBindings({this.composerId});
@override
void dependencies() {
_bindingsUtils();
@@ -32,12 +36,18 @@ class IdentityInteractorsBindings extends InteractorsBindings {
@override
void bindingsDataSource() {
Get.lazyPut<IdentityDataSource>(() => Get.find<IdentityDataSourceImpl>());
Get.lazyPut<IdentityCreatorDataSource>(() => Get.find<LocalIdentityCreatorDataSourceImpl>());
Get.lazyPut<IdentityDataSource>(
() => Get.find<IdentityDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<IdentityCreatorDataSource>(
() => Get.find<LocalIdentityCreatorDataSourceImpl>(tag: composerId),
tag: composerId,
);
}
void _bindingsUtils() {
Get.lazyPut(() => IdentityUtils());
Get.lazyPut(() => IdentityUtils(), tag: composerId);
}
@override
@@ -45,41 +55,70 @@ class IdentityInteractorsBindings extends InteractorsBindings {
Get.lazyPut(() => IdentityDataSourceImpl(
Get.find<HtmlTransform>(),
Get.find<IdentityAPI>(),
Get.find<RemoteExceptionThrower>()));
Get.find<RemoteExceptionThrower>()
), tag: composerId);
Get.lazyPut(() => LocalIdentityCreatorDataSourceImpl(
Get.find<CacheExceptionThrower>()
));
), tag: composerId);
}
@override
void bindingsInteractor() {
Get.lazyPut(() => GetAllIdentitiesInteractor(
Get.find<IdentityRepository>(),
Get.find<IdentityUtils>()));
Get.lazyPut(() => CreateNewIdentityInteractor(Get.find<IdentityRepository>()));
Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>(tag: composerId)
), tag: composerId);
Get.lazyPut(
() => CreateNewIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => CreateNewDefaultIdentityInteractor(
Get.find<IdentityRepository>(),
Get.find<IdentityUtils>()));
Get.lazyPut(() => DeleteIdentityInteractor(Get.find<IdentityRepository>()));
Get.lazyPut(() => EditIdentityInteractor(Get.find<IdentityRepository>()));
Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>(tag: composerId)
), tag: composerId);
Get.lazyPut(
() => DeleteIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => EditIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => EditDefaultIdentityInteractor(
Get.find<IdentityRepository>(),
Get.find<IdentityUtils>()));
Get.lazyPut(() => TransformHtmlSignatureInteractor(Get.find<IdentityRepository>()));
Get.lazyPut(() => SaveIdentityCacheOnWebInteractor(Get.find<IdentityCreatorRepository>()));
Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>(tag: composerId)
), tag: composerId);
Get.lazyPut(
() => TransformHtmlSignatureInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => SaveIdentityCacheOnWebInteractor(Get.find<IdentityCreatorRepository>(tag: composerId)),
tag: composerId,
);
}
@override
void bindingsRepository() {
Get.lazyPut<IdentityRepository>(() => Get.find<IdentityRepositoryImpl>());
Get.lazyPut<IdentityCreatorRepository>(() => Get.find<IdentityCreatorRepositoryImpl>());
Get.lazyPut<IdentityRepository>(
() => Get.find<IdentityRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<IdentityCreatorRepository>(
() => Get.find<IdentityCreatorRepositoryImpl>(tag: composerId),
tag: composerId,
);
}
@override
void bindingsRepositoryImpl() {
Get.lazyPut(() => IdentityRepositoryImpl(Get.find<IdentityDataSource>()));
Get.lazyPut(() => IdentityCreatorRepositoryImpl(
Get.find<IdentityCreatorDataSource>()
));
Get.lazyPut(
() => IdentityRepositoryImpl(Get.find<IdentityDataSource>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => IdentityCreatorRepositoryImpl(Get.find<IdentityCreatorDataSource>(tag: composerId)),
tag: composerId,
);
}
}