Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-3406 Edit as new email #3412

Open
wants to merge 4 commits into
base: master-candidate
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,19 @@ class ComposerController extends BaseController
);

switch(arguments.emailActionType) {
case EmailActionType.composeFromPresentationEmail:
_initEmailAddress(
presentationEmail: arguments.presentationEmail!,
actionType: EmailActionType.composeFromPresentationEmail
);
_initSubjectEmail(
presentationEmail: arguments.presentationEmail!,
actionType: EmailActionType.composeFromPresentationEmail
);
_getEmailContentOfEmailDrafts(
emailId: arguments.presentationEmail!.id!,
);
break;
case EmailActionType.editDraft:
_initEmailAddress(
presentationEmail: arguments.presentationEmail!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension EmailActionTypeExtension on EmailActionType {
case EmailActionType.editDraft:
case EmailActionType.editSendingEmail:
case EmailActionType.reopenComposerBrowser:
case EmailActionType.composeFromPresentationEmail:
return subject;
default:
return '';
Expand Down Expand Up @@ -143,6 +144,8 @@ extension EmailActionTypeExtension on EmailActionType {
return imagePaths.icMailboxArchived;
case EmailActionType.downloadMessageAsEML:
return imagePaths.icDownloadAttachment;
case EmailActionType.composeFromPresentationEmail:
return imagePaths.icEdit;
default:
return '';
}
Expand All @@ -164,6 +167,8 @@ extension EmailActionTypeExtension on EmailActionType {
return AppLocalizations.of(context).archiveMessage;
case EmailActionType.downloadMessageAsEML:
return AppLocalizations.of(context).downloadMessageAsEML;
case EmailActionType.composeFromPresentationEmail:
return AppLocalizations.of(context).editAsNewEmail;
default:
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
case EmailActionType.reopenComposerBrowser:
case EmailActionType.composeFromMailtoUri:
case EmailActionType.composeFromUnsubscribeMailtoLink:
case EmailActionType.composeFromPresentationEmail:
if (contentViewState == null) {
return const SizedBox.shrink();
}
Expand All @@ -64,9 +65,12 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
if (success is GetEmailContentLoading) {
return const CupertinoLoadingWidget(padding: EdgeInsets.all(16.0));
} else {
var newContent = success is GetEmailContentSuccess
? success.htmlEmailContent
: HtmlExtension.editorStartTags;
var newContent = HtmlExtension.editorStartTags;
if (success is GetEmailContentSuccess) {
newContent = success.htmlEmailContent;
} else if (success is GetEmailContentFromCacheSuccess) {
newContent = success.htmlEmailContent;
}
if (newContent.isEmpty) {
newContent = HtmlExtension.editorStartTags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
case EmailActionType.reopenComposerBrowser:
case EmailActionType.composeFromUnsubscribeMailtoLink:
case EmailActionType.composeFromMailtoUri:
case EmailActionType.composeFromPresentationEmail:
if (contentViewState == null) {
return const SizedBox.shrink();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
case EmailActionType.downloadMessageAsEML:
_downloadMessageAsEML(presentationEmail);
break;
case EmailActionType.composeFromPresentationEmail:
_composeFromPresentationEmail(presentationEmail);
break;
default:
break;
}
Expand Down Expand Up @@ -1871,6 +1874,14 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
downloadAttachmentForWeb(emlAttachment);
}

void _composeFromPresentationEmail(PresentationEmail presentationEmail) {
if (accountId == null || session == null) return;

mailboxDashBoardController.goToComposer(
ComposerArguments.fromPresentationEmail(presentationEmail),
);
}

void handleDownloadAttachmentAction(BuildContext context, Attachment attachment) {
if (PlatformInfo.isWeb) {
downloadAttachmentForWeb(attachment);
Expand Down
3 changes: 2 additions & 1 deletion lib/features/email/presentation/email_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ class EmailView extends GetWidget<SingleEmailController> {
if (mailboxContain?.isArchive == false)
EmailActionType.archiveMessage,
if (PlatformInfo.isWeb && PlatformInfo.isCanvasKit)
EmailActionType.downloadMessageAsEML
EmailActionType.downloadMessageAsEML,
EmailActionType.composeFromPresentationEmail,
];

if (position == null) {
Expand Down
6 changes: 6 additions & 0 deletions lib/features/email/presentation/model/composer_arguments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class ComposerArguments extends RouterArguments {
emailActionType: EmailActionType.editDraft,
presentationEmail: presentationEmail,
);

factory ComposerArguments.fromPresentationEmail(PresentationEmail presentationEmail) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromPresentationEmail,
presentationEmail: presentationEmail,
);

factory ComposerArguments.fromSessionStorageBrowser(ComposerCache composerCache) =>
ComposerArguments(
Expand Down
36 changes: 36 additions & 0 deletions lib/features/search/email/presentation/search_email_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import 'package:tmail_ui_user/features/thread/presentation/styles/item_email_til
import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_builder.dart'
if (dart.library.html) 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_web_builder.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';

class SearchEmailView extends GetWidget<SearchEmailController>
with AppLoaderMixin {
Expand Down Expand Up @@ -746,6 +747,8 @@ class SearchEmailView extends GetWidget<SearchEmailController>
List<Widget> _contextMenuActionTile(BuildContext context, PresentationEmail email) {
return <Widget>[
_markAsEmailSpamOrUnSpamAction(context, email),
if (email.mailboxContain?.isDrafts == false)
_editAsNewEmailContextMenuItemAction(context, email),
];
}

Expand Down Expand Up @@ -778,11 +781,44 @@ class SearchEmailView extends GetWidget<SearchEmailController>
.build();
}

Widget _editAsNewEmailContextMenuItemAction(
BuildContext context,
PresentationEmail email,
) {
return (
EmailActionCupertinoActionSheetActionBuilder(
const Key('edit_as_new_email_action'),
SvgPicture.asset(
controller.imagePaths.icEdit,
width: 24,
height: 24,
fit: BoxFit.fill,
colorFilter: AppColor.colorTextButton.asFilter()
),
AppLocalizations.of(context).editAsNewEmail,
email,
iconLeftPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12, end: 16)
: const EdgeInsetsDirectional.only(end: 12),
iconRightPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12)
: EdgeInsets.zero)
..onActionClick((email) {
popBack();
controller.editAsNewEmail(email);
})
).build();
}

List<PopupMenuEntry> _popupMenuActionTile(BuildContext context, PresentationEmail email) {
return [
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _markAsEmailSpamOrUnSpamAction(context, email)),
if (email.mailboxContain?.isDrafts == false)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _editAsNewEmailContextMenuItemAction(context, email)),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ mixin EmailActionController {
mailboxDashBoardController.goToComposer(ComposerArguments.editDraftEmail(presentationEmail));
}

void editAsNewEmail(PresentationEmail presentationEmail) {
mailboxDashBoardController.goToComposer(
ComposerArguments.fromPresentationEmail(presentationEmail),
);
}

void previewEmail(PresentationEmail presentationEmail) {
log('EmailActionController::previewEmail():presentationEmailId: ${presentationEmail.id}');
mailboxDashBoardController.openEmailDetailedView(presentationEmail);
Expand Down
3 changes: 3 additions & 0 deletions lib/features/thread/presentation/thread_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,9 @@ class ThreadController extends BaseController with EmailActionController {
case EmailActionType.preview:
if (mailboxContain?.isDrafts == true) {
editDraftEmail(selectedEmail);
} else if (mailboxContain?.isTemplates == true) {
popBack();
editAsNewEmail(selectedEmail);
} else {
previewEmail(selectedEmail);
}
Expand Down
58 changes: 57 additions & 1 deletion lib/features/thread/presentation/thread_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ class ThreadView extends GetWidget<ThreadController>
_markAsEmailSpamOrUnSpamContextMenuItemAction(context, email, mailboxContain),
if (mailboxContain?.isArchive == false)
_archiveMessageContextMenuItemAction(context, email),
if (mailboxContain?.isDrafts == false)
_editAsNewEmailContextMenuItemAction(context, email),
];
}

Expand Down Expand Up @@ -770,7 +772,7 @@ class ThreadView extends GetWidget<ThreadController>
email,
iconLeftPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12, end: 16)
: const EdgeInsetsDirectional.only(start: 12),
: const EdgeInsetsDirectional.only(end: 12),
iconRightPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12)
: EdgeInsets.zero
Expand All @@ -779,6 +781,35 @@ class ThreadView extends GetWidget<ThreadController>
).build();
}

Widget _editAsNewEmailContextMenuItemAction(
BuildContext context,
PresentationEmail email,
) {
return (
EmailActionCupertinoActionSheetActionBuilder(
const Key('edit_as_new_email_action'),
SvgPicture.asset(
controller.imagePaths.icEdit,
width: 24,
height: 24,
fit: BoxFit.fill,
colorFilter: AppColor.colorTextButton.asFilter()
),
AppLocalizations.of(context).editAsNewEmail,
email,
iconLeftPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12, end: 16)
: const EdgeInsetsDirectional.only(end: 12),
iconRightPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsetsDirectional.only(start: 12)
: EdgeInsets.zero)
..onActionClick((email) {
popBack();
controller.editAsNewEmail(email);
})
).build();
}

List<PopupMenuEntry> _popupMenuActionTile(BuildContext context, PresentationEmail email) {
final mailboxContain = email.mailboxContain;

Expand All @@ -788,6 +819,8 @@ class ThreadView extends GetWidget<ThreadController>
_buildMarkAsSpamPopupMenuItem(context, email, mailboxContain),
if (mailboxContain?.isArchive == false)
_buildArchiveMessagePopupMenuItem(context, email),
if (mailboxContain?.isDrafts == false)
_buildEditAsNewEmailPopupMenuItem(AppLocalizations.of(context), email),
];
}

Expand Down Expand Up @@ -865,6 +898,29 @@ class ThreadView extends GetWidget<ThreadController>
);
}

PopupMenuEntry _buildEditAsNewEmailPopupMenuItem(
AppLocalizations appLocalizations,
PresentationEmail email,
) {
return PopupMenuItem(
padding: EdgeInsets.zero,
child: popupItem(
controller.imagePaths.icEdit,
appLocalizations.editAsNewEmail,
colorIcon: AppColor.colorTextButton,
styleName: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16,
color: Colors.black
),
onCallbackAction: () {
popBack();
controller.editAsNewEmail(email);
}
)
);
}

Widget _buildMailboxActionProgressBanner(BuildContext context) {
return Obx(() {
return _MailboxActionProgressBanner(
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_messages.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4211,5 +4211,11 @@
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"editAsNewEmail": "Edit as new email",
"@editAsNewEmail": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
}
}
6 changes: 6 additions & 0 deletions lib/main/localizations/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4422,4 +4422,10 @@ class AppLocalizations {
);
}

String get editAsNewEmail {
return Intl.message(
'Edit as new email',
name: 'editAsNewEmail',
);
}
dab246 marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions model/lib/email/email_action_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum EmailActionType {
composeFromFileShared,
composeFromEmailAddress,
composeFromMailtoUri,
composeFromPresentationEmail,
reopenComposerBrowser,
moveToTrash,
deletePermanently,
Expand Down
Loading