TF-2713 Small evolution for printing
This commit is contained in:
@@ -48,13 +48,10 @@ extension DateTimeNullableExtension on DateTime? {
|
||||
}
|
||||
|
||||
String toPatternForEmailView() {
|
||||
if (this != null) {
|
||||
if (this!.isThisYear()) {
|
||||
return 'dd.MM, HH:mm';
|
||||
} else {
|
||||
return 'dd/MM/yyyy';
|
||||
}
|
||||
if (this?.isThisYear() == true) {
|
||||
return 'dd.MM, HH:mm';
|
||||
} else {
|
||||
return 'dd.MM.yyyy, HH:mm';
|
||||
}
|
||||
return 'dd/MM/yyyy';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ class PrintUtils {
|
||||
}
|
||||
|
||||
Element? _createSenderElement({
|
||||
required String fromPrefix,
|
||||
required String senderName,
|
||||
required String senderEmailAddress,
|
||||
required String dateTime,
|
||||
@@ -79,7 +80,7 @@ class PrintUtils {
|
||||
return Element.html('''
|
||||
<tr>
|
||||
<td>
|
||||
<font size="-1"><b>$senderName </b><$senderEmailAddress></font>
|
||||
<font size="-1">$fromPrefix: <b>$senderName </b><$senderEmailAddress></font>
|
||||
</td>
|
||||
<td align="right"><font size="-1">$dateTime</font></td>
|
||||
</tr>
|
||||
@@ -207,8 +208,8 @@ class PrintUtils {
|
||||
required String emailContent,
|
||||
required String senderName,
|
||||
required String senderEmailAddress,
|
||||
required String locale,
|
||||
required String dateTime,
|
||||
required String fromPrefix,
|
||||
required String toPrefix,
|
||||
required String ccPrefix,
|
||||
required String bccPrefix,
|
||||
@@ -234,6 +235,7 @@ class PrintUtils {
|
||||
Element? subjectElement = _createSubjectElement(subject);
|
||||
|
||||
Element? senderElement = _createSenderElement(
|
||||
fromPrefix: fromPrefix,
|
||||
senderName: senderName,
|
||||
senderEmailAddress: senderEmailAddress,
|
||||
dateTime: dateTime);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:core/data/model/print_attachment.dart';
|
||||
import 'package:core/domain/extensions/datetime_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:core/utils/print_utils.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:model/extensions/utc_date_extension.dart';
|
||||
import 'package:model/extensions/email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/data/datasource/print_file_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/email_print.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/attachment_extension.dart';
|
||||
@@ -30,9 +31,10 @@ class PrintFileDataSourceImpl extends PrintFileDataSource {
|
||||
final sender = emailPrint.emailInformation.from?.isNotEmpty == true
|
||||
? emailPrint.emailInformation.from!.first
|
||||
: null;
|
||||
final receiveTime = emailPrint.emailInformation.receivedAt?.formatDateToLocal(
|
||||
pattern: 'E, MMM d, yyyy \'at\' h:mm a',
|
||||
locale: emailPrint.locale);
|
||||
final receiveTime = emailPrint.emailInformation.getReceivedAt(
|
||||
newLocale: emailPrint.locale,
|
||||
pattern: emailPrint.emailInformation.receivedAt?.value.toLocal().toPatternForEmailView()
|
||||
);
|
||||
|
||||
final List<PrintAttachment> listPrintAttachment = [];
|
||||
|
||||
@@ -51,12 +53,12 @@ class PrintFileDataSourceImpl extends PrintFileDataSource {
|
||||
return await _printUtils.printEmail(
|
||||
appName: emailPrint.appName,
|
||||
userName: emailPrint.userName,
|
||||
locale: emailPrint.locale,
|
||||
subject: emailPrint.emailInformation.subject ?? '',
|
||||
emailContent: emailPrint.emailContent,
|
||||
senderName: sender?.name ?? '',
|
||||
senderEmailAddress: sender?.email ?? '',
|
||||
dateTime: receiveTime ?? '',
|
||||
dateTime: receiveTime,
|
||||
fromPrefix: emailPrint.fromPrefix,
|
||||
toPrefix: emailPrint.toPrefix,
|
||||
ccPrefix: emailPrint.ccPrefix,
|
||||
bccPrefix: emailPrint.bccPrefix,
|
||||
|
||||
@@ -9,6 +9,7 @@ class EmailPrint with EquatableMixin {
|
||||
final String emailContent;
|
||||
final String locale;
|
||||
final String toPrefix;
|
||||
final String fromPrefix;
|
||||
final String ccPrefix;
|
||||
final String bccPrefix;
|
||||
final String replyToPrefix;
|
||||
@@ -25,6 +26,7 @@ class EmailPrint with EquatableMixin {
|
||||
required this.emailInformation,
|
||||
required this.emailContent,
|
||||
required this.locale,
|
||||
required this.fromPrefix,
|
||||
required this.toPrefix,
|
||||
required this.ccPrefix,
|
||||
required this.bccPrefix,
|
||||
@@ -44,6 +46,7 @@ class EmailPrint with EquatableMixin {
|
||||
emailInformation,
|
||||
emailContent,
|
||||
locale,
|
||||
fromPrefix,
|
||||
toPrefix,
|
||||
ccPrefix,
|
||||
bccPrefix,
|
||||
@@ -66,6 +69,7 @@ extension EmailPrintExtension on EmailPrint {
|
||||
emailContent: newEmailContent,
|
||||
titleAttachment: titleAttachment,
|
||||
locale: locale,
|
||||
fromPrefix: fromPrefix,
|
||||
toPrefix: toPrefix,
|
||||
ccPrefix: ccPrefix,
|
||||
bccPrefix: bccPrefix,
|
||||
|
||||
@@ -1599,6 +1599,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
attachments: _currentEmailLoaded?.attachments,
|
||||
emailContent: _currentEmailLoaded?.htmlContent ?? '',
|
||||
locale: Localizations.localeOf(context).toLanguageTag(),
|
||||
fromPrefix: AppLocalizations.of(context).from_email_address_prefix,
|
||||
toPrefix: AppLocalizations.of(context).to_email_address_prefix,
|
||||
ccPrefix: AppLocalizations.of(context).cc_email_address_prefix,
|
||||
bccPrefix: AppLocalizations.of(context).bcc_email_address_prefix,
|
||||
|
||||
+1
-4
@@ -81,10 +81,7 @@ class InformationSenderAndReceiverBuilder extends StatelessWidget {
|
||||
],
|
||||
)
|
||||
),
|
||||
ReceivedTimeBuilder(
|
||||
emailSelected: emailSelected,
|
||||
margin: const EdgeInsetsDirectional.only(start: 16),
|
||||
),
|
||||
ReceivedTimeBuilder(emailSelected: emailSelected),
|
||||
]),
|
||||
if (emailSelected.numberOfAllEmailAddress() > 0)
|
||||
EmailReceiverWidget(
|
||||
|
||||
@@ -9,19 +9,16 @@ import 'package:model/extensions/presentation_email_extension.dart';
|
||||
class ReceivedTimeBuilder extends StatelessWidget {
|
||||
|
||||
final PresentationEmail emailSelected;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
|
||||
const ReceivedTimeBuilder({
|
||||
Key? key,
|
||||
required this.emailSelected,
|
||||
this.margin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
constraints: const BoxConstraints(maxWidth: 100),
|
||||
margin: margin,
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 16),
|
||||
child: Text(
|
||||
emailSelected.getReceivedAt(
|
||||
Localizations.localeOf(context).toLanguageTag(),
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@ enum AdvancedSearchFilterField {
|
||||
String getTitle(BuildContext context) {
|
||||
switch (this) {
|
||||
case AdvancedSearchFilterField.from:
|
||||
return AppLocalizations.of(context).form;
|
||||
return AppLocalizations.of(context).from_email_address_prefix;
|
||||
case AdvancedSearchFilterField.to:
|
||||
return AppLocalizations.of(context).to;
|
||||
return AppLocalizations.of(context).to_email_address_prefix;
|
||||
case AdvancedSearchFilterField.subject:
|
||||
return AppLocalizations.of(context).subject;
|
||||
case AdvancedSearchFilterField.hasKeyword:
|
||||
|
||||
@@ -1871,24 +1871,12 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "من",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "الموضوع",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "إلى",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"hasTheWords": "لديه الكلمات",
|
||||
"@hasTheWords": {
|
||||
"type": "text",
|
||||
|
||||
@@ -1439,18 +1439,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "From",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "To",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "Subject",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
|
||||
+2
-14
@@ -108,7 +108,7 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to_email_address_prefix": "Pour",
|
||||
"to_email_address_prefix": "À",
|
||||
"@to_email_address_prefix": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
@@ -1174,18 +1174,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "De",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "À",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"hasTheWords": "Contient les mots",
|
||||
"@hasTheWords": {
|
||||
"type": "text",
|
||||
@@ -2734,7 +2722,7 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"titleRecipientSendingEmail": "Pour : {recipients}",
|
||||
"titleRecipientSendingEmail": "À: {recipients}",
|
||||
"@titleRecipientSendingEmail": {
|
||||
"type": "text",
|
||||
"placeholders_order": [
|
||||
|
||||
@@ -1335,18 +1335,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "Da",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "A",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "Oggetto",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"@@last_modified": "2024-03-13T15:04:05.816015",
|
||||
"@@last_modified": "2024-03-15T11:06:05.333495",
|
||||
"initializing_data": "Initializing data...",
|
||||
"@initializing_data": {
|
||||
"type": "text",
|
||||
@@ -1440,18 +1440,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "From",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "To",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "Subject",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
|
||||
@@ -1336,12 +1336,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "От",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "Тема",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
@@ -1450,12 +1444,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "Кому",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"saveAndClose": "Сохранить и закрыть",
|
||||
"@saveAndClose": {
|
||||
"type": "text",
|
||||
|
||||
@@ -748,18 +748,6 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"form": "Từ",
|
||||
"@form": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"to": "Tới",
|
||||
"@to": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"subject": "Tiêu đề",
|
||||
"@subject": {
|
||||
"type": "text",
|
||||
|
||||
@@ -1457,20 +1457,6 @@ class AppLocalizations {
|
||||
name: 'wrongUrlMessage');
|
||||
}
|
||||
|
||||
String get form {
|
||||
return Intl.message(
|
||||
'From',
|
||||
name: 'form',
|
||||
);
|
||||
}
|
||||
|
||||
String get to {
|
||||
return Intl.message(
|
||||
'To',
|
||||
name: 'to',
|
||||
);
|
||||
}
|
||||
|
||||
String get subject {
|
||||
return Intl.message(
|
||||
'Subject',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:core/domain/extensions/datetime_extension.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
@@ -44,6 +45,17 @@ extension EmailExtension on Email {
|
||||
mailboxCurrent?.isSent == false;
|
||||
}
|
||||
|
||||
String getReceivedAt({required String newLocale, String? pattern}) {
|
||||
log('EmailExtension::getReceivedAt: newLocale = $newLocale | pattern = $pattern');
|
||||
if (receivedAt != null) {
|
||||
return receivedAt!.formatDateToLocal(
|
||||
pattern: pattern ?? receivedAt!.value.toLocal().toPattern(),
|
||||
locale: newLocale
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Set<String> getRecipientEmailAddressList() {
|
||||
final listEmailAddress = <String>{};
|
||||
final listToAddress = to.getListAddress() ?? [];
|
||||
|
||||
@@ -29,6 +29,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress();
|
||||
|
||||
String getReceivedAt(String newLocale, {String? pattern}) {
|
||||
log('PresentationEmailExtension::getReceivedAt: newLocale = $newLocale | pattern = $pattern');
|
||||
final emailTime = receivedAt;
|
||||
if (emailTime != null) {
|
||||
return emailTime.formatDateToLocal(
|
||||
|
||||
Reference in New Issue
Block a user