TF-2172 Handle add attachment from drop zone

(cherry picked from commit a9c2b8d7a187e0149ca078cd55d5ce0e09964b52)
This commit is contained in:
dab246
2023-10-02 15:27:22 +07:00
committed by Dat H. Pham
parent 92575309ec
commit 949b2ed8ed
3 changed files with 16 additions and 5 deletions
@@ -2022,4 +2022,9 @@ class ComposerController extends BaseController {
_updateStatusEmailSendButton();
}
void addAttachmentFromDropZone(Attachment attachment) {
log('ComposerController::addAttachmentFromDropZone: $attachment');
uploadController.initializeUploadAttachments([attachment]);
}
}
@@ -369,6 +369,7 @@ class ComposerView extends GetWidget<ComposerController> {
child: DropZoneWidget(
width: constraints.maxWidth,
height: constraints.maxHeight,
addAttachmentFromDropZone: controller.addAttachmentFromDropZone,
)
)
],
@@ -1,6 +1,5 @@
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -9,12 +8,20 @@ import 'package:model/email/attachment.dart';
import 'package:tmail_ui_user/features/composer/presentation/styles/web/drop_zone_widget_style.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
typedef OnAddAttachmentFromDropZone = Function(Attachment attachment);
class DropZoneWidget extends StatefulWidget {
final double? width;
final double? height;
final OnAddAttachmentFromDropZone? addAttachmentFromDropZone;
const DropZoneWidget({super.key, this.width, this.height});
const DropZoneWidget({
super.key,
this.width,
this.height,
this.addAttachmentFromDropZone
});
@override
State<DropZoneWidget> createState() => _DropZoneWidgetState();
@@ -69,9 +76,7 @@ class _DropZoneWidgetState extends State<DropZoneWidget> {
return SizedBox(width: widget.width, height: widget.height);
}
},
onAccept: (attachment) {
log('_DropZoneWidgetState::build:onAccept: $attachment');
},
onAccept: widget.addAttachmentFromDropZone,
onLeave: (attachment) {
if (_isDragging) {
setState(() => _isDragging = false);