TF-2520 Use mime type png to display logo in print page
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
+103
-95
@@ -1,10 +1,100 @@
|
||||
library core;
|
||||
|
||||
export 'data/constants/constant.dart';
|
||||
// Extensions
|
||||
export 'presentation/extensions/color_extension.dart';
|
||||
export 'presentation/extensions/url_extension.dart';
|
||||
export 'presentation/extensions/uri_extension.dart';
|
||||
export 'presentation/extensions/capitalize_extension.dart';
|
||||
export 'presentation/extensions/list_extensions.dart';
|
||||
export 'domain/extensions/datetime_extension.dart';
|
||||
export 'presentation/extensions/html_extension.dart';
|
||||
export 'presentation/extensions/compare_string_extension.dart';
|
||||
export 'presentation/extensions/compare_list_extensions.dart';
|
||||
export 'presentation/extensions/string_extension.dart';
|
||||
export 'presentation/extensions/tap_down_details_extension.dart';
|
||||
export 'domain/extensions/media_type_extension.dart';
|
||||
export 'presentation/extensions/map_extensions.dart';
|
||||
|
||||
// Exceptions
|
||||
export 'domain/exceptions/download_file_exception.dart';
|
||||
export 'data/extensions/options_extensions.dart';
|
||||
export 'data/model/query/query_parameter.dart';
|
||||
// Model
|
||||
export 'data/model/source_type/data_source_type.dart';
|
||||
export 'domain/exceptions/web_session_exception.dart';
|
||||
|
||||
// Utils
|
||||
export 'presentation/utils/theme_utils.dart';
|
||||
export 'presentation/utils/responsive_utils.dart';
|
||||
export 'presentation/utils/keyboard_utils.dart';
|
||||
export 'presentation/utils/icon_utils.dart';
|
||||
export 'presentation/utils/style_utils.dart';
|
||||
export 'presentation/utils/app_toast.dart';
|
||||
export 'presentation/utils/html_transformer/html_transform.dart';
|
||||
export 'presentation/utils/html_transformer/transform_configuration.dart';
|
||||
export 'presentation/utils/html_transformer/dom/add_tooltip_link_transformers.dart';
|
||||
export 'data/utils/device_manager.dart';
|
||||
export 'utils/app_logger.dart';
|
||||
export 'utils/benchmark.dart';
|
||||
export 'utils/fps_manager.dart';
|
||||
export 'utils/build_utils.dart';
|
||||
export 'utils/string_convert.dart';
|
||||
export 'utils/config/app_config_loader.dart';
|
||||
export 'utils/config/app_config_parser.dart';
|
||||
export 'utils/config/errors.dart';
|
||||
export 'data/utils/compress_file_utils.dart';
|
||||
export 'utils/platform_info.dart';
|
||||
export 'utils/file_utils.dart';
|
||||
export 'utils/option_param_mixin.dart';
|
||||
export 'utils/print_utils.dart';
|
||||
|
||||
// Views
|
||||
export 'presentation/views/text/slogan_builder.dart';
|
||||
export 'presentation/views/text/text_field_builder.dart';
|
||||
export 'presentation/views/text/text_form_field_builder.dart';
|
||||
export 'presentation/views/text/input_decoration_builder.dart';
|
||||
export 'presentation/views/text/rich_text_builder.dart';
|
||||
export 'presentation/views/text/text_overflow_builder.dart';
|
||||
export 'presentation/views/responsive/responsive_widget.dart';
|
||||
export 'presentation/views/list/tree_view.dart';
|
||||
export 'presentation/views/button/icon_button_web.dart';
|
||||
export 'presentation/views/button/tmail_button_widget.dart';
|
||||
export 'presentation/views/image/avatar_builder.dart';
|
||||
export 'presentation/views/list/sliver_grid_delegate_fixed_height.dart';
|
||||
export 'presentation/views/image/icon_builder.dart';
|
||||
export 'presentation/views/context_menu/context_menu_action_builder.dart';
|
||||
export 'presentation/views/context_menu/context_menu_builder.dart';
|
||||
export 'presentation/views/context_menu/context_menu_header_builder.dart';
|
||||
export 'presentation/views/context_menu/simple_context_menu_action_builder.dart';
|
||||
export 'presentation/views/dialog/downloading_file_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/edit_text_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/color_picker_dialog_builder.dart';
|
||||
export 'presentation/views/html_viewer/html_content_viewer_widget.dart';
|
||||
export 'presentation/views/html_viewer/html_content_viewer_on_web_widget.dart';
|
||||
export 'presentation/views/floating_button/scrolling_floating_button_animated.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_action_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_no_icon_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_builder.dart';
|
||||
export 'presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
||||
export 'presentation/views/modal_sheets/edit_text_modal_sheet_builder.dart';
|
||||
export 'presentation/views/search/search_bar_view.dart';
|
||||
export 'presentation/views/popup_menu/popup_menu_item_widget.dart';
|
||||
export 'presentation/views/quick_search/quick_search_input_form.dart';
|
||||
export 'presentation/views/toast/toast_position.dart';
|
||||
export 'presentation/views/toast/tmail_toast.dart';
|
||||
export 'presentation/views/bottom_popup/full_screen_action_sheet_builder.dart';
|
||||
export 'presentation/views/checkbox/labeled_checkbox.dart';
|
||||
export 'presentation/views/container/tmail_container_widget.dart';
|
||||
export 'presentation/views/clipper/side_arrow_clipper.dart';
|
||||
export 'presentation/views/avatar/gradient_circle_avatar_icon.dart';
|
||||
export 'presentation/views/loading/cupertino_loading_widget.dart';
|
||||
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
export 'presentation/resources/image_paths.dart';
|
||||
|
||||
// Constants
|
||||
export 'presentation/constants/constants_ui.dart';
|
||||
export 'data/constants/constant.dart';
|
||||
|
||||
// Network
|
||||
export 'data/network/config/dynamic_url_interceptors.dart';
|
||||
export 'data/network/config/service_path.dart';
|
||||
@@ -12,96 +102,14 @@ export 'data/network/dio_client.dart';
|
||||
export 'data/network/download/download_client.dart';
|
||||
export 'data/network/download/download_manager.dart';
|
||||
export 'data/network/download/downloaded_response.dart';
|
||||
export 'data/utils/compress_file_utils.dart';
|
||||
export 'data/utils/device_manager.dart';
|
||||
// Exceptions
|
||||
export 'domain/exceptions/download_file_exception.dart';
|
||||
export 'domain/exceptions/web_session_exception.dart';
|
||||
export 'domain/extensions/datetime_extension.dart';
|
||||
export 'domain/extensions/media_type_extension.dart';
|
||||
// Action
|
||||
export 'presentation/action/action_callback_define.dart';
|
||||
// Constants
|
||||
export 'presentation/constants/constants_ui.dart';
|
||||
export 'presentation/extensions/capitalize_extension.dart';
|
||||
// Extensions
|
||||
export 'presentation/extensions/color_extension.dart';
|
||||
export 'presentation/extensions/compare_list_extensions.dart';
|
||||
export 'presentation/extensions/compare_string_extension.dart';
|
||||
export 'presentation/extensions/html_extension.dart';
|
||||
export 'presentation/extensions/list_extensions.dart';
|
||||
export 'presentation/extensions/map_extensions.dart';
|
||||
export 'presentation/extensions/string_extension.dart';
|
||||
export 'presentation/extensions/tap_down_details_extension.dart';
|
||||
export 'presentation/extensions/uri_extension.dart';
|
||||
export 'presentation/extensions/url_extension.dart';
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
export 'presentation/resources/image_paths.dart';
|
||||
export 'presentation/state/failure.dart';
|
||||
|
||||
// State
|
||||
export 'presentation/state/success.dart';
|
||||
export 'presentation/utils/app_toast.dart';
|
||||
export 'presentation/utils/html_transformer/dom/add_tooltip_link_transformers.dart';
|
||||
export 'presentation/utils/html_transformer/html_transform.dart';
|
||||
export 'presentation/utils/html_transformer/transform_configuration.dart';
|
||||
export 'presentation/utils/icon_utils.dart';
|
||||
export 'presentation/utils/keyboard_utils.dart';
|
||||
export 'presentation/utils/responsive_utils.dart';
|
||||
export 'presentation/utils/style_utils.dart';
|
||||
// Utils
|
||||
export 'presentation/utils/theme_utils.dart';
|
||||
export 'presentation/views/avatar/gradient_circle_avatar_icon.dart';
|
||||
export 'presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_action_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_builder.dart';
|
||||
export 'presentation/views/bottom_popup/cupertino_action_sheet_no_icon_builder.dart';
|
||||
export 'presentation/views/bottom_popup/full_screen_action_sheet_builder.dart';
|
||||
export 'presentation/views/button/icon_button_web.dart';
|
||||
export 'presentation/views/button/tmail_button_widget.dart';
|
||||
export 'presentation/views/checkbox/labeled_checkbox.dart';
|
||||
export 'presentation/views/clipper/side_arrow_clipper.dart';
|
||||
export 'presentation/views/container/tmail_container_widget.dart';
|
||||
export 'presentation/views/context_menu/context_menu_action_builder.dart';
|
||||
export 'presentation/views/context_menu/context_menu_builder.dart';
|
||||
export 'presentation/views/context_menu/context_menu_header_builder.dart';
|
||||
export 'presentation/views/context_menu/simple_context_menu_action_builder.dart';
|
||||
export 'presentation/views/dialog/color_picker_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/downloading_file_dialog_builder.dart';
|
||||
export 'presentation/views/dialog/edit_text_dialog_builder.dart';
|
||||
export 'presentation/views/floating_button/scrolling_floating_button_animated.dart';
|
||||
export 'presentation/views/html_viewer/html_content_viewer_on_web_widget.dart';
|
||||
export 'presentation/views/html_viewer/html_content_viewer_widget.dart';
|
||||
export 'presentation/views/image/avatar_builder.dart';
|
||||
export 'presentation/views/image/icon_builder.dart';
|
||||
export 'presentation/views/list/sliver_grid_delegate_fixed_height.dart';
|
||||
export 'presentation/views/list/tree_view.dart';
|
||||
export 'presentation/views/loading/cupertino_loading_widget.dart';
|
||||
export 'presentation/views/modal_sheets/edit_text_modal_sheet_builder.dart';
|
||||
export 'presentation/views/popup_menu/popup_menu_item_widget.dart';
|
||||
export 'presentation/views/quick_search/quick_search_input_form.dart';
|
||||
export 'presentation/views/responsive/responsive_widget.dart';
|
||||
export 'presentation/views/search/search_bar_view.dart';
|
||||
export 'presentation/views/text/input_decoration_builder.dart';
|
||||
export 'presentation/views/text/rich_text_builder.dart';
|
||||
// Views
|
||||
export 'presentation/views/text/slogan_builder.dart';
|
||||
export 'presentation/views/text/text_field_builder.dart';
|
||||
export 'presentation/views/text/text_form_field_builder.dart';
|
||||
export 'presentation/views/text/text_overflow_builder.dart';
|
||||
export 'presentation/views/toast/tmail_toast.dart';
|
||||
export 'presentation/views/toast/toast_position.dart';
|
||||
export 'utils/app_logger.dart';
|
||||
export 'utils/benchmark.dart';
|
||||
export 'utils/build_utils.dart';
|
||||
export 'utils/config/app_config_loader.dart';
|
||||
export 'utils/config/app_config_parser.dart';
|
||||
export 'utils/config/errors.dart';
|
||||
export 'utils/file_utils.dart';
|
||||
export 'utils/fps_manager.dart';
|
||||
export 'utils/html/html_template.dart';
|
||||
export 'utils/option_param_mixin.dart';
|
||||
export 'utils/platform_info.dart';
|
||||
export 'utils/print_utils.dart';
|
||||
export 'utils/string_convert.dart';
|
||||
export 'presentation/state/failure.dart';
|
||||
|
||||
// Model
|
||||
export 'data/model/source_type/data_source_type.dart';
|
||||
export 'data/model/query/query_parameter.dart';
|
||||
|
||||
// Action
|
||||
export 'presentation/action/action_callback_define.dart';
|
||||
@@ -1,4 +1,5 @@
|
||||
class AssetsPaths {
|
||||
static const images = 'assets/images/';
|
||||
static const icons = 'assets/icons/';
|
||||
static const configurationImages = 'configurations/icons/';
|
||||
}
|
||||
@@ -210,11 +210,16 @@ class ImagePaths {
|
||||
String get icUnsubscribe => _getImagePath('ic_unsubscribe.svg');
|
||||
String get icRecoverDeletedMessages => _getImagePath('ic_recover_deleted_messages.svg');
|
||||
String get icPrinter => _getImagePath('ic_printer.svg');
|
||||
String get icLogoApp => _getIconPath('logo_app.png');
|
||||
|
||||
String _getImagePath(String imageName) {
|
||||
return AssetsPaths.images + imageName;
|
||||
}
|
||||
|
||||
String _getIconPath(String iconName) {
|
||||
return AssetsPaths.icons + iconName;
|
||||
}
|
||||
|
||||
String getConfigurationImagePath(String imageName) {
|
||||
return AssetsPaths.configurationImages + imageName;
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'package:core/data/network/dio_client.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/base/dom_transformer.dart';
|
||||
import 'package:html/dom.dart';
|
||||
|
||||
class RemoveTagHiddenTransformer extends DomTransformer {
|
||||
const RemoveTagHiddenTransformer();
|
||||
|
||||
@override
|
||||
Future<void> process({
|
||||
required Document document,
|
||||
required DioClient dioClient,
|
||||
Map<String, String>? mapUrlDownloadCID,
|
||||
}) async {
|
||||
final elements = document.querySelectorAll('[style]');
|
||||
await Future.wait(elements.map((element) async {
|
||||
var exStyle = element.attributes['style'];
|
||||
if (exStyle?.contains('display: none') == true || exStyle?.contains('display:none') == true) {
|
||||
element.remove();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import 'package:core/presentation/utils/html_transformer/dom/blockquoted_transfo
|
||||
import 'package:core/presentation/utils/html_transformer/dom/image_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/remove_collapsed_signature_button_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/remove_lazy_loading_for_background_image_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/remove_tag_hidden_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/remove_tooltip_link_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/script_transformers.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/dom/sigature_transformers.dart';
|
||||
@@ -67,7 +66,6 @@ class TransformConfiguration {
|
||||
const RemoveTooltipLinkTransformer(),
|
||||
const RemoveLazyLoadingForBackgroundImageTransformer(),
|
||||
const RemoveCollapsedSignatureButtonTransformer(),
|
||||
const RemoveTagHiddenTransformer(),
|
||||
]);
|
||||
|
||||
/// Provides easy access to a standard configuration that does not block external images.
|
||||
|
||||
+101
-43
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:core/data/model/print_attachment.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:core/utils/html/html_interaction.dart';
|
||||
import 'package:core/utils/html/html_template.dart';
|
||||
@@ -16,18 +17,18 @@ class PrintUtils {
|
||||
|
||||
PrintUtils(this._imagePaths, this._fileUtils);
|
||||
|
||||
Future<Element> _createUserInformationElement({
|
||||
Future<Element?> _createUserInformationElement({
|
||||
required String appName,
|
||||
required String userName,
|
||||
}) async {
|
||||
final logoBase64Data = await _fileUtils.convertImageAssetToBase64(_imagePaths.icTMailLogo);
|
||||
try {
|
||||
final logoBase64Data = await _fileUtils.convertImageAssetToBase64(_imagePaths.icLogoApp);
|
||||
|
||||
return Element.html('''
|
||||
return Element.html('''
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tbody>
|
||||
<tr height="14px">
|
||||
<td width="40"><img src="${HtmlUtils.generateSVGImageData(logoBase64Data)}" width="40" height="40" class="logo" /></td>
|
||||
<td style="padding-left: 10px;font-size: 20px;color: #000;"><b>$appName</b></td>
|
||||
<td width="200"><img src="${HtmlUtils.convertBase64ToImageResourceData(base64Data: logoBase64Data, mimeType: 'image/png')}" width="200" height="40" class="logo" /></td>
|
||||
<td align="right" style="color: #777;">
|
||||
<b>$userName</b>
|
||||
</td>
|
||||
@@ -35,12 +36,24 @@ class PrintUtils {
|
||||
</tbody>
|
||||
</table>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createUserInformationElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Element get dividerElement => Element.html('<hr />');
|
||||
Element? get dividerElement {
|
||||
try {
|
||||
return Element.html('<hr />');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::dividerElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Element _createSubjectElement(String subject) {
|
||||
return Element.html('''
|
||||
Element? _createSubjectElement(String subject) {
|
||||
try {
|
||||
return Element.html('''
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
@@ -51,14 +64,19 @@ class PrintUtils {
|
||||
</tbody>
|
||||
</table>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createSubjectElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Element _createSenderElement({
|
||||
Element? _createSenderElement({
|
||||
required String senderName,
|
||||
required String senderEmailAddress,
|
||||
required String dateTime,
|
||||
}) {
|
||||
return Element.html('''
|
||||
try {
|
||||
return Element.html('''
|
||||
<tr>
|
||||
<td>
|
||||
<font size="-1"><b>$senderName </b><$senderEmailAddress></font>
|
||||
@@ -66,15 +84,24 @@ class PrintUtils {
|
||||
<td align="right"><font size="-1">$dateTime</font></td>
|
||||
</tr>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createSenderElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _createRecipientHtmlTag(String prefix, String emailAddress) {
|
||||
Element element = Element.html('<div class="${prefix.toLowerCase()}"></div>');
|
||||
element.text = '$prefix: $emailAddress';
|
||||
return element.outerHtml;
|
||||
String? _createRecipientHtmlTag(String prefix, String emailAddress) {
|
||||
try {
|
||||
Element element = Element.html('<div class="${prefix.toLowerCase()}"></div>');
|
||||
element.text = '$prefix: $emailAddress';
|
||||
return element.outerHtml;
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createRecipientHtmlTag: Exception = $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Element _createRecipientsElement({
|
||||
Element? _createRecipientsElement({
|
||||
required String toPrefix,
|
||||
required String ccPrefix,
|
||||
required String bccPrefix,
|
||||
@@ -84,7 +111,8 @@ class PrintUtils {
|
||||
String? bccAddress,
|
||||
String? replyToAddress,
|
||||
}) {
|
||||
return Element.html('''
|
||||
try {
|
||||
return Element.html('''
|
||||
<tr>
|
||||
<td colspan="2" style="padding-bottom: 4px;" class="recipient">
|
||||
${replyToAddress?.isNotEmpty == true ? _createRecipientHtmlTag(replyToPrefix, replyToAddress!) : ''}
|
||||
@@ -94,10 +122,15 @@ class PrintUtils {
|
||||
</td>
|
||||
</tr>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createRecipientsElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Element _createEmailContentElement(String emailContent) {
|
||||
return Element.html('''
|
||||
Element? _createEmailContentElement(String emailContent) {
|
||||
try {
|
||||
return Element.html('''
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<table width="100%" cellpadding="12" cellspacing="0" border="0">
|
||||
@@ -110,6 +143,10 @@ class PrintUtils {
|
||||
</td>
|
||||
</tr>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createEmailContentElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _createTitleAttachmentHtmlTag({
|
||||
@@ -144,11 +181,12 @@ class PrintUtils {
|
||||
''';
|
||||
}
|
||||
|
||||
Element _createAttachmentsElement({
|
||||
Element? _createAttachmentsElement({
|
||||
required String titleAttachment,
|
||||
required List<PrintAttachment> listAttachment
|
||||
}) {
|
||||
return Element.html('''
|
||||
try {
|
||||
return Element.html('''
|
||||
<table class="attachments" cellspacing="0" cellpadding="5" border="0">
|
||||
<tbody>
|
||||
${_createTitleAttachmentHtmlTag(countAttachments: listAttachment.length, titleAttachment: titleAttachment)}
|
||||
@@ -156,6 +194,10 @@ class PrintUtils {
|
||||
</tbody>
|
||||
</table>
|
||||
''');
|
||||
} catch (e) {
|
||||
logError('PrintUtils::_createAttachmentsElement: Exception = $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> printEmail({
|
||||
@@ -185,18 +227,18 @@ class PrintUtils {
|
||||
Element messageElement = Element.html('<table width="100%" cellpadding="0" cellspacing="0" border="0" class="message"></table>');
|
||||
Element messageBodyElement = Element.html('<tbody></tbody>');
|
||||
|
||||
Element userInfoElement = await _createUserInformationElement(
|
||||
Element? userInfoElement = await _createUserInformationElement(
|
||||
appName: appName,
|
||||
userName: userName);
|
||||
|
||||
Element subjectElement = _createSubjectElement(subject);
|
||||
Element? subjectElement = _createSubjectElement(subject);
|
||||
|
||||
Element senderElement = _createSenderElement(
|
||||
Element? senderElement = _createSenderElement(
|
||||
senderName: senderName,
|
||||
senderEmailAddress: senderEmailAddress,
|
||||
dateTime: dateTime);
|
||||
|
||||
Element recipientsElement = _createRecipientsElement(
|
||||
Element? recipientsElement = _createRecipientsElement(
|
||||
toPrefix: toPrefix,
|
||||
ccPrefix: ccPrefix,
|
||||
bccPrefix: bccPrefix,
|
||||
@@ -207,40 +249,56 @@ class PrintUtils {
|
||||
replyToAddress: replyToAddress,
|
||||
);
|
||||
|
||||
Element emailContentElement = _createEmailContentElement(emailContent);
|
||||
|
||||
bodyContainerElement.append(userInfoElement);
|
||||
bodyContainerElement.append(dividerElement);
|
||||
|
||||
mainContentElement.append(subjectElement);
|
||||
mainContentElement.append(dividerElement);
|
||||
|
||||
messageBodyElement.append(senderElement);
|
||||
messageBodyElement.append(recipientsElement);
|
||||
messageBodyElement.append(emailContentElement);
|
||||
Element? emailContentElement = _createEmailContentElement(emailContent);
|
||||
|
||||
if (senderElement != null) {
|
||||
messageBodyElement.append(senderElement);
|
||||
}
|
||||
if (recipientsElement != null) {
|
||||
messageBodyElement.append(recipientsElement);
|
||||
}
|
||||
if (emailContentElement != null) {
|
||||
messageBodyElement.append(emailContentElement);
|
||||
}
|
||||
messageElement.append(messageBodyElement);
|
||||
|
||||
if (subjectElement != null) {
|
||||
mainContentElement.append(subjectElement);
|
||||
}
|
||||
if (dividerElement != null) {
|
||||
mainContentElement.append(dividerElement!);
|
||||
}
|
||||
mainContentElement.append(messageElement);
|
||||
|
||||
if (listAttachment?.isNotEmpty == true) {
|
||||
Element attachmentsElement = _createAttachmentsElement(
|
||||
titleAttachment: titleAttachment,
|
||||
listAttachment: listAttachment!);
|
||||
mainContentElement.append(dividerElement);
|
||||
mainContentElement.append(attachmentsElement);
|
||||
final attachmentsElement = _createAttachmentsElement(
|
||||
titleAttachment: titleAttachment,
|
||||
listAttachment: listAttachment!);
|
||||
|
||||
if (dividerElement != null) {
|
||||
mainContentElement.append(dividerElement!);
|
||||
}
|
||||
if (attachmentsElement != null) {
|
||||
mainContentElement.append(attachmentsElement);
|
||||
}
|
||||
}
|
||||
|
||||
if (userInfoElement != null) {
|
||||
bodyContainerElement.append(userInfoElement);
|
||||
}
|
||||
if (dividerElement != null) {
|
||||
bodyContainerElement.append(dividerElement!);
|
||||
}
|
||||
bodyContainerElement.append(mainContentElement);
|
||||
|
||||
Element styleElement = Element.html(HtmlTemplate.printDocumentCssStyle);
|
||||
document.head?.append(styleElement);
|
||||
|
||||
document.body?.append(bodyContainerElement);
|
||||
|
||||
Element scriptElement = Element.html(HtmlInteraction.scriptHandleInvokePrinterOnBrowser);
|
||||
document.body?.append(scriptElement);
|
||||
|
||||
Element styleElement = Element.html(HtmlTemplate.printDocumentCssStyle);
|
||||
document.head?.append(styleElement);
|
||||
|
||||
final htmlDocument = document.outerHtml;
|
||||
|
||||
HtmlUtils.openNewTabHtmlDocument(htmlDocument);
|
||||
|
||||
@@ -44,6 +44,7 @@ import 'package:tmail_ui_user/features/email/domain/state/mark_as_email_read_sta
|
||||
import 'package:tmail_ui_user/features/email/domain/state/mark_as_email_star_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/move_to_mailbox_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/print_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/send_receipt_to_sender_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/unsubscribe_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/view_attachment_for_web_state.dart';
|
||||
@@ -206,6 +207,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
emailLoadedViewState.value = Right<Failure, Success>(success);
|
||||
} else if (success is ParseCalendarEventSuccess) {
|
||||
_handleParseCalendarEventSuccess(success);
|
||||
} else if (success is PrintEmailLoading) {
|
||||
_showMessageWhenStartingEmailPrinting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,6 +229,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
_handleParseCalendarEventFailure(failure);
|
||||
} else if (failure is GetEmailContentFailure) {
|
||||
emailLoadedViewState.value = Left<Failure, Success>(failure);
|
||||
} else if (failure is PrintEmailFailure) {
|
||||
_showMessageWhenEmailPrintingFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1587,9 +1592,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
}
|
||||
|
||||
void _printEmail(BuildContext context, PresentationEmail email) {
|
||||
if (email.id != _currentEmailLoaded?.emailCurrent?.id) {
|
||||
log('SingleEmailController::_printEmail: EMAIL ${email.id?.asString} NOT LOADED');
|
||||
}
|
||||
final emailPrint = EmailPrint(
|
||||
appName: AppLocalizations.of(context).app_name,
|
||||
userName: mailboxDashBoardController.userProfile.value?.email ?? '',
|
||||
@@ -1609,4 +1611,22 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
);
|
||||
consumeState(_printEmailInteractor.execute(emailPrint));
|
||||
}
|
||||
|
||||
void _showMessageWhenStartingEmailPrinting() {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
appToast.showToastMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).printingInProgress,
|
||||
leadingSVGIconColor: AppColor.primaryColor,
|
||||
leadingSVGIcon: imagePaths.icPrinter);
|
||||
}
|
||||
}
|
||||
|
||||
void _showMessageWhenEmailPrintingFailed() {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).printingFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"@@last_modified": "2024-02-28T17:05:44.385016",
|
||||
"@@last_modified": "2024-03-08T11:39:58.409792",
|
||||
"initializing_data": "Initializing data...",
|
||||
"@initializing_data": {
|
||||
"type": "text",
|
||||
@@ -3665,5 +3665,17 @@
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"printingInProgress": "Printing in progress",
|
||||
"@printingInProgress": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"printingFailed": "Printing failed",
|
||||
"@printingFailed": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
@@ -3819,4 +3819,18 @@ class AppLocalizations {
|
||||
name: 'replyToEmailAddressPrefix',
|
||||
);
|
||||
}
|
||||
|
||||
String get printingInProgress {
|
||||
return Intl.message(
|
||||
'Printing in progress',
|
||||
name: 'printingInProgress'
|
||||
);
|
||||
}
|
||||
|
||||
String get printingFailed {
|
||||
return Intl.message(
|
||||
'Printing failed',
|
||||
name: 'printingFailed'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user