Fix validate email sending dialog position

(cherry picked from commit 8d873b53843a971d3e8e5eb0f80f97f6c5587454)
This commit is contained in:
dab246
2023-12-05 18:55:21 +07:00
committed by Dat H. Pham
parent d97457d42c
commit affc1a4ee7
5 changed files with 96 additions and 82 deletions
@@ -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))
]
))
]
)
);
}
@@ -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)
@@ -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);
@@ -60,7 +60,7 @@ class ComposerView extends GetWidget<ComposerController> {
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<ComposerController> {
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<ComposerController> {
TabletBottomBarComposerWidget(
deleteComposerAction: () => controller.closeComposer(context),
saveToDraftAction: () => controller.saveToDraftAction(context),
sendMessageAction: () => controller.sendEmailAction(context),
sendMessageAction: () => controller.validateInformationBeforeSending(context),
requestReadReceiptAction: (position) {
controller.openPopupMenuAction(
context,
@@ -47,7 +47,7 @@ class ComposerView extends GetWidget<ComposerController> {
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<ComposerController> {
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<ComposerController> {
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,