TF-898 Implement quick creating rule in email view

This commit is contained in:
dab246
2022-11-11 10:59:31 +07:00
committed by Dat H. Pham
parent 927151ec8e
commit f4f6298761
20 changed files with 538 additions and 262 deletions
@@ -55,9 +55,13 @@ import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_action
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/dashboard_routes.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/download/download_task_state.dart';
import 'package:tmail_ui_user/features/manage_account/domain/model/create_new_email_rule_filter_request.dart';
import 'package:tmail_ui_user/features/manage_account/domain/state/create_new_rule_filter_state.dart';
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_identities_state.dart';
import 'package:tmail_ui_user/features/manage_account/domain/usecases/create_new_email_rule_filter_interactor.dart';
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_identities_interactor.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/datetime_extension.dart';
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/rules_filter_creator_arguments.dart';
import 'package:tmail_ui_user/features/thread/domain/constants/thread_constants.dart';
import 'package:tmail_ui_user/features/thread/presentation/model/delete_action_type.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
@@ -85,6 +89,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final DownloadAttachmentForWebInteractor _downloadAttachmentForWebInteractor;
final GetAllIdentitiesInteractor _getAllIdentitiesInteractor;
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
SendReceiptToSenderInteractor? _sendReceiptToSenderInteractor;
final emailAddressExpandMode = ExpandMode.COLLAPSE.obs;
@@ -126,6 +131,14 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
_initializeDebounceTimeIndexPageViewChange();
_initWorker();
_listenDownloadAttachmentProgressState();
injectRuleFilterBindings(
emailSupervisorController.sessionCurrent,
emailSupervisorController.accountId);
try {
_createNewEmailRuleFilterInteractor = Get.find<CreateNewEmailRuleFilterInteractor>();
} catch (e) {
logError('SingleEmailController::onInit(): ${e.toString()}');
}
super.onInit();
}
@@ -138,7 +151,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
try {
_sendReceiptToSenderInteractor = Get.find<SendReceiptToSenderInteractor>();
} catch (e) {
logError('EmailController::onReady(): SendReceiptToSenderInteractor not registered');
logError('SingleEmailController::onReady(): SendReceiptToSenderInteractor not registered');
}
super.onReady();
}
@@ -161,7 +174,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _initWorker() {
emailWorker = ever(emailSupervisorController.selectedEmail, (presentationEmail) {
log('EmailController::_initWorker(): $presentationEmail');
log('SingleEmailController::_initWorker(): $presentationEmail');
if (presentationEmail is PresentationEmail) {
if (_currentEmailId != presentationEmail.id) {
_currentEmailId = presentationEmail.id;
@@ -185,7 +198,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _listenDownloadAttachmentProgressState() {
downloadProgressState.listen((state) {
log('EmailController::_listenDownloadAttachmentProgressState(): $state');
log('SingleEmailController::_listenDownloadAttachmentProgressState(): $state');
state.fold(
(failure) => null,
(success) {
@@ -203,7 +216,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
} else if (success is DownloadingAttachmentForWeb) {
final percent = success.progress.round();
log('EmailController::DownloadingAttachmentForWeb(): $percent%');
log('SingleEmailController::DownloadingAttachmentForWeb(): $percent%');
emailSupervisorController.mailboxDashBoardController.updateDownloadTask(
success.taskId,
@@ -234,7 +247,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
.firstWhere((identity) => identity.mayDelete == false);
_identitySelected = identityDefault;
} catch (e) {
logError('EmailController::_getAllIdentitiesSuccess(): ${e.toString()}');
logError('SingleEmailController::_getAllIdentitiesSuccess(): ${e.toString()}');
_identitySelected = success.identities!.first;
}
}
@@ -290,6 +303,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
_getAllIdentitiesSuccess(success);
} else if (success is SendReceiptToSenderSuccess) {
_sendReceiptToSenderSuccess(success);
} else if (success is CreateNewRuleFilterSuccess) {
_createNewRuleFilterSuccess(success);
}
});
}
@@ -479,7 +494,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _openDownloadedPreviewWorkGroupDocument(DownloadedResponse downloadedResponse) async {
log('EmailController::_openDownloadedPreviewWorkGroupDocument(): $downloadedResponse');
log('SingleEmailController::_openDownloadedPreviewWorkGroupDocument(): $downloadedResponse');
if (downloadedResponse.mediaType == null) {
await share_library.Share.shareFiles([downloadedResponse.filePath]);
}
@@ -490,7 +505,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
uti: Platform.isIOS ? downloadedResponse.mediaType!.getDocumentUti().value : null);
if (openResult.type != open_file.ResultType.done) {
logError('EmailController::_openDownloadedPreviewWorkGroupDocument(): no preview available');
logError('SingleEmailController::_openDownloadedPreviewWorkGroupDocument(): no preview available');
if (currentContext != null) {
_appToast.showErrorToast(AppLocalizations.of(currentContext!).noPreviewAvailable);
}
@@ -516,7 +531,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _downloadAttachmentForWebSuccessAction(DownloadAttachmentForWebSuccess success) {
log('EmailController::_downloadAttachmentForWebSuccessAction():');
log('SingleEmailController::_downloadAttachmentForWebSuccessAction():');
mailboxDashBoardController.deleteDownloadTask(success.taskId);
_downloadManager.createAnchorElementDownloadFileWeb(
@@ -525,7 +540,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _downloadAttachmentForWebFailureAction(DownloadAttachmentForWebFailure failure) {
log('EmailController::_downloadAttachmentForWebFailureAction(): $failure');
log('SingleEmailController::_downloadAttachmentForWebFailureAction(): $failure');
mailboxDashBoardController.deleteDownloadTask(failure.taskId);
if (currentOverlayContext != null && currentContext != null) {
@@ -772,22 +787,25 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void openEmailAddressDialog(BuildContext context, EmailAddress emailAddress) {
if (responsiveUtils.isScreenWithShortestSide(context)) {
(EmailAddressBottomSheetBuilder(context, imagePaths, emailAddress)
..addOnCloseContextMenuAction(() => popBack())
..addOnCopyEmailAddressAction((emailAddress) => copyEmailAddress(context, emailAddress))
..addOnComposeEmailAction((emailAddress) => composeEmailFromEmailAddress(emailAddress)))
.show();
..addOnCloseContextMenuAction(() => popBack())
..addOnCopyEmailAddressAction((emailAddress) => copyEmailAddress(context, emailAddress))
..addOnComposeEmailAction((emailAddress) => composeEmailFromEmailAddress(emailAddress))
..addOnQuickCreatingRuleEmailBottomSheetAction((emailAddress) => quickCreatingRule(context, emailAddress))
).show();
} else {
showDialog(
context: context,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
builder: (BuildContext context) => PointerInterceptor(
child: EmailAddressDialogBuilder(
emailAddress,
onCloseDialogAction: () => popBack(),
onCopyEmailAddressAction: (emailAddress) =>
copyEmailAddress(context, emailAddress),
onComposeEmailAction: (emailAddress) =>
composeEmailFromEmailAddress(emailAddress))));
context: context,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
builder: (BuildContext context) => PointerInterceptor(
child: EmailAddressDialogBuilder(
emailAddress,
onCloseDialogAction: () => popBack(),
onCopyEmailAddressAction: (emailAddress) => copyEmailAddress(context, emailAddress),
onComposeEmailAction: (emailAddress) => composeEmailFromEmailAddress(emailAddress),
onQuickCreatingRuleEmailDialogAction: (emailAddress) => quickCreatingRule(context, emailAddress)
)
)
);
}
}
@@ -813,9 +831,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void openMailToLink(Uri? uri) {
log('EmailController::openMailToLink(): ${uri.toString()}');
log('SingleEmailController::openMailToLink(): ${uri.toString()}');
String address = uri?.path ?? '';
log('EmailController::openMailToLink(): address: $address');
log('SingleEmailController::openMailToLink(): address: $address');
if (address.isNotEmpty) {
final emailAddress = EmailAddress(null, address);
final arguments = ComposerArguments(
@@ -920,7 +938,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
mdn: mdnToSender,
identityId: _identitySelected!.id!,
sendId: Id(_uuid.v1()));
log('EmailController::_handleSendReceiptToSenderAction(): sendReceiptRequest: $sendReceiptRequest');
log('SingleEmailController::_handleSendReceiptToSenderAction(): sendReceiptRequest: $sendReceiptRequest');
consumeState(_sendReceiptToSenderInteractor!.execute(accountId, sendReceiptRequest));
}
@@ -948,7 +966,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _sendReceiptToSenderSuccess(SendReceiptToSenderSuccess success) {
log('EmailController::_sendReceiptToSenderSuccess(): ${success.mdn.toString()}');
log('SingleEmailController::_sendReceiptToSenderSuccess(): ${success.mdn.toString()}');
if (currentContext != null) {
_appToast.showBottomToast(
currentOverlayContext!,
@@ -997,4 +1015,63 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
mailboxDashBoardController.goToComposer(arguments);
}
}
void quickCreatingRule(BuildContext context, EmailAddress emailAddress) async {
popBack();
final accountId = mailboxDashBoardController.accountId.value;
final session = mailboxDashBoardController.sessionCurrent;
if (accountId != null && session != null) {
final arguments = RulesFilterCreatorArguments(
accountId,
session,
emailAddress: emailAddress);
if (BuildUtils.isWeb) {
showDialogRuleFilterCreator(
context: context,
arguments: arguments,
onCreatedRuleFilter: (arguments) {
if (arguments is CreateNewEmailRuleFilterRequest) {
_createNewRuleFilterAction(accountId, arguments);
}
}
);
} else {
final newRuleFilterRequest = await push(
AppRoutes.rulesFilterCreator,
arguments: arguments
);
if (newRuleFilterRequest is CreateNewEmailRuleFilterRequest) {
_createNewRuleFilterAction(accountId, newRuleFilterRequest);
}
}
}
}
void _createNewRuleFilterAction(
AccountId accountId,
CreateNewEmailRuleFilterRequest ruleFilterRequest
) async {
try {
_createNewEmailRuleFilterInteractor = Get.find<CreateNewEmailRuleFilterInteractor>();
} catch (e) {
logError('SingleEmailController::onInit(): ${e.toString()}');
}
if (_createNewEmailRuleFilterInteractor != null) {
consumeState(_createNewEmailRuleFilterInteractor!.execute(accountId, ruleFilterRequest));
}
}
void _createNewRuleFilterSuccess(CreateNewRuleFilterSuccess success) {
if (success.newListRules.isNotEmpty == true) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastWithIcon(
currentOverlayContext!,
message: AppLocalizations.of(currentContext!).newFilterWasCreated,
icon: imagePaths.icSelected);
}
}
}
}
+104 -71
View File
@@ -746,21 +746,27 @@ class EmailView extends GetWidget<SingleEmailController> {
return <Widget>[
_markAsEmailUnreadAction(context, email),
_markAsEmailSpamOrUnSpamAction(context, email),
_quickCreatingRuleAction(context, email),
];
}
Widget _markAsEmailUnreadAction(BuildContext context, PresentationEmail email) {
return (EmailActionCupertinoActionSheetActionBuilder(
const Key('mark_as_unread_action'),
SvgPicture.asset(imagePaths.icUnreadEmail, width: 28, height: 28, fit: BoxFit.fill, color: AppColor.colorTextButton),
SvgPicture.asset(
imagePaths.icUnreadEmail,
width: 24,
height: 24,
fit: BoxFit.fill,
color: AppColor.colorTextButton),
AppLocalizations.of(context).mark_as_unread,
email,
iconLeftPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
? const EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
iconRightPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(right: 12)
: EdgeInsets.zero)
? const EdgeInsets.only(right: 12)
: EdgeInsets.zero)
..onActionClick((email) => controller.handleEmailAction(context, email, EmailActionType.markAsUnread)))
.build();
}
@@ -771,100 +777,127 @@ class EmailView extends GetWidget<SingleEmailController> {
return (EmailActionCupertinoActionSheetActionBuilder(
const Key('mark_as_spam_or_un_spam_action'),
SvgPicture.asset(
currentMailbox?.isSpam == true ? imagePaths.icNotSpam : imagePaths.icMailboxSpam,
width: 28, height: 28, fit: BoxFit.fill, color: AppColor.colorTextButton),
currentMailbox?.isSpam == true ? imagePaths.icNotSpam : imagePaths.icMailboxSpam,
width: 24,
height: 24,
fit: BoxFit.fill,
color: AppColor.colorTextButton),
currentMailbox?.isSpam == true
? AppLocalizations.of(context).remove_from_spam
: AppLocalizations.of(context).mark_as_spam,
? AppLocalizations.of(context).remove_from_spam
: AppLocalizations.of(context).mark_as_spam,
email,
iconLeftPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
? const EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
iconRightPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(right: 12)
: EdgeInsets.zero)
? const EdgeInsets.only(right: 12)
: EdgeInsets.zero)
..onActionClick((email) => controller.handleEmailAction(context, email,
currentMailbox?.isSpam == true ? EmailActionType.unSpam : EmailActionType.moveToSpam)))
.build();
}
Widget _quickCreatingRuleAction(BuildContext context, PresentationEmail email) {
return (EmailActionCupertinoActionSheetActionBuilder(
const Key('quick_creating_rule_action'),
SvgPicture.asset(
imagePaths.icQuickCreatingRule,
width: 24,
height: 24,
fit: BoxFit.fill,
color: AppColor.colorTextButton),
AppLocalizations.of(context).quickCreatingRule,
email,
iconLeftPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(left: 12, right: 16)
: const EdgeInsets.only(right: 12),
iconRightPadding: responsiveUtils.isMobile(context)
? const EdgeInsets.only(right: 12)
: EdgeInsets.zero)
..onActionClick((email) => controller.quickCreatingRule(context, email.from!.first)))
.build();
}
List<PopupMenuEntry> _popupMenuEmailActionTile(BuildContext context, PresentationEmail email) {
return [
PopupMenuItem(
padding: EdgeInsets.zero,
child: _markAsEmailUnreadPopupItemAction(context, email)),
padding: EdgeInsets.zero,
child: _markAsEmailUnreadPopupItemAction(context, email)),
PopupMenuItem(
padding: EdgeInsets.zero,
child: _markAsEmailSpamOrUnSpamPopupItemAction(context, email)),
padding: EdgeInsets.zero,
child: _markAsEmailSpamOrUnSpamPopupItemAction(context, email)),
PopupMenuItem(
padding: EdgeInsets.zero,
child: _quickCreatingRulePopupItemAction(context, email)),
];
}
Widget _markAsEmailUnreadPopupItemAction(BuildContext context, PresentationEmail email) {
return InkWell(
onTap: () => controller.handleEmailAction(context, email, EmailActionType.markAsUnread),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SizedBox(
width: 383,
height: 56,
child: Row(children: [
SvgPicture.asset(
imagePaths.icUnreadEmail,
width: 24,
height: 24,
color: AppColor.colorTextButton,
fit: BoxFit.fill),
const SizedBox(width: 12),
Expanded(child: Text(
AppLocalizations.of(context).mark_as_unread,
style: const TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500)
)),
])
),
)
return _popupMenuItem(
icon: imagePaths.icUnreadEmail,
title: AppLocalizations.of(context).mark_as_unread,
onTapCallback: () => controller.handleEmailAction(context, email, EmailActionType.markAsUnread)
);
}
Widget _markAsEmailSpamOrUnSpamPopupItemAction(BuildContext context, PresentationEmail email) {
final currentMailbox = controller.getMailboxContain(email);
return InkWell(
onTap: () => controller.handleEmailAction(
context,
email,
currentMailbox?.isSpam == true
? EmailActionType.unSpam
: EmailActionType.moveToSpam),
return _popupMenuItem(
icon: currentMailbox?.isSpam == true
? imagePaths.icNotSpam
: imagePaths.icMailboxSpam,
title: currentMailbox?.isSpam == true
? AppLocalizations.of(context).remove_from_spam
: AppLocalizations.of(context).mark_as_spam,
onTapCallback: () => controller.handleEmailAction(
context,
email,
currentMailbox?.isSpam == true ? EmailActionType.unSpam : EmailActionType.moveToSpam)
);
}
Widget _quickCreatingRulePopupItemAction(BuildContext context, PresentationEmail email) {
return _popupMenuItem(
icon: imagePaths.icQuickCreatingRule,
title: AppLocalizations.of(context).quickCreatingRule,
onTapCallback: () => controller.quickCreatingRule(context, email.from!.first)
);
}
Widget _popupMenuItem({
required String icon,
required String title,
Function()? onTapCallback
}) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTapCallback,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SizedBox(
width: 383,
height: 56,
child: Row(children: [
SvgPicture.asset(
currentMailbox?.isSpam == true
? imagePaths.icNotSpam
: imagePaths.icMailboxSpam,
width: 24,
height: 24,
color: AppColor.colorTextButton,
fit: BoxFit.fill),
const SizedBox(width: 12),
Expanded(child: Text(
currentMailbox?.isSpam == true
? AppLocalizations.of(context).remove_from_spam
: AppLocalizations.of(context).mark_as_spam,
style: const TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500)
)),
])
width: 300,
height: 44,
child: Row(children: [
SvgPicture.asset(
icon,
width: 20,
height: 20,
color: AppColor.colorTextButton,
fit: BoxFit.fill),
const SizedBox(width: 12),
Expanded(child: Text(
title,
style: const TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.normal)
)),
])
),
)
),
);
}
}
@@ -11,6 +11,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
typedef OnCloseBottomSheetAction = void Function();
typedef OnCopyEmailAddressBottomSheetAction = void Function(EmailAddress);
typedef OnComposeEmailBottomSheetAction = void Function(EmailAddress);
typedef OnQuickCreatingRuleEmailBottomSheetAction = void Function(EmailAddress);
class EmailAddressBottomSheetBuilder {
@@ -21,6 +22,7 @@ class EmailAddressBottomSheetBuilder {
OnCloseBottomSheetAction? _onCloseBottomSheetAction;
OnCopyEmailAddressBottomSheetAction? _onCopyEmailAddressAction;
OnComposeEmailBottomSheetAction? _onComposeEmailAction;
OnQuickCreatingRuleEmailBottomSheetAction? _creatingRuleEmailBottomSheetAction;
EmailAddressBottomSheetBuilder(
this._context,
@@ -40,6 +42,10 @@ class EmailAddressBottomSheetBuilder {
_onComposeEmailAction = onComposeEmailAction;
}
void addOnQuickCreatingRuleEmailBottomSheetAction(OnQuickCreatingRuleEmailBottomSheetAction creatingRuleEmailBottomSheetAction) {
_creatingRuleEmailBottomSheetAction = creatingRuleEmailBottomSheetAction;
}
RoundedRectangleBorder _shape() {
return const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
@@ -132,28 +138,54 @@ class EmailAddressBottomSheetBuilder {
onPressed: () => _onCopyEmailAddressAction?.call(_emailAddress)
)
),
SizedBox(height: _emailAddress.displayName.isNotEmpty ? 100 : 130),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 20),
padding: const EdgeInsets.only(left: 24, right: 24, bottom: 12),
child: SizedBox(
key: const Key('quick_creating_rule_email_button'),
width: double.infinity,
height: 44,
child: TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorTextButton),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorItemEmailSelectedDesktop),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
width: 0,
color: AppColor.colorItemEmailSelectedDesktop)))),
child: Text(
AppLocalizations.of(_context).quickCreatingRule,
style: const TextStyle(
fontSize: 17,
color: AppColor.colorTextButton,
fontWeight: FontWeight.w500)),
onPressed: () => _creatingRuleEmailBottomSheetAction?.call(_emailAddress)),
)
),
Padding(
padding: const EdgeInsets.only(left: 24, right: 24, bottom: 24),
child: SizedBox(
key: const Key('compose_email_button'),
width: double.infinity,
height: 48,
child: ElevatedButton(
height: 44,
child: TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => Colors.white),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorTextButton),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
width: 0,
color: AppColor.colorTextButton)))),
child: Text(
AppLocalizations.of(_context).compose_email,
style: const TextStyle(
fontSize: 16,
fontSize: 17,
color: Colors.white,
fontWeight: FontWeight.w500)),
onPressed: () => _onComposeEmailAction?.call(_emailAddress)),
@@ -10,6 +10,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
typedef OnCloseDialogAction = void Function();
typedef OnCopyEmailAddressDialogAction = void Function(EmailAddress);
typedef OnComposeEmailDialogAction = void Function(EmailAddress);
typedef OnQuickCreatingRuleEmailDialogAction = void Function(EmailAddress);
class EmailAddressDialogBuilder extends StatelessWidget {
@@ -17,6 +18,7 @@ class EmailAddressDialogBuilder extends StatelessWidget {
final OnCloseDialogAction? onCloseDialogAction;
final OnCopyEmailAddressDialogAction? onCopyEmailAddressAction;
final OnComposeEmailDialogAction? onComposeEmailAction;
final OnQuickCreatingRuleEmailDialogAction? onQuickCreatingRuleEmailDialogAction;
const EmailAddressDialogBuilder(
this._emailAddress, {
@@ -24,6 +26,7 @@ class EmailAddressDialogBuilder extends StatelessWidget {
this.onCloseDialogAction,
this.onCopyEmailAddressAction,
this.onComposeEmailAction,
this.onQuickCreatingRuleEmailDialogAction,
}) : super(key: key);
@override
@@ -43,7 +46,8 @@ class EmailAddressDialogBuilder extends StatelessWidget {
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(16))),
child: Wrap(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerRight,
@@ -115,28 +119,54 @@ class EmailAddressDialogBuilder extends StatelessWidget {
onPressed: () => onCopyEmailAddressAction?.call(_emailAddress)
)
))),
SizedBox(height: _emailAddress.displayName.isNotEmpty ? 100 : 130),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 20),
padding: const EdgeInsets.only(left: 24, right: 24, bottom: 12),
child: SizedBox(
key: const Key('quick_creating_rule_email_button'),
width: double.infinity,
height: 44,
child: TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorTextButton),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorItemEmailSelectedDesktop),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
width: 0,
color: AppColor.colorItemEmailSelectedDesktop)))),
child: Text(
AppLocalizations.of(context).quickCreatingRule,
style: const TextStyle(
fontSize: 17,
color: AppColor.colorTextButton,
fontWeight: FontWeight.w500)),
onPressed: () => onQuickCreatingRuleEmailDialogAction?.call(_emailAddress)),
)
),
Padding(
padding: const EdgeInsets.only(left: 24, right: 24, bottom: 24),
child: SizedBox(
key: const Key('compose_email_button'),
width: double.infinity,
height: 48,
child: ElevatedButton(
height: 44,
child: TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => Colors.white),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => AppColor.colorTextButton),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
width: 0,
color: AppColor.colorTextButton)))),
child: Text(
AppLocalizations.of(context).compose_email,
style: const TextStyle(
fontSize: 16,
fontSize: 17,
color: Colors.white,
fontWeight: FontWeight.w500)),
onPressed: () => onComposeEmailAction?.call(_emailAddress)),