TF-56 Implement upload single attachment

This commit is contained in:
dab246
2021-09-17 18:04:47 +07:00
committed by Dat H. Pham
parent 6aaa8f93d3
commit 39ca213285
23 changed files with 575 additions and 12 deletions
@@ -1,4 +1,5 @@
import 'package:core/core.dart';
import 'package:core/presentation/views/dialog/downloading_file_dialog_builder.dart';
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
@@ -2,5 +2,11 @@ import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
import 'package:model/model.dart';
extension EmailBodyPartExtension on EmailBodyPart {
Attachment toAttachment() => Attachment(partId, blobId, size, name, type, cid);
Attachment toAttachment() => Attachment(
partId: partId,
blobId: blobId,
size: size,
name: name,
type: type,
cid: cid);
}
@@ -1,5 +1,4 @@
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_constants.dart';
import 'package:model/model.dart';
import 'package:tmail_ui_user/features/email/presentation/model/message_content.dart';
@@ -20,6 +20,9 @@ class AttachmentFileTileBuilder {
OnDownloadAttachmentFileActionClick? _onDownloadAttachmentFileActionClick;
OnExpandAttachmentActionClick? _onExpandAttachmentActionClick;
Widget? buttonAction;
double? heightItem;
AttachmentFileTileBuilder(
this._imagePaths,
this._attachment,
@@ -39,6 +42,14 @@ class AttachmentFileTileBuilder {
_expandMode = expandMode;
}
void addButtonAction(Widget action) {
buttonAction = action;
}
void height(double height) {
heightItem = height;
}
Widget build() {
return Theme(
data: ThemeData(
@@ -47,6 +58,8 @@ class AttachmentFileTileBuilder {
child: Container(
key: Key('attach_file_tile'),
alignment: Alignment.center,
margin: EdgeInsets.only(top:heightItem != null ? 8 : 0),
height: heightItem ?? null,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.attachmentFileBorderColor),
@@ -83,6 +96,11 @@ class AttachmentFileTileBuilder {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: AppColor.attachmentFileSizeColor)))
: null,
trailing: buttonAction != null
? Transform(
transform: Matrix4.translationValues(6.0, heightItem != null ? -6.0 : 0.0, 0.0),
child: buttonAction)
: null
),
Transform(