TF-32 Add presentation layer of download attachment for android platform

This commit is contained in:
dab246
2021-09-16 09:08:17 +07:00
committed by Dat H. Pham
parent 30dfb5aec6
commit 20f98ce541
18 changed files with 209 additions and 71 deletions
@@ -1,28 +0,0 @@
import 'package:equatable/equatable.dart';
import 'package:http_parser/http_parser.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
class AttachmentFile with EquatableMixin {
final PartId? partId;
final Id? blobId;
final UnsignedInt? size;
final String? name;
final MediaType? type;
final String? cid;
AttachmentFile(
this.partId,
this.blobId,
this.size,
this.name,
this.type,
this.cid
);
@override
List<Object?> get props => [partId, blobId, size, name, type, cid];
}
@@ -1,8 +1,6 @@
import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:tmail_ui_user/features/email/presentation/model/attachment_file.dart';
import 'package:tmail_ui_user/features/email/presentation/model/text_format.dart';
import 'package:model/model.dart';
@@ -15,16 +13,11 @@ class MessageContent with EquatableMixin {
bool hasImageInlineWithCid() => content.contains('cid:');
String getContentHasInlineAttachment(Session session, AccountId accountId, List<AttachmentFile> attachmentFiles) {
String getContentHasInlineAttachment(String baseDownloadUrl, AccountId accountId, List<Attachment> attachments) {
var contentValid = content;
attachmentFiles.forEach((attachment) {
attachments.forEach((attachment) {
if(attachment.cid != null) {
final urlDownloadImage = session.getDownloadUrl(
'${accountId.id.value}',
'${attachment.blobId?.value}',
'${attachment.name}',
'${attachment.type?.mimeType}');
final urlDownloadImage = attachment.getDownloadUrl(baseDownloadUrl, accountId);
contentValid = content.replaceAll('cid:${attachment.cid}', '$urlDownloadImage');
}
});