TF-48 Create and update object for compose email
This commit is contained in:
-1
@@ -2,7 +2,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/presentation_email_address_converter.dart';
|
||||
|
||||
part 'presentation_account_response.g.dart';
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
import 'package:core/data/local/config/email_address_table.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'email_address_cache.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class EmailAddressCache with EquatableMixin {
|
||||
|
||||
@JsonKey(name: EmailAddressTable.NAME)
|
||||
final String name;
|
||||
@JsonKey(name: EmailAddressTable.EMAIL)
|
||||
final String email;
|
||||
|
||||
EmailAddressCache(this.name, this.email);
|
||||
|
||||
factory EmailAddressCache.fromJson(Map<String, dynamic> json) => _$EmailAddressCacheFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$EmailAddressCacheToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, email];
|
||||
}
|
||||
|
||||
extension EmailAddressCacheExtension on EmailAddressCache {
|
||||
EmailAddress toEmailAddress() => EmailAddress(name, email);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/email/email_address_cache.dart';
|
||||
|
||||
extension EmailAddressExtension on EmailAddress {
|
||||
|
||||
@@ -26,4 +27,6 @@ extension EmailAddressExtension on EmailAddress {
|
||||
String getEmail() => email != null ? email! : '';
|
||||
|
||||
String getName() => name != null ? name! : '';
|
||||
|
||||
EmailAddressCache toEmailAddressCache() => EmailAddressCache(name ?? '', email ?? '');
|
||||
}
|
||||
+19
@@ -1,8 +1,27 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
|
||||
Set<String> getRecipientEmailAddressList() {
|
||||
final listEmailAddress = Set<String>();
|
||||
final listToAddress = to.getListAddress() ?? [];
|
||||
final listCcAddress = cc.getListAddress() ?? [];
|
||||
final listBccAddress = bcc.getListAddress() ?? [];
|
||||
listEmailAddress.addAll(listToAddress + listCcAddress + listBccAddress);
|
||||
return listEmailAddress;
|
||||
}
|
||||
|
||||
EmailContent toEmailContent() {
|
||||
return EmailContent(
|
||||
id,
|
||||
htmlBody: htmlBody,
|
||||
attachments: attachments,
|
||||
bodyValues: bodyValues
|
||||
);
|
||||
}
|
||||
|
||||
PresentationEmail toPresentationEmail({SelectMode selectMode = SelectMode.INACTIVE}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
@@ -4,6 +4,8 @@ import 'package:model/extensions/email_address_extension.dart';
|
||||
|
||||
extension ListEmailAddressExtension on Set<EmailAddress>? {
|
||||
|
||||
List<String>? getListAddress() => this?.map((emailAddress) => emailAddress.getEmail()).toList();
|
||||
|
||||
List<String> getListEmailAddress({ExpandMode expandMode = ExpandMode.EXPAND, int limitAddress = 1, bool isFullEmailAddress = false}) {
|
||||
if (this != null) {
|
||||
if (expandMode == ExpandMode.EXPAND) {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/presentation_account_response.dart';
|
||||
|
||||
extension PresentationAccountExtension on PresentationAccount {
|
||||
PresentationAccountResponse toPresentationAccountResponse() {
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress();
|
||||
|
||||
String getEmailDateTime(String newLocale, {String? pattern}) {
|
||||
final emailTime = sentAt ?? receivedAt;
|
||||
if (emailTime != null) {
|
||||
return emailTime.formatDate(pattern: pattern ?? emailTime.value.toPattern(), locale: newLocale);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/user_profile_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/presentation_account_extension.dart';
|
||||
|
||||
extension UserProfileExtension on UserProfile {
|
||||
UserProfileResponse toUserProfileResponse() {
|
||||
@@ -5,9 +5,11 @@ import 'package:model/mailbox/select_mode.dart';
|
||||
|
||||
class PresentationMailbox with EquatableMixin {
|
||||
|
||||
static final roleInbox = Role('inbox');
|
||||
static final roleTrash = Role('trash');
|
||||
static final roleSent = Role('sent');
|
||||
static final roleTemplates = Role('templates');
|
||||
static final roleOutbox = Role('outbox');
|
||||
|
||||
final MailboxId id;
|
||||
final MailboxName? name;
|
||||
@@ -44,10 +46,6 @@ class PresentationMailbox with EquatableMixin {
|
||||
bool hasRole() => role != null && role!.value.isNotEmpty;
|
||||
|
||||
String getCountUnReadEmails() {
|
||||
if (role == roleTrash || role == roleSent || role == roleTemplates) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (unreadEmails == null || unreadEmails!.value.value <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
+16
-1
@@ -5,11 +5,15 @@ export 'account/user_name.dart';
|
||||
export 'account/password.dart';
|
||||
export 'account/account_type.dart';
|
||||
export 'account/presentation_account.dart';
|
||||
export 'account/presentation_account_response.dart';
|
||||
export 'account/attribute.dart';
|
||||
export 'account/account_request.dart';
|
||||
|
||||
// User
|
||||
export 'user/user_id.dart';
|
||||
export 'user/user_profile.dart';
|
||||
export 'user/avatar_id.dart';
|
||||
export 'user/user_profile_response.dart';
|
||||
|
||||
// Mailbox
|
||||
export 'mailbox/presentation_mailbox.dart';
|
||||
@@ -22,9 +26,20 @@ export 'email/email_content.dart';
|
||||
export 'email/prefix_email_address.dart';
|
||||
export 'email/email_action_type.dart';
|
||||
export 'email/presentation_email_address.dart';
|
||||
export 'email/email_address_cache.dart';
|
||||
|
||||
// Extensions
|
||||
export 'extensions/email_address_extension.dart';
|
||||
export 'extensions/list_email_address_extension.dart';
|
||||
export 'extensions/session_extension.dart';
|
||||
export 'extensions/utcdate_extension.dart';
|
||||
export 'extensions/utc_date_extension.dart';
|
||||
export 'extensions/email_extension.dart';
|
||||
export 'extensions/presentation_account_extension.dart';
|
||||
export 'extensions/user_profile_extension.dart';
|
||||
export 'extensions/presentation_email_extension.dart';
|
||||
|
||||
// Converter
|
||||
export 'converter/avatar_id_converter.dart';
|
||||
export 'converter/avatar_id_nullable_converter.dart';
|
||||
export 'converter/presentation_email_address_converter.dart';
|
||||
export 'converter/user_id_converter.dart';
|
||||
-5
@@ -1,11 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_nullable_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/user_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/presentation_account_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/utils/attribute.dart';
|
||||
|
||||
part 'user_profile_response.g.dart';
|
||||
|
||||
@@ -24,6 +24,9 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
core:
|
||||
path: ../core
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
@@ -46,11 +49,16 @@ dependencies:
|
||||
# uri
|
||||
uri: 1.0.0
|
||||
|
||||
# json_annotation
|
||||
json_annotation: 4.0.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
build_runner: 2.0.5
|
||||
|
||||
json_serializable: 4.1.3
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
|
||||
+11
-6
@@ -23,9 +23,9 @@ environment:
|
||||
dependency_overrides:
|
||||
# build_runner dependencies
|
||||
intl: 0.17.0
|
||||
args: 2.1.1
|
||||
dart_style: 2.0.2
|
||||
analyzer: 2.0.0
|
||||
args: 2.2.0
|
||||
dart_style: 2.0.3
|
||||
analyzer: 2.2.0
|
||||
petitparser: 4.2.0
|
||||
meta: 1.7.0
|
||||
|
||||
@@ -58,7 +58,6 @@ dependencies:
|
||||
|
||||
# Http client
|
||||
dio: 4.0.0
|
||||
json_annotation: 4.0.1
|
||||
|
||||
# equatable
|
||||
equatable: 2.0.3
|
||||
@@ -92,7 +91,10 @@ dependencies:
|
||||
flutter_widget_from_html: 0.6.2
|
||||
|
||||
# flutter_chips_input
|
||||
flutter_chips_input: 1.10.0
|
||||
flutter_chips_input:
|
||||
git:
|
||||
url: git://github.com/dab246/flutter_chips_input.git
|
||||
ref: master
|
||||
|
||||
# html_editor_enhanced
|
||||
html_editor_enhanced:
|
||||
@@ -100,12 +102,15 @@ dependencies:
|
||||
url: git://github.com/dab246/html-editor-enhanced.git
|
||||
ref: master
|
||||
|
||||
# uuid
|
||||
uuid: 3.0.4
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
build_runner: 2.0.5
|
||||
json_serializable: 4.1.3
|
||||
|
||||
mockito: 5.0.10
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
Reference in New Issue
Block a user