Skip to content

Commit

Permalink
fixup! TF-3406 Add edit as new email feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Jan 8, 2025
1 parent caa01bf commit 0624157
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
34 changes: 34 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,7 @@ class SearchEmailView extends GetWidget<SearchEmailController>
List<Widget> _contextMenuActionTile(BuildContext context, PresentationEmail email) {
return <Widget>[
_markAsEmailSpamOrUnSpamAction(context, email),
_editAsNewEmailContextMenuItemAction(context, email),
];
}

Expand Down Expand Up @@ -778,11 +780,43 @@ 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 EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
iconRightPadding: controller.responsiveUtils.isMobile(context)
? const EdgeInsets.only(right: 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)),
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
8 changes: 2 additions & 6 deletions lib/features/thread/presentation/thread_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,7 @@ class ThreadView extends GetWidget<ThreadController>
: EdgeInsets.zero)
..onActionClick((email) {
popBack();
controller.mailboxDashBoardController.goToComposer(
ComposerArguments.fromPresentationEmail(email)
);
controller.editAsNewEmail(email);
})
).build();
}
Expand Down Expand Up @@ -915,9 +913,7 @@ class ThreadView extends GetWidget<ThreadController>
),
onCallbackAction: () {
popBack();
controller.mailboxDashBoardController.goToComposer(
ComposerArguments.fromPresentationEmail(email)
);
controller.editAsNewEmail(email);
}
)
);
Expand Down

0 comments on commit 0624157

Please sign in to comment.