TF-2667 Show confirm dialog when click close composer
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -27,7 +27,7 @@ class ConfirmDialogBuilder {
|
|||||||
EdgeInsets? _paddingContent;
|
EdgeInsets? _paddingContent;
|
||||||
EdgeInsets? _paddingButton;
|
EdgeInsets? _paddingButton;
|
||||||
EdgeInsets? _outsideDialogPadding;
|
EdgeInsets? _outsideDialogPadding;
|
||||||
EdgeInsets? _marginIcon;
|
EdgeInsetsGeometry? _marginIcon;
|
||||||
EdgeInsets? _margin;
|
EdgeInsets? _margin;
|
||||||
double? _widthDialog;
|
double? _widthDialog;
|
||||||
double? _heightDialog;
|
double? _heightDialog;
|
||||||
@@ -107,7 +107,7 @@ class ConfirmDialogBuilder {
|
|||||||
_paddingButton = value;
|
_paddingButton = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void marginIcon(EdgeInsets? value) {
|
void marginIcon(EdgeInsetsGeometry? value) {
|
||||||
_marginIcon = value;
|
_marginIcon = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ mixin MessageDialogActionMixin {
|
|||||||
{
|
{
|
||||||
Function? onConfirmAction,
|
Function? onConfirmAction,
|
||||||
Function? onCancelAction,
|
Function? onCancelAction,
|
||||||
|
OnCloseButtonAction? onCloseButtonAction,
|
||||||
String? title,
|
String? title,
|
||||||
String? cancelTitle,
|
String? cancelTitle,
|
||||||
bool hasCancelButton = true,
|
bool hasCancelButton = true,
|
||||||
@@ -28,6 +29,7 @@ mixin MessageDialogActionMixin {
|
|||||||
TextStyle? cancelStyle,
|
TextStyle? cancelStyle,
|
||||||
Color? actionButtonColor,
|
Color? actionButtonColor,
|
||||||
Color? cancelButtonColor,
|
Color? cancelButtonColor,
|
||||||
|
EdgeInsetsGeometry? marginIcon,
|
||||||
}
|
}
|
||||||
) async {
|
) async {
|
||||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
@@ -43,7 +45,7 @@ mixin MessageDialogActionMixin {
|
|||||||
..addIcon(icon)
|
..addIcon(icon)
|
||||||
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
||||||
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
||||||
..marginIcon(icon != null ? const EdgeInsets.only(top: 24) : null)
|
..marginIcon(icon != null ? (marginIcon ?? const EdgeInsets.only(top: 24)) : null)
|
||||||
..paddingTitle(icon != null
|
..paddingTitle(icon != null
|
||||||
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
||||||
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
||||||
@@ -66,6 +68,7 @@ mixin MessageDialogActionMixin {
|
|||||||
onCancelAction?.call();
|
onCancelAction?.call();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
..onCloseButtonAction(onCloseButtonAction)
|
||||||
).build()
|
).build()
|
||||||
),
|
),
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
@@ -111,7 +114,7 @@ mixin MessageDialogActionMixin {
|
|||||||
onCancelAction?.call();
|
onCancelAction?.call();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
..onCloseButtonAction(() => popBack()))
|
..onCloseButtonAction(onCloseButtonAction ?? () => popBack()))
|
||||||
.build()
|
.build()
|
||||||
),
|
),
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
@@ -171,7 +174,7 @@ mixin MessageDialogActionMixin {
|
|||||||
onCancelAction?.call();
|
onCancelAction?.call();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
..onCloseButtonAction(() => popBack()))
|
..onCloseButtonAction(onCloseButtonAction ?? () => popBack()))
|
||||||
.build()
|
.build()
|
||||||
),
|
),
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
|
|||||||
@@ -428,7 +428,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onCreatedMobileEditorAction(BuildContext context, HtmlEditorApi editorApi, String? content) {
|
void onCreatedMobileEditorAction(BuildContext context, HtmlEditorApi editorApi, String? content) {
|
||||||
initTextEditor(content);
|
if (identitySelected.value != null) {
|
||||||
|
initTextEditor(content);
|
||||||
|
}
|
||||||
richTextMobileTabletController.htmlEditorApi = editorApi;
|
richTextMobileTabletController.htmlEditorApi = editorApi;
|
||||||
keyboardRichTextController.onCreateHTMLEditor(
|
keyboardRichTextController.onCreateHTMLEditor(
|
||||||
editorApi,
|
editorApi,
|
||||||
@@ -982,7 +984,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
alignCenter: true,
|
alignCenter: true,
|
||||||
onConfirmAction: () {
|
onConfirmAction: () {
|
||||||
_sendButtonState = ButtonState.enabled;
|
_sendButtonState = ButtonState.enabled;
|
||||||
popBack();
|
|
||||||
_autoFocusFieldWhenLauncher();
|
_autoFocusFieldWhenLauncher();
|
||||||
},
|
},
|
||||||
onCancelAction: () async {
|
onCancelAction: () async {
|
||||||
@@ -1170,8 +1171,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
PresentationEmail? presentationEmail,
|
PresentationEmail? presentationEmail,
|
||||||
Role? mailboxRole,
|
Role? mailboxRole,
|
||||||
}) async {
|
}) async {
|
||||||
final newEmailBody = await _getEmailBodyText(context, asDrafts: true);
|
final newEmailBody = await _getContentInEditor();
|
||||||
final oldEmailBody = _initTextEditor ?? '';
|
final oldEmailBody = _initTextEditor ?? '';
|
||||||
|
log('ComposerController::_validateEmailChange: newEmailBody = $newEmailBody | oldEmailBody = $oldEmailBody');
|
||||||
final isEmailBodyChanged = !oldEmailBody.trim().isSame(newEmailBody.trim());
|
final isEmailBodyChanged = !oldEmailBody.trim().isSame(newEmailBody.trim());
|
||||||
|
|
||||||
final newEmailSubject = subjectEmail.value ?? '';
|
final newEmailSubject = subjectEmail.value ?? '';
|
||||||
@@ -1936,7 +1938,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController.htmlEditorApi;
|
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController.htmlEditorApi;
|
||||||
|
|
||||||
void onChangeTextEditorWeb(String? text) {
|
void onChangeTextEditorWeb(String? text) {
|
||||||
initTextEditor(text);
|
if (identitySelected.value != null) {
|
||||||
|
initTextEditor(text);
|
||||||
|
}
|
||||||
_textEditorWeb = text;
|
_textEditorWeb = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2053,19 +2057,92 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
log('ComposerController::handleClickCloseComposer: _closeComposerButtonState = disabled');
|
log('ComposerController::handleClickCloseComposer: _closeComposerButtonState = disabled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_isEmailBodyLoaded) {
|
_closeComposerButtonState = ButtonState.disabled;
|
||||||
log('ComposerController::handleClickCloseComposer: _isEmailBodyLoaded = false');
|
|
||||||
|
if (composerArguments.value == null) {
|
||||||
|
log('ComposerController::handleClickCloseComposer: ARGUMENTS is NULL');
|
||||||
clearFocus(context);
|
clearFocus(context);
|
||||||
_closeComposerAction();
|
_closeComposerAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_closeComposerButtonState = ButtonState.disabled;
|
final isChanged = await _validateEmailChange(
|
||||||
clearFocus(context);
|
context: context,
|
||||||
final draftArgs = await _generateSaveAsDraftsArguments(context);
|
emailActionType: composerArguments.value!.emailActionType,
|
||||||
_closeComposerAction(result: draftArgs);
|
presentationEmail: composerArguments.value!.presentationEmail,
|
||||||
_closeComposerButtonState = ButtonState.enabled;
|
mailboxRole: composerArguments.value!.mailboxRole
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isChanged && context.mounted) {
|
||||||
|
clearFocus(context);
|
||||||
|
_showConfirmDialogSaveMessage(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_isEmailBodyLoaded && context.mounted) {
|
||||||
|
log('ComposerController::handleClickCloseComposer: EDITOR NOT LOADED');
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
clearFocus(context);
|
||||||
|
_closeComposerAction();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
clearFocus(context);
|
||||||
|
_closeComposerAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showConfirmDialogSaveMessage(BuildContext context) {
|
||||||
|
showConfirmDialogAction(
|
||||||
|
context,
|
||||||
|
title: AppLocalizations.of(context).saveMessage.capitalizeFirstEach,
|
||||||
|
AppLocalizations.of(context).warningMessageWhenClickCloseComposer,
|
||||||
|
AppLocalizations.of(context).save,
|
||||||
|
cancelTitle: AppLocalizations.of(context).discardChanges,
|
||||||
|
alignCenter: true,
|
||||||
|
onConfirmAction: () {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
},
|
||||||
|
onCancelAction: () async {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
await Future.delayed(
|
||||||
|
const Duration(milliseconds: 100),
|
||||||
|
_closeComposerAction
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onCloseButtonAction: () {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
popBack();
|
||||||
|
_autoFocusFieldWhenLauncher();
|
||||||
|
},
|
||||||
|
marginIcon: EdgeInsets.zero,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
imagePaths.icQuotasWarning,
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
colorFilter: AppColor.colorBackgroundQuotasWarning.asFilter(),
|
||||||
|
),
|
||||||
|
titleStyle: Theme.of(context).textTheme.labelLarge?.copyWith(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black
|
||||||
|
),
|
||||||
|
messageStyle: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
color: AppColor.colorTextBody
|
||||||
|
),
|
||||||
|
actionStyle: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
fontSize: 17,
|
||||||
|
color: Colors.white
|
||||||
|
),
|
||||||
|
cancelStyle: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
fontSize: 17,
|
||||||
|
color: Colors.black
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAlwaysReadReceiptSetting() {
|
void _getAlwaysReadReceiptSetting() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:core/presentation/extensions/capitalize_extension.dart';
|
import 'package:core/presentation/extensions/capitalize_extension.dart';
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
@@ -7,6 +8,7 @@ import 'package:core/presentation/state/success.dart';
|
|||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart' as dartz;
|
import 'package:dartz/dartz.dart' as dartz;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/usecases/create_new_and_send_email_interactor.dart';
|
import 'package:tmail_ui_user/features/composer/domain/usecases/create_new_and_send_email_interactor.dart';
|
||||||
@@ -82,7 +84,7 @@ class _SendingMessageDialogViewState extends State<SendingMessageDialogView> {
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
width: 400,
|
width: min(context.width, 400),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2024-03-06T00:47:30.311599",
|
"@@last_modified": "2024-03-06T01:50:29.250412",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -3803,5 +3803,23 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"saveMessage": "Save message",
|
||||||
|
"@saveMessage": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"discardChanges": "Discard changes",
|
||||||
|
"@discardChanges": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"warningMessageWhenClickCloseComposer": "Save this message to your drafts folder and close composer?",
|
||||||
|
"@warningMessageWhenClickCloseComposer": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3974,4 +3974,22 @@ class AppLocalizations {
|
|||||||
'Close anyway',
|
'Close anyway',
|
||||||
name: 'closeAnyway');
|
name: 'closeAnyway');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get saveMessage {
|
||||||
|
return Intl.message(
|
||||||
|
'Save message',
|
||||||
|
name: 'saveMessage');
|
||||||
|
}
|
||||||
|
|
||||||
|
String get discardChanges {
|
||||||
|
return Intl.message(
|
||||||
|
'Discard changes',
|
||||||
|
name: 'discardChanges');
|
||||||
|
}
|
||||||
|
|
||||||
|
String get warningMessageWhenClickCloseComposer {
|
||||||
|
return Intl.message(
|
||||||
|
'Save this message to your drafts folder and close composer?',
|
||||||
|
name: 'warningMessageWhenClickCloseComposer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user