TF-4367 Update logic apply Reply/Forward prefix for subject when compose email
This commit is contained in:
@@ -10,26 +10,27 @@ import 'package:model/extensions/utc_date_extension.dart';
|
|||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
extension EmailActionTypeExtension on EmailActionType {
|
extension EmailActionTypeExtension on EmailActionType {
|
||||||
|
static const String _defaultReplyPrefix = 'Re:';
|
||||||
|
static const String _defaultForwardPrefix = 'Fwd:';
|
||||||
|
|
||||||
String getSubjectComposer(BuildContext? context, String subject) {
|
String getSubjectComposer(BuildContext? context, String subject) {
|
||||||
switch(this) {
|
final l10n = context != null ? AppLocalizations.of(context) : null;
|
||||||
|
|
||||||
|
switch (this) {
|
||||||
case EmailActionType.reply:
|
case EmailActionType.reply:
|
||||||
case EmailActionType.replyToList:
|
case EmailActionType.replyToList:
|
||||||
case EmailActionType.replyAll:
|
case EmailActionType.replyAll:
|
||||||
if (subject.toLowerCase().startsWith('re:')) {
|
return _applyPrefix(
|
||||||
return subject;
|
subject: subject,
|
||||||
} else {
|
defaultPrefix: _defaultReplyPrefix,
|
||||||
return context != null
|
localizedPrefix: l10n?.prefix_reply_email,
|
||||||
? '${AppLocalizations.of(context).prefix_reply_email} $subject'
|
);
|
||||||
: 'Re: $subject';
|
|
||||||
}
|
|
||||||
case EmailActionType.forward:
|
case EmailActionType.forward:
|
||||||
if (subject.toLowerCase().startsWith('fwd:')) {
|
return _applyPrefix(
|
||||||
return subject;
|
subject: subject,
|
||||||
} else {
|
defaultPrefix: _defaultForwardPrefix,
|
||||||
return context != null
|
localizedPrefix: l10n?.prefix_forward_email,
|
||||||
? '${AppLocalizations.of(context).prefix_forward_email} $subject'
|
);
|
||||||
: 'Fwd: $subject';
|
|
||||||
}
|
|
||||||
case EmailActionType.editDraft:
|
case EmailActionType.editDraft:
|
||||||
case EmailActionType.editSendingEmail:
|
case EmailActionType.editSendingEmail:
|
||||||
case EmailActionType.reopenComposerBrowser:
|
case EmailActionType.reopenComposerBrowser:
|
||||||
@@ -42,6 +43,29 @@ extension EmailActionTypeExtension on EmailActionType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _applyPrefix({
|
||||||
|
required String subject,
|
||||||
|
required String defaultPrefix,
|
||||||
|
String? localizedPrefix,
|
||||||
|
}) {
|
||||||
|
final trimmed = subject.trim();
|
||||||
|
final lowerSubject = trimmed.toLowerCase();
|
||||||
|
|
||||||
|
final prefixes = <String>[
|
||||||
|
defaultPrefix.toLowerCase(),
|
||||||
|
if (localizedPrefix != null) localizedPrefix.toLowerCase(),
|
||||||
|
];
|
||||||
|
|
||||||
|
final hasPrefix = prefixes.any(lowerSubject.startsWith);
|
||||||
|
|
||||||
|
if (hasPrefix) {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
final prefix = localizedPrefix ?? defaultPrefix;
|
||||||
|
return '$prefix $subject';
|
||||||
|
}
|
||||||
|
|
||||||
String getToastMessageMoveToMailboxSuccess(BuildContext context, {String? destinationPath}) {
|
String getToastMessageMoveToMailboxSuccess(BuildContext context, {String? destinationPath}) {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case EmailActionType.archiveMessage:
|
case EmailActionType.archiveMessage:
|
||||||
|
|||||||
Reference in New Issue
Block a user