TF-2764 Enable preview PDF attachment on web platform
This commit is contained in:
@@ -343,20 +343,8 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
onDragEnd: (details) {
|
||||
controller.mailboxDashBoardController.disableDraggableApp();
|
||||
},
|
||||
downloadAttachmentAction: (attachment) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
controller.downloadAttachmentForWeb(attachment);
|
||||
} else {
|
||||
controller.exportAttachment(context, attachment);
|
||||
}
|
||||
},
|
||||
// viewAttachmentAction: (attachment) {
|
||||
// if (PlatformInfo.isWeb) {
|
||||
// controller.viewAttachmentForWeb(attachment);
|
||||
// } else {
|
||||
// controller.exportAttachment(context, attachment);
|
||||
// }
|
||||
// },
|
||||
downloadAttachmentAction: (attachment) => controller.handleDownloadAttachmentAction(context, attachment),
|
||||
viewAttachmentAction: (attachment) => controller.handleViewAttachmentAction(context, attachment),
|
||||
onTapShowAllAttachmentFile: () => controller.openAttachmentList(context, controller.attachments),
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -13,14 +13,14 @@ import 'package:tmail_ui_user/features/email/presentation/extensions/attachment_
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_item_widget_style.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
|
||||
typedef OnDownloadAttachmentFileActionClick = void Function(Attachment attachment);
|
||||
typedef OnViewAttachmentFileActionClick = void Function(Attachment attachment);
|
||||
typedef OnDownloadAttachmentFileAction = void Function(Attachment attachment);
|
||||
typedef OnViewAttachmentFileAction = void Function(Attachment attachment);
|
||||
|
||||
class AttachmentItemWidget extends StatelessWidget {
|
||||
|
||||
final Attachment attachment;
|
||||
final OnDownloadAttachmentFileActionClick? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileActionClick? viewAttachmentAction;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileAction? viewAttachmentAction;
|
||||
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
+4
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_list_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_action_button_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_bottom_sheet_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_item_widget.dart';
|
||||
@@ -16,6 +17,7 @@ class AttachmentListBottomSheetBodyBuilder extends StatelessWidget {
|
||||
final ScrollController scrollController;
|
||||
final OnDownloadAllButtonAction? onDownloadAllButtonAction;
|
||||
final OnDownloadAttachmentFileAction? onDownloadAttachmentFileAction;
|
||||
final OnViewAttachmentFileAction? onViewAttachmentFileAction;
|
||||
final OnCancelButtonAction? onCancelButtonAction;
|
||||
final OnCloseButtonAction? onCloseButtonAction;
|
||||
|
||||
@@ -27,6 +29,7 @@ class AttachmentListBottomSheetBodyBuilder extends StatelessWidget {
|
||||
required this.scrollController,
|
||||
this.onDownloadAllButtonAction,
|
||||
this.onDownloadAttachmentFileAction,
|
||||
this.onViewAttachmentFileAction,
|
||||
this.onCancelButtonAction,
|
||||
this.onCloseButtonAction,
|
||||
});
|
||||
@@ -100,6 +103,7 @@ class AttachmentListBottomSheetBodyBuilder extends StatelessWidget {
|
||||
return AttachmentListItemWidget(
|
||||
attachment: attachments[index],
|
||||
downloadAttachmentAction: onDownloadAttachmentFileAction,
|
||||
viewAttachmentAction: onViewAttachmentFileAction,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
|
||||
+7
-1
@@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_list_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_bottom_sheet_body_builder.dart';
|
||||
|
||||
typedef OnDownloadAttachmentFileAction = void Function(Attachment attachment);
|
||||
typedef OnDownloadAllButtonAction = void Function();
|
||||
typedef OnCancelButtonAction = void Function();
|
||||
typedef OnCloseButtonAction = void Function();
|
||||
@@ -20,6 +20,7 @@ class AttachmentListBottomSheetBuilder {
|
||||
|
||||
OnDownloadAllButtonAction? _onDownloadAllButtonAction;
|
||||
OnDownloadAttachmentFileAction? _onDownloadAttachmentFileAction;
|
||||
OnViewAttachmentFileAction? _onViewAttachmentFileAction;
|
||||
OnCancelButtonAction? _onCancelButtonAction;
|
||||
OnCloseButtonAction? _onCloseButtonAction;
|
||||
|
||||
@@ -40,6 +41,10 @@ class AttachmentListBottomSheetBuilder {
|
||||
_onDownloadAttachmentFileAction = onDownloadAttachmentFileAction;
|
||||
}
|
||||
|
||||
void onViewAttachmentFileAction(OnViewAttachmentFileAction onViewAttachmentFileAction) {
|
||||
_onViewAttachmentFileAction = onViewAttachmentFileAction;
|
||||
}
|
||||
|
||||
void onCancelButtonAction(OnCancelButtonAction onCancelButtonAction) {
|
||||
_onCancelButtonAction = onCancelButtonAction;
|
||||
}
|
||||
@@ -62,6 +67,7 @@ class AttachmentListBottomSheetBuilder {
|
||||
scrollController: _scrollController,
|
||||
onDownloadAllButtonAction: _onDownloadAllButtonAction,
|
||||
onDownloadAttachmentFileAction: _onDownloadAttachmentFileAction,
|
||||
onViewAttachmentFileAction: _onViewAttachmentFileAction,
|
||||
onCancelButtonAction: _onCancelButtonAction,
|
||||
onCloseButtonAction: _onCloseButtonAction,
|
||||
),
|
||||
|
||||
+2
-1
@@ -3,8 +3,9 @@ import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_list_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_action_button_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_dialog_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_bottom_sheet_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_item_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
|
||||
+2
-6
@@ -3,14 +3,10 @@ import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_list_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_bottom_sheet_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_list/attachment_list_dialog_body_builder.dart';
|
||||
|
||||
typedef OnDownloadAttachmentFileAction = void Function(Attachment attachment);
|
||||
typedef OnViewAttachmentFileAction = void Function(Attachment attachment);
|
||||
typedef OnDownloadAllButtonAction = void Function();
|
||||
typedef OnCancelButtonAction = void Function();
|
||||
typedef OnCloseButtonAction = void Function();
|
||||
|
||||
class AttachmentListDialogBuilder extends StatelessWidget {
|
||||
|
||||
final ImagePaths imagePaths;
|
||||
|
||||
+2
-4
@@ -14,13 +14,11 @@ import 'package:tmail_ui_user/features/email/presentation/styles/attachment/atta
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
|
||||
typedef OnDownloadAttachmentFileActionClick = void Function(Attachment attachment);
|
||||
|
||||
class AttachmentListItemWidget extends StatelessWidget {
|
||||
|
||||
final Attachment attachment;
|
||||
final OnDownloadAttachmentFileActionClick? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileActionClick? viewAttachmentAction;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileAction? viewAttachmentAction;
|
||||
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class DraggableAttachmentItemWidget extends StatelessWidget{
|
||||
final Attachment attachment;
|
||||
final OnDragAttachmentStarted? onDragStarted;
|
||||
final OnDragAttachmentEnd? onDragEnd;
|
||||
final OnDownloadAttachmentFileActionClick? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileActionClick? viewAttachmentAction;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileAction? viewAttachmentAction;
|
||||
|
||||
const DraggableAttachmentItemWidget({
|
||||
Key? key,
|
||||
|
||||
@@ -19,8 +19,8 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
final List<Attachment> attachments;
|
||||
final OnDragAttachmentStarted? onDragStarted;
|
||||
final OnDragAttachmentEnd? onDragEnd;
|
||||
final OnDownloadAttachmentFileActionClick? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileActionClick? viewAttachmentAction;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileAction? viewAttachmentAction;
|
||||
final ResponsiveUtils responsiveUtils;
|
||||
final ImagePaths imagePaths;
|
||||
final OnTapActionCallback? onTapShowAllAttachmentFile;
|
||||
@@ -109,14 +109,13 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
onDragStarted: onDragStarted,
|
||||
onDragEnd: onDragEnd,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: PlatformInfo.isCanvasKit
|
||||
? viewAttachmentAction
|
||||
: null,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
);
|
||||
} else {
|
||||
return AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
downloadAttachmentAction: downloadAttachmentAction
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
);
|
||||
}
|
||||
}).toList(),
|
||||
|
||||
Reference in New Issue
Block a user