diff --git a/core/lib/presentation/extensions/html_extension.dart b/core/lib/presentation/extensions/html_extension.dart index 3753a0997..0ede25835 100644 --- a/core/lib/presentation/extensions/html_extension.dart +++ b/core/lib/presentation/extensions/html_extension.dart @@ -17,12 +17,14 @@ extension HtmlExtension on String { String addBlockTag(String tag, {String? attribute}) => attribute != null ? '<$tag $attribute>$this' : '<$tag>$this'; + String append(String value) => this + value; + String addNewLineTag({int count = 1}) { - if (count == 1) return '$this
'; + if (count == 1) return '$this
'; var htmlString = this; for (var i = 0; i < count; i++) { - htmlString = '$htmlString
'; + htmlString = '$htmlString
'; } return htmlString; } diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index 67eebe7fc..38f5c62da 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -236,11 +236,70 @@ class ComposerController extends BaseController { htmlControllerBrowser.setFullScreen(); } - Tuple2? _getHeaderEmailQuoted(String locale, ComposerArguments arguments) { - if (arguments.presentationEmail != null) { - final sentDate = arguments.presentationEmail?.sentAt; - final emailAddress = arguments.presentationEmail?.from.listEmailAddressToString(isFullEmailAddress: true) ?? ''; - return Tuple2(sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale), emailAddress); + String? _getHeaderEmailQuoted(BuildContext context, ComposerArguments arguments) { + final presentationEmail = arguments.presentationEmail; + if (presentationEmail != null) { + final locale = Localizations.localeOf(context).toLanguageTag(); + log('ComposerController::_getHeaderEmailQuoted(): emailActionType: ${arguments.emailActionType}'); + switch(arguments.emailActionType) { + case EmailActionType.reply: + case EmailActionType.replyAll: + final sentDate = presentationEmail.sentAt; + final emailAddress = presentationEmail.from.listEmailAddressToString(isFullEmailAddress: true); + return AppLocalizations.of(context).header_email_quoted( + sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale), + emailAddress); + case EmailActionType.forward: + var headerQuoted = '------- ${AppLocalizations.of(context).forwarded_message} -------'.addNewLineTag(); + + final subject = presentationEmail.subject ?? ''; + final sentDate = presentationEmail.sentAt; + final fromEmailAddress = presentationEmail.from.listEmailAddressToString(isFullEmailAddress: true); + final toEmailAddress = presentationEmail.to.listEmailAddressToString(isFullEmailAddress: true); + final ccEmailAddress = presentationEmail.cc.listEmailAddressToString(isFullEmailAddress: true); + final bccEmailAddress = presentationEmail.bcc.listEmailAddressToString(isFullEmailAddress: true); + + if (subject.isNotEmpty) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).subject_email}: ') + .append(subject) + .addNewLineTag(); + } + if (sentDate != null) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).date}: ') + .append(sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale)) + .addNewLineTag(); + } + if (fromEmailAddress.isNotEmpty) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).from_email_address_prefix}: ') + .append(fromEmailAddress) + .addNewLineTag(); + } + if (toEmailAddress.isNotEmpty) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).to_email_address_prefix}: ') + .append(toEmailAddress) + .addNewLineTag(); + } + if (ccEmailAddress.isNotEmpty) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).cc_email_address_prefix}: ') + .append(ccEmailAddress) + .addNewLineTag(); + } + if (bccEmailAddress.isNotEmpty) { + headerQuoted = headerQuoted + .append('${AppLocalizations.of(context).bcc_email_address_prefix}: ') + .append(bccEmailAddress) + .addNewLineTag(); + } + + return headerQuoted; + default: + return null; + } } return null; } @@ -312,11 +371,9 @@ class ComposerController extends BaseController { } String getEmailContentQuotedAsHtml(BuildContext context, ComposerArguments arguments) { - final headerEmailQuoted = _getHeaderEmailQuoted(Localizations.localeOf(context).toLanguageTag(), arguments); - - final headerEmailQuotedAsHtml = headerEmailQuoted != null - ? AppLocalizations.of(context).header_email_quoted(headerEmailQuoted.value1, headerEmailQuoted.value2).addBlockTag('cite') - : ''; + final headerEmailQuoted = _getHeaderEmailQuoted(context, arguments); + log('ComposerController::getEmailContentQuotedAsHtml(): headerEmailQuoted: $headerEmailQuoted'); + final headerEmailQuotedAsHtml = headerEmailQuoted != null ? headerEmailQuoted.addBlockTag('cite') : ''; final trustAsHtml = arguments.emailContents?.asHtmlString ?? ''; final emailQuotedHtml = '


$headerEmailQuotedAsHtml${trustAsHtml.addBlockQuoteTag()}'; diff --git a/lib/features/email/presentation/email_controller.dart b/lib/features/email/presentation/email_controller.dart index c845bd766..cf95f52b8 100644 --- a/lib/features/email/presentation/email_controller.dart +++ b/lib/features/email/presentation/email_controller.dart @@ -596,7 +596,7 @@ class EmailController extends BaseController { emailActionType: emailActionType, presentationEmail: mailboxDashBoardController.selectedEmail.value!, emailContents: initialEmailContents, - attachments: attachments, + attachments: emailActionType == EmailActionType.forward ? attachments : null, mailboxRole: mailboxDashBoardController.selectedMailbox.value?.role); if (kIsWeb) { diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index 95cf30f5a..6af71af8e 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -522,12 +522,12 @@ class EmailView extends GetView with UserSettingPopupMenuMixin, NetworkConnectio (failure) => SizedBox.shrink(), (success) { if (success is LoadingState) { - return Padding( + return Align(alignment: Alignment.topCenter, child: Padding( padding: EdgeInsets.all(16), child: SizedBox( width: 30, height: 30, - child: CupertinoActivityIndicator(color: AppColor.colorLoading))); + child: CupertinoActivityIndicator(color: AppColor.colorLoading)))); } else { if (emailController.emailContents.isNotEmpty) { final allEmailContents = emailController.emailContents.asHtmlString; diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index d741d3a1d..d384a81d7 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2022-04-07T15:43:45.603676", + "@@last_modified": "2022-04-14T15:13:36.565629", "initializing_data": "Initializing data...", "@initializing_data": { "type": "text", @@ -214,12 +214,6 @@ "placeholders_order": [], "placeholders": {} }, - "move_to_mailbox": "Move to mailbox", - "@move_to_mailbox": { - "type": "text", - "placeholders_order": [], - "placeholders": {} - }, "mark_as_star": "Star", "@mark_as_star": { "type": "text", @@ -1041,5 +1035,29 @@ "type": "text", "placeholders_order": [], "placeholders": {} + }, + "exchange": "Exchange", + "@exchange": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "move_message": "Move message", + "@move_message": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "forwarded_message": "Forwarded message", + "@forwarded_message": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, + "date": "Date", + "@date": { + "type": "text", + "placeholders_order": [], + "placeholders": {} } } \ No newline at end of file diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index f8c0e1070..eb2922894 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -1097,4 +1097,18 @@ class AppLocalizations { name: 'move_message', ); } + + String get forwarded_message { + return Intl.message( + 'Forwarded message', + name: 'forwarded_message', + ); + } + + String get date { + return Intl.message( + 'Date', + name: 'date', + ); + } } \ No newline at end of file