From affc1a4ee70609b912a11df8a77dc4c33ba380af Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 5 Dec 2023 18:55:21 +0700 Subject: [PATCH] Fix validate email sending dialog position (cherry picked from commit 8d873b53843a971d3e8e5eb0f80f97f6c5587454) --- .../dialog/confirmation_dialog_builder.dart | 150 +++++++++--------- .../mixin/message_dialog_action_mixin.dart | 8 +- .../presentation/composer_controller.dart | 8 +- .../composer/presentation/composer_view.dart | 6 +- .../presentation/composer_view_web.dart | 6 +- 5 files changed, 96 insertions(+), 82 deletions(-) diff --git a/core/lib/presentation/views/dialog/confirmation_dialog_builder.dart b/core/lib/presentation/views/dialog/confirmation_dialog_builder.dart index 556a94d50..ad9fe6fdd 100644 --- a/core/lib/presentation/views/dialog/confirmation_dialog_builder.dart +++ b/core/lib/presentation/views/dialog/confirmation_dialog_builder.dart @@ -155,7 +155,7 @@ class ConfirmDialogBuilder { return Dialog( key: _key, shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(16))), + borderRadius: BorderRadius.all(Radius.circular(18))), insetPadding: _outsideDialogPadding ?? const EdgeInsets.symmetric( horizontal: 24.0, vertical: 16.0), @@ -171,83 +171,89 @@ class ConfirmDialogBuilder { width: _widthDialog ?? 400, height: _heightDialog, decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(16))), + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(18))), margin: _margin, - child: Wrap(children: [ - if (_onCloseButtonAction != null) - Align( - alignment: Alignment.centerRight, - child: Padding( - padding: const EdgeInsets.only(top: 8, right: 8), - child: buildIconWeb( - icon: SvgPicture.asset(_imagePath.icCircleClose, fit: BoxFit.fill), - onTap: () => _onCloseButtonAction?.call()) - )), - if (_iconWidget != null) - Container( - margin: _marginIcon ?? EdgeInsets.zero, - alignment: Alignment.center, - child: _iconWidget, - ), - if (_title.isNotEmpty) - Padding( - padding: _paddingTitle ?? const EdgeInsets.only(top: 12), - child: Center( - child: Text( - _title, - textAlign: TextAlign.center, - style: _styleTitle ?? const TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500) - ) + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (_onCloseButtonAction != null) + Align( + alignment: AlignmentDirectional.centerEnd, + child: TMailButtonWidget.fromIcon( + icon: _imagePath.icCircleClose, + iconSize: 30, + padding: const EdgeInsets.all(3), + backgroundColor: Colors.transparent, + margin: const EdgeInsetsDirectional.only(top: 16, end: 16), + onTapActionCallback: _onCloseButtonAction ) - ), - if (_content.isNotEmpty) - Padding( - padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24), - child: Center( - child: Text(_content, - textAlign: TextAlign.center, - style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog) - ), ), - ) - else if (listTextSpan != null) - Padding( - padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24), - child: Center( - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog), - children: listTextSpan + if (_iconWidget != null) + Container( + margin: _marginIcon ?? EdgeInsets.zero, + alignment: Alignment.center, + child: _iconWidget, + ), + if (_title.isNotEmpty) + Padding( + padding: _paddingTitle ?? const EdgeInsets.only(top: 12), + child: Center( + child: Text( + _title, + textAlign: TextAlign.center, + style: _styleTitle ?? const TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500) + ) + ) + ), + if (_content.isNotEmpty) + Padding( + padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24), + child: Center( + child: Text(_content, + textAlign: TextAlign.center, + style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog) + ), + ), + ) + else if (listTextSpan != null) + Padding( + padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24), + child: Center( + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog), + children: listTextSpan + ), ), ), ), - ), - Padding( - padding: _paddingButton ?? const EdgeInsets.only(bottom: 16, left: 16, right: 16), - child: Row( - children: [ - if (_cancelText.isNotEmpty) - Expanded(child: _buildButton( - name: _cancelText, - bgColor: _colorCancelButton, - radius: _radiusButton, - height: heightButton, - textStyle: _styleTextCancelButton, - action: _onCancelButtonAction)), - if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) const SizedBox(width: 16), - if (_confirmText.isNotEmpty) - Expanded(child: _buildButton( - name: _confirmText, - bgColor: _colorConfirmButton, - radius: _radiusButton, - height: heightButton, - textStyle: _styleTextConfirmButton, - action: _onConfirmButtonAction)) - ] - )) - ]) + Padding( + padding: _paddingButton ?? const EdgeInsets.only(bottom: 16, left: 16, right: 16), + child: Row( + children: [ + if (_cancelText.isNotEmpty) + Expanded(child: _buildButton( + name: _cancelText, + bgColor: _colorCancelButton, + radius: _radiusButton, + height: heightButton, + textStyle: _styleTextCancelButton, + action: _onCancelButtonAction)), + if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) const SizedBox(width: 16), + if (_confirmText.isNotEmpty) + Expanded(child: _buildButton( + name: _confirmText, + bgColor: _colorConfirmButton, + radius: _radiusButton, + height: heightButton, + textStyle: _styleTextConfirmButton, + action: _onConfirmButtonAction)) + ] + )) + ] + ) ); } diff --git a/lib/features/base/mixin/message_dialog_action_mixin.dart b/lib/features/base/mixin/message_dialog_action_mixin.dart index e096e2e66..f84dbd596 100644 --- a/lib/features/base/mixin/message_dialog_action_mixin.dart +++ b/lib/features/base/mixin/message_dialog_action_mixin.dart @@ -77,8 +77,7 @@ mixin MessageDialogActionMixin { ..title(title ?? '') ..content(message) ..addIcon(icon) - ..margin(const EdgeInsets.symmetric(vertical: 42, horizontal: 16)) - ..marginIcon(icon != null ? const EdgeInsets.only(top: 24) : null) + ..margin(const EdgeInsets.only(bottom: 42)) ..widthDialog(responsiveUtils.getSizeScreenWidth(context)) ..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton) ..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton) @@ -108,6 +107,11 @@ mixin MessageDialogActionMixin { barrierColor: AppColor.colorDefaultCupertinoActionSheet, backgroundColor: Colors.transparent, enableDrag: true, + constraints: BoxConstraints( + maxWidth: responsiveUtils.getSizeScreenShortestSide(context) - 16 + ), + useSafeArea: true, + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(18))), ); } else { return (ConfirmationDialogActionSheetBuilder(context, listTextSpan: listTextSpan) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index f84e97e38..3037a8447 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -815,7 +815,7 @@ class ComposerController extends BaseController { return 'Team-Mail/${mailboxDashBoardController.appInformation.value?.version} $userAgent'; } - void sendEmailAction(BuildContext context) async { + void validateInformationBeforeSending(BuildContext context) async { if (isSendEmailLoading.isTrue) { return; } @@ -838,7 +838,8 @@ class ComposerController extends BaseController { onConfirmAction: () => isSendEmailLoading.value = false, title: AppLocalizations.of(context).sending_failed, icon: SvgPicture.asset(imagePaths.icSendToastError, fit: BoxFit.fill), - hasCancelButton: false + hasCancelButton: false, + showAsBottomSheet: true, ).whenComplete(() => isSendEmailLoading.value = false); return; } @@ -857,6 +858,7 @@ class ComposerController extends BaseController { bccAddressExpandMode.value = ExpandMode.EXPAND; isSendEmailLoading.value = false; }, + showAsBottomSheet: true, title: AppLocalizations.of(context).sending_failed, icon: SvgPicture.asset(imagePaths.icSendToastError, fit: BoxFit.fill), hasCancelButton: false @@ -871,6 +873,7 @@ class ComposerController extends BaseController { onConfirmAction: () => _handleSendMessages(context), onCancelAction: () => isSendEmailLoading.value = false, title: AppLocalizations.of(context).empty_subject, + showAsBottomSheet: true, icon: SvgPicture.asset(imagePaths.icEmpty, fit: BoxFit.fill), ).whenComplete(() => isSendEmailLoading.value = false); return; @@ -883,6 +886,7 @@ class ComposerController extends BaseController { AppLocalizations.of(context).got_it, onConfirmAction: () => isSendEmailLoading.value = false, title: AppLocalizations.of(context).sending_failed, + showAsBottomSheet: true, icon: SvgPicture.asset(imagePaths.icSendToastError, fit: BoxFit.fill), hasCancelButton: false ).whenComplete(() => isSendEmailLoading.value = false); diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index 12101a8d4..0183896af 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -60,7 +60,7 @@ class ComposerView extends GetWidget { Obx(() => LandscapeAppBarComposerWidget( isSendButtonEnabled: controller.isEnableEmailSendButton.value, onCloseViewAction: () => controller.saveToDraftAndClose(context), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), openContextMenuAction: (position) { controller.openPopupMenuAction( context, @@ -74,7 +74,7 @@ class ComposerView extends GetWidget { Obx(() => AppBarComposerWidget( isSendButtonEnabled: controller.isEnableEmailSendButton.value, onCloseViewAction: () => controller.saveToDraftAndClose(context), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), openContextMenuAction: (position) { controller.openPopupMenuAction( context, @@ -362,7 +362,7 @@ class ComposerView extends GetWidget { TabletBottomBarComposerWidget( deleteComposerAction: () => controller.closeComposer(context), saveToDraftAction: () => controller.saveToDraftAction(context), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), requestReadReceiptAction: (position) { controller.openPopupMenuAction( context, diff --git a/lib/features/composer/presentation/composer_view_web.dart b/lib/features/composer/presentation/composer_view_web.dart index f4ed53e8f..147ce8954 100644 --- a/lib/features/composer/presentation/composer_view_web.dart +++ b/lib/features/composer/presentation/composer_view_web.dart @@ -47,7 +47,7 @@ class ComposerView extends GetWidget { onCloseViewAction: () => controller.saveToDraftAndClose(context), attachFileAction: () => controller.openFilePickerByType(context, FileType.any), insertImageAction: () => controller.insertImage(context, constraints.maxWidth), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), openContextMenuAction: (position) { controller.openPopupMenuAction( context, @@ -441,7 +441,7 @@ class ComposerView extends GetWidget { showCodeViewAction: controller.richTextWebController.toggleCodeView, deleteComposerAction: () => controller.closeComposer(context), saveToDraftAction: () => controller.saveToDraftAction(context), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), requestReadReceiptAction: (position) { controller.openPopupMenuAction( context, @@ -657,7 +657,7 @@ class ComposerView extends GetWidget { showCodeViewAction: controller.richTextWebController.toggleCodeView, deleteComposerAction: () => controller.closeComposer(context), saveToDraftAction: () => controller.saveToDraftAction(context), - sendMessageAction: () => controller.sendEmailAction(context), + sendMessageAction: () => controller.validateInformationBeforeSending(context), requestReadReceiptAction: (position) { controller.openPopupMenuAction( context,