TF-831: add set forward to module
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
import 'package:forward/forward/forward_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
class ForwardIdNullableConverter implements JsonConverter<ForwardId?, String?> {
|
||||||
|
const ForwardIdNullableConverter();
|
||||||
|
|
||||||
|
@override
|
||||||
|
ForwardId? fromJson(String? json) => json != null ? ForwardId(id: Id(json)) : null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? toJson(ForwardId? object) => object?.id.value;
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:forward/forward/converter/forward_id_coverter.dart';
|
import 'package:forward/forward/converter/forward_id_coverter.dart';
|
||||||
|
import 'package:forward/forward/converter/forward_id_nullable_converter.dart';
|
||||||
import 'package:forward/forward/forward.dart';
|
import 'package:forward/forward/forward.dart';
|
||||||
import 'package:forward/forward/forward_id.dart';
|
import 'package:forward/forward/forward_id.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
@@ -6,13 +7,14 @@ import 'package:json_annotation/json_annotation.dart';
|
|||||||
part 'tmail_forward.g.dart';
|
part 'tmail_forward.g.dart';
|
||||||
|
|
||||||
@ForwardIdConverter()
|
@ForwardIdConverter()
|
||||||
@JsonSerializable()
|
@ForwardIdNullableConverter()
|
||||||
|
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||||
class TMailForward extends Forward {
|
class TMailForward extends Forward {
|
||||||
final ForwardId id;
|
final ForwardId? id;
|
||||||
final bool localCopy;
|
final bool localCopy;
|
||||||
final Set<String> forwards;
|
final Set<String> forwards;
|
||||||
TMailForward({
|
TMailForward({
|
||||||
required this.id,
|
this.id,
|
||||||
required this.localCopy,
|
required this.localCopy,
|
||||||
required this.forwards,
|
required this.forwards,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import 'package:contact/data/datasource/auto_complete_datasource.dart';
|
||||||
|
import 'package:contact/data/datasource_impl/tmail_contact_datasource_impl.dart';
|
||||||
|
import 'package:contact/data/network/contact_api.dart';
|
||||||
|
import 'package:core/data/model/source_type/data_source_type.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart';
|
||||||
|
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/state_datasource_impl.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/get_all_mailbox_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/autocomplete_bindings.dart';
|
||||||
|
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/rules_filter_creator_controller.dart';
|
||||||
|
|
||||||
|
class MailsForwardCreatorBindings extends BaseBindings {
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dependencies() {
|
||||||
|
_bindingsUtils();
|
||||||
|
super.dependencies();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _bindingsUtils() {
|
||||||
|
Get.lazyPut(() => AutoCompleteBindings());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void bindingsController() {
|
||||||
|
Get.lazyPut(() => RulesFilterCreatorController(
|
||||||
|
Get.find<VerifyNameInteractor>(),
|
||||||
|
Get.find<GetAllMailboxInteractor>(),
|
||||||
|
Get.find<TreeBuilder>()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void bindingsDataSource() {
|
||||||
|
Get.lazyPut<AutoCompleteDataSource>(() => Get.find<TMailContactDataSourceImpl>());
|
||||||
|
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void bindingsDataSourceImpl() {
|
||||||
|
Get.lazyPut(() => TMailContactDataSourceImpl(Get.find<ContactAPI>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void bindingsInteractor() {
|
||||||
|
Get.lazyPut(() => VerifyNameInteractor());
|
||||||
|
Get.lazyPut(() => GetAllMailboxInteractor(Get.find<MailboxRepository>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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>(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
|
import 'package:model/model.dart';
|
||||||
|
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/model/contact_suggestion_source.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_with_device_contact_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mails_forward_creator/presentation/model/mails_forward_creator_arguments.dart';
|
||||||
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
|
|
||||||
|
class RulesFilterCreatorController extends BaseController {
|
||||||
|
|
||||||
|
final inputEmailForwardController = TextEditingController();
|
||||||
|
final ContactSuggestionSource _contactSuggestionSource = ContactSuggestionSource.tMailContact;
|
||||||
|
|
||||||
|
late AccountId _accountId;
|
||||||
|
late GetAutoCompleteWithDeviceContactInteractor _getAutoCompleteWithDeviceContactInteractor;
|
||||||
|
late GetAutoCompleteInteractor _getAutoCompleteInteractor;
|
||||||
|
|
||||||
|
final listEmailForwards = <String>[].obs;
|
||||||
|
|
||||||
|
RulesFilterCreatorController(
|
||||||
|
this._getAutoCompleteWithDeviceContactInteractor,
|
||||||
|
this._getAutoCompleteInteractor,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
_getArguments();
|
||||||
|
super.onReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
inputEmailForwardController.dispose();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onDone() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onError(error) {}
|
||||||
|
|
||||||
|
void _getArguments() {
|
||||||
|
final arguments = Get.arguments;
|
||||||
|
if (arguments is MailsForwardCreatorArguments) {
|
||||||
|
_accountId = arguments.accountId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<EmailAddress>> getAutoCompleteSuggestion(
|
||||||
|
{required String word}) async {
|
||||||
|
log('ComposerController::getAutoCompleteSuggestion(): $word | $_contactSuggestionSource');
|
||||||
|
|
||||||
|
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||||
|
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||||
|
|
||||||
|
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||||
|
return await _getAutoCompleteWithDeviceContactInteractor
|
||||||
|
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||||
|
.then((value) => value.fold(
|
||||||
|
(failure) => <EmailAddress>[],
|
||||||
|
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||||
|
}
|
||||||
|
return await _getAutoCompleteInteractor
|
||||||
|
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||||
|
.then((value) => value.fold(
|
||||||
|
(failure) => <EmailAddress>[],
|
||||||
|
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _clearAll() {
|
||||||
|
inputEmailForwardController.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void closeView(BuildContext context) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
popBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
|
||||||
|
class MailsForwardCreatorArguments with EquatableMixin {
|
||||||
|
final AccountId accountId;
|
||||||
|
|
||||||
|
MailsForwardCreatorArguments(this.accountId);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [accountId];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user