TF-3189 new confirmation popup when enabling subaddressing for a folder
This commit is contained in:
committed by
Dat H. Pham
parent
019dbe6e03
commit
78be3e4d79
@@ -12,10 +12,11 @@ class ConfirmDialogBuilder {
|
||||
|
||||
Key? _key;
|
||||
String _title = '';
|
||||
String _content = '';
|
||||
String _textContent = '';
|
||||
String _confirmText = '';
|
||||
String _cancelText = '';
|
||||
Widget? _iconWidget;
|
||||
Widget? _additionalWidgetContent;
|
||||
Color? _colorCancelButton;
|
||||
Color? _colorConfirmButton;
|
||||
TextStyle? _styleTextCancelButton;
|
||||
@@ -63,7 +64,11 @@ class ConfirmDialogBuilder {
|
||||
}
|
||||
|
||||
void content(String content) {
|
||||
_content = content;
|
||||
_textContent = content;
|
||||
}
|
||||
|
||||
void addWidgetContent(Widget? icon) {
|
||||
_additionalWidgetContent = icon;
|
||||
}
|
||||
|
||||
void addIcon(Widget? icon) {
|
||||
@@ -210,11 +215,11 @@ class ConfirmDialogBuilder {
|
||||
)
|
||||
)
|
||||
),
|
||||
if (_content.isNotEmpty)
|
||||
if (_textContent.isNotEmpty)
|
||||
Padding(
|
||||
padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
child: Center(
|
||||
child: Text(_content,
|
||||
child: Text(_textContent,
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
|
||||
),
|
||||
@@ -233,6 +238,11 @@ class ConfirmDialogBuilder {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_additionalWidgetContent != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: _additionalWidgetContent,
|
||||
),
|
||||
if (isArrangeActionButtonsVertical)
|
||||
...[
|
||||
if (_cancelText.isNotEmpty)
|
||||
|
||||
@@ -52,6 +52,11 @@ import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/dialog_router.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
typedef RenameMailboxActionCallback = void Function(PresentationMailbox mailbox, MailboxName newMailboxName);
|
||||
typedef MovingMailboxActionCallback = void Function(PresentationMailbox mailboxSelected, PresentationMailbox? destinationMailbox);
|
||||
typedef DeleteMailboxActionCallback = void Function(PresentationMailbox mailbox);
|
||||
typedef AllowSubaddressingActionCallback = void Function(MailboxId, Map<String, List<String>?>?, MailboxActions);
|
||||
|
||||
abstract class BaseMailboxController extends BaseController {
|
||||
final TreeBuilder _treeBuilder;
|
||||
final VerifyNameInteractor verifyNameInteractor;
|
||||
@@ -318,7 +323,7 @@ abstract class BaseMailboxController extends BaseController {
|
||||
BuildContext context,
|
||||
PresentationMailbox presentationMailbox,
|
||||
ResponsiveUtils responsiveUtils, {
|
||||
required Function(PresentationMailbox mailbox, MailboxName newMailboxName) onRenameMailboxAction
|
||||
required RenameMailboxActionCallback onRenameMailboxAction
|
||||
}) {
|
||||
final listMailboxName = getListMailboxNameInParentMailbox(presentationMailbox);
|
||||
|
||||
@@ -388,7 +393,7 @@ abstract class BaseMailboxController extends BaseController {
|
||||
BuildContext context,
|
||||
PresentationMailbox mailboxSelected,
|
||||
MailboxDashBoardController dashBoardController, {
|
||||
required Function(PresentationMailbox mailboxSelected, PresentationMailbox? destinationMailbox) onMovingMailboxAction
|
||||
required MovingMailboxActionCallback onMovingMailboxAction
|
||||
}) async {
|
||||
final accountId = dashBoardController.accountId.value;
|
||||
final session = dashBoardController.sessionCurrent;
|
||||
@@ -421,7 +426,7 @@ abstract class BaseMailboxController extends BaseController {
|
||||
ResponsiveUtils responsiveUtils,
|
||||
ImagePaths imagePaths,
|
||||
PresentationMailbox presentationMailbox, {
|
||||
required Function(PresentationMailbox mailbox) onDeleteMailboxAction
|
||||
required DeleteMailboxActionCallback onDeleteMailboxAction
|
||||
}) {
|
||||
if (responsiveUtils.isLandscapeMobile(context) || responsiveUtils.isPortraitMobile(context)) {
|
||||
(ConfirmationDialogActionSheetBuilder(context)
|
||||
|
||||
@@ -75,6 +75,7 @@ import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.d
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/open_mailbox_view_event.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/utils/mailbox_utils.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/copy_subaddress_widget.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/mailbox_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/new_mailbox_arguments.dart';
|
||||
@@ -1267,6 +1268,22 @@ class MailboxController extends BaseMailboxController
|
||||
_unsubscribeMailboxAction(mailbox.id);
|
||||
break;
|
||||
case MailboxActions.allowSubaddressing:
|
||||
try{
|
||||
final subaddress = getSubaddress(mailboxDashBoardController.userEmail, findNodePathWithSeparator(mailbox.id, '.')!);
|
||||
openConfirmationDialogSubaddressingAction(
|
||||
context,
|
||||
responsiveUtils,
|
||||
imagePaths,
|
||||
mailbox.id,
|
||||
mailbox.getDisplayName(context),
|
||||
subaddress,
|
||||
mailbox.rights,
|
||||
onAllowSubaddressingAction: _handleSubaddressingAction
|
||||
);
|
||||
} catch (error) {
|
||||
appToast.showToastErrorMessage(context, AppLocalizations.of(context).errorWhileFetchingSubaddress);
|
||||
}
|
||||
break;
|
||||
case MailboxActions.disallowSubaddressing:
|
||||
_handleSubaddressingAction(mailbox.id, mailbox.rights, actions);
|
||||
break;
|
||||
@@ -1644,6 +1661,51 @@ class MailboxController extends BaseMailboxController
|
||||
return session.getContactSupportCapability(accountId);
|
||||
}
|
||||
|
||||
void openConfirmationDialogSubaddressingAction(
|
||||
BuildContext context,
|
||||
ResponsiveUtils responsiveUtils,
|
||||
ImagePaths imagePaths,
|
||||
MailboxId mailboxId,
|
||||
String mailboxName,
|
||||
String subaddress,
|
||||
Map<String, List<String>?>? currentRights, {
|
||||
required AllowSubaddressingActionCallback onAllowSubaddressingAction
|
||||
}) {
|
||||
if (responsiveUtils.isLandscapeMobile(context) || responsiveUtils.isPortraitMobile(context)) {
|
||||
(ConfirmationDialogActionSheetBuilder(context)
|
||||
..messageText(AppLocalizations.of(context).message_confirmation_dialog_allow_subaddressing(mailboxName))
|
||||
..onCancelAction(AppLocalizations.of(context).cancel, () => popBack())
|
||||
..onConfirmAction(AppLocalizations.of(context).allow, () => onAllowSubaddressingAction(mailboxId, currentRights, MailboxActions.allowSubaddressing))
|
||||
).show();
|
||||
} else {
|
||||
Get.dialog(
|
||||
PointerInterceptor(
|
||||
child: (ConfirmDialogBuilder(imagePaths)
|
||||
..key(const Key('confirm_dialog_subaddressing'))
|
||||
..title(AppLocalizations.of(context).allowSubaddressing)
|
||||
..styleTitle(const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.colorTextButton
|
||||
))
|
||||
..content(AppLocalizations.of(context).message_confirmation_dialog_allow_subaddressing(mailboxName))
|
||||
..addIcon(SvgPicture.asset(imagePaths.icSubaddressingAllow, width: 64, height: 64))
|
||||
..addWidgetContent(CopySubaddressWidget(
|
||||
context: context,
|
||||
imagePath: imagePaths,
|
||||
subaddress: subaddress,
|
||||
onCopyButtonAction: () => copySubaddressAction(context, subaddress),
|
||||
))
|
||||
..colorCancelButton(AppColor.colorContentEmail)
|
||||
..onCloseButtonAction(() => popBack())
|
||||
..onConfirmButtonAction(AppLocalizations.of(context).allow, () => onAllowSubaddressingAction(mailboxId, currentRights, MailboxActions.allowSubaddressing))
|
||||
..onCancelButtonAction(AppLocalizations.of(context).cancel, () => popBack())
|
||||
).build()),
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void copySubaddressAction(BuildContext context, String subaddress) {
|
||||
Clipboard.setData(ClipboardData(text: subaddress));
|
||||
appToast.showToastSuccessMessage(context, AppLocalizations.of(context).emailSubaddressCopiedToClipboard);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnCopyButtonAction = void Function();
|
||||
|
||||
class CopySubaddressWidget extends StatelessWidget {
|
||||
|
||||
final BuildContext context;
|
||||
final ImagePaths imagePath;
|
||||
final String subaddress;
|
||||
|
||||
final OnCopyButtonAction onCopyButtonAction;
|
||||
|
||||
const CopySubaddressWidget({
|
||||
super.key,
|
||||
required this.context,
|
||||
required this.imagePath,
|
||||
required this.subaddress,
|
||||
required this.onCopyButtonAction
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
subaddress,
|
||||
style: const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog),
|
||||
),
|
||||
),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: imagePath.icCopy,
|
||||
iconSize: 30,
|
||||
padding: const EdgeInsets.all(3),
|
||||
backgroundColor: Colors.transparent,
|
||||
margin: const EdgeInsetsDirectional.only(top: 16, end: 16),
|
||||
onTapActionCallback: onCopyButtonAction
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -718,6 +718,16 @@
|
||||
"nameMailbox": {}
|
||||
}
|
||||
},
|
||||
"message_confirmation_dialog_allow_subaddressing": "You are about to allow anyone to send emails directly to your folder \"{nameMailbox}\" using:",
|
||||
"@message_confirmation_dialog_allow_subaddressing": {
|
||||
"type": "text",
|
||||
"placeholders_order": [
|
||||
"nameMailbox"
|
||||
],
|
||||
"placeholders": {
|
||||
"nameMailbox": {}
|
||||
}
|
||||
},
|
||||
"renameFolder": "Rename folder",
|
||||
"@renameFolder": {
|
||||
"type": "text",
|
||||
@@ -2364,6 +2374,12 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"allow": "Allow",
|
||||
"@allow": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"disallowSubaddressing": "Disallow subaddressing",
|
||||
"@disallowSubaddressing": {
|
||||
"type": "text",
|
||||
|
||||
@@ -729,6 +729,14 @@ class AppLocalizations {
|
||||
);
|
||||
}
|
||||
|
||||
String message_confirmation_dialog_allow_subaddressing(String nameMailbox) {
|
||||
return Intl.message(
|
||||
'You are about to allow anyone to send emails directly to your folder "$nameMailbox" using:',
|
||||
name: 'message_confirmation_dialog_allow_subaddressing',
|
||||
args: [nameMailbox]
|
||||
);
|
||||
}
|
||||
|
||||
String get renameFolder {
|
||||
return Intl.message(
|
||||
'Rename folder',
|
||||
@@ -2434,6 +2442,12 @@ class AppLocalizations {
|
||||
name: 'allowSubaddressing');
|
||||
}
|
||||
|
||||
String get allow {
|
||||
return Intl.message(
|
||||
'Allow',
|
||||
name: 'allow');
|
||||
}
|
||||
|
||||
String get disallowSubaddressing {
|
||||
return Intl.message(
|
||||
'Disallow subaddressing',
|
||||
|
||||
Reference in New Issue
Block a user