Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add presentation layer for GetEmailContent
- Loading branch information
Showing
32 changed files
with
1,055 additions
and
109 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
lib/features/email/presentation/constants/email_contants.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
class EmailConstants { | ||
static const HTML_TEXT = 'text/html'; | ||
static const PLAIN_TEXT = 'text/plain'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import 'package:core/presentation/utils/responsive_utils.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart'; | ||
import 'package:tmail_ui_user/features/email/data/datasource_impl/email_datasource_impl.dart'; | ||
import 'package:tmail_ui_user/features/email/data/network/email_api.dart'; | ||
import 'package:tmail_ui_user/features/email/data/repository/email_repository_impl.dart'; | ||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart'; | ||
import 'package:tmail_ui_user/features/email/domain/usecases/get_email_content_interactor.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/email_controller.dart'; | ||
|
||
class EmailBindings extends Bindings { | ||
@override | ||
void dependencies() { | ||
Get.lazyPut(() => EmailController(Get.find<ResponsiveUtils>())); | ||
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>())); | ||
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>()); | ||
Get.lazyPut(() => EmailRepositoryImpl(Get.find<EmailDataSource>())); | ||
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>()); | ||
Get.lazyPut(() => GetEmailContentInteractor(Get.find<EmailRepository>())); | ||
Get.put(EmailController(Get.find<GetEmailContentInteractor>())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
lib/features/email/presentation/extensions/email_body_part_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/model/attachment_file.dart'; | ||
|
||
extension EmailBodyPartExtension on EmailBodyPart { | ||
AttachmentFile toAttachmentFile() => AttachmentFile(partId, blobId, size, name, type); | ||
} |
39 changes: 39 additions & 0 deletions
39
lib/features/email/presentation/extensions/email_content_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart'; | ||
import 'package:model/email/email_content.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/constants/email_contants.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/model/attachment_file.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/model/message_content.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/model/text_format.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/extensions/email_body_part_extension.dart'; | ||
|
||
extension EmailContentExtension on EmailContent { | ||
|
||
List<MessageContent> getListMessageContent() { | ||
Map<PartId, TextFormat> mapHtmlBody = Map(); | ||
List<MessageContent> listMessageContent = []; | ||
|
||
htmlBody?.forEach((element) { | ||
if (element.partId != null && element.type != null) { | ||
mapHtmlBody[element.partId!] = element.type!.mimeType == EmailConstants.HTML_TEXT | ||
? TextFormat.HTML | ||
: TextFormat.PLAIN; | ||
} | ||
}); | ||
|
||
bodyValues?.forEach((key, value) { | ||
listMessageContent.add(MessageContent(mapHtmlBody[key] ?? TextFormat.PLAIN, value.value)); | ||
}); | ||
|
||
return listMessageContent; | ||
} | ||
|
||
List<AttachmentFile> getListAttachment() { | ||
if (attachments != null) { | ||
return attachments! | ||
.where((element) => element.disposition != 'inline') | ||
.map((item) => item.toAttachmentFile()) | ||
.toList(); | ||
} | ||
return []; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/features/email/presentation/extensions/presentation_email_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:intl/intl.dart'; | ||
import 'package:model/model.dart'; | ||
|
||
extension PresentationEmailExtension on PresentationEmail { | ||
|
||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress(); | ||
|
||
String getSentTime() => sentAt != null ? DateFormat('dd/MM/yyyy h:mm a', 'en_US').format(sentAt!.value) : ''; | ||
} |
Oops, something went wrong.