Only create and use the correct rich text controller for each platform
This commit is contained in:
@@ -214,9 +214,12 @@ class ComposerBindings extends BaseBindings {
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => RichTextMobileTabletController());
|
||||
if (PlatformInfo.isWeb) {
|
||||
Get.lazyPut(() => RichTextWebController());
|
||||
} else {
|
||||
Get.lazyPut(() => RichTextMobileTabletController());
|
||||
}
|
||||
Get.lazyPut(() => UploadController(Get.find<UploadAttachmentInteractor>()));
|
||||
Get.lazyPut(() => RichTextWebController());
|
||||
Get.lazyPut(() => ComposerController(
|
||||
Get.find<LocalFilePickerInteractor>(),
|
||||
Get.find<LocalImagePickerInteractor>(),
|
||||
@@ -225,7 +228,6 @@ class ComposerBindings extends BaseBindings {
|
||||
Get.find<UploadController>(),
|
||||
Get.find<RemoveComposerCacheOnWebInteractor>(),
|
||||
Get.find<SaveComposerCacheOnWebInteractor>(),
|
||||
Get.find<RichTextWebController>(),
|
||||
Get.find<DownloadImageAsBase64Interactor>(),
|
||||
Get.find<TransformHtmlEmailContentInteractor>(),
|
||||
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
|
||||
@@ -235,9 +237,12 @@ class ComposerBindings extends BaseBindings {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
if (PlatformInfo.isWeb) {
|
||||
Get.delete<RichTextWebController>();
|
||||
} else {
|
||||
Get.delete<RichTextMobileTabletController>();
|
||||
}
|
||||
Get.delete<UploadController>();
|
||||
Get.delete<RichTextWebController>();
|
||||
Get.delete<RichTextMobileTabletController>();
|
||||
Get.delete<ComposerController>();
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,6 @@ import 'package:universal_html/html.dart' as html;
|
||||
class ComposerController extends BaseController with DragDropFileMixin {
|
||||
|
||||
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
||||
final richTextMobileTabletController = Get.find<RichTextMobileTabletController>();
|
||||
final networkConnectionController = Get.find<NetworkConnectionController>();
|
||||
final _dynamicUrlInterceptors = Get.find<DynamicUrlInterceptors>();
|
||||
|
||||
@@ -121,7 +120,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
final UploadController uploadController;
|
||||
final RemoveComposerCacheOnWebInteractor _removeComposerCacheOnWebInteractor;
|
||||
final SaveComposerCacheOnWebInteractor _saveComposerCacheOnWebInteractor;
|
||||
final RichTextWebController richTextWebController;
|
||||
final DownloadImageAsBase64Interactor _downloadImageAsBase64Interactor;
|
||||
final TransformHtmlEmailContentInteractor _transformHtmlEmailContentInteractor;
|
||||
final GetAlwaysReadReceiptSettingInteractor _getAlwaysReadReceiptSettingInteractor;
|
||||
@@ -165,7 +163,8 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
StreamSubscription<html.Event>? _subscriptionOnDragLeave;
|
||||
StreamSubscription<html.Event>? _subscriptionOnDrop;
|
||||
|
||||
final RichTextController keyboardRichTextController = RichTextController();
|
||||
RichTextMobileTabletController? richTextMobileTabletController;
|
||||
RichTextWebController? richTextWebController;
|
||||
|
||||
final ScrollController scrollController = ScrollController();
|
||||
final ScrollController scrollControllerEmailAddress = ScrollController();
|
||||
@@ -194,7 +193,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
this.uploadController,
|
||||
this._removeComposerCacheOnWebInteractor,
|
||||
this._saveComposerCacheOnWebInteractor,
|
||||
this.richTextWebController,
|
||||
this._downloadImageAsBase64Interactor,
|
||||
this._transformHtmlEmailContentInteractor,
|
||||
this._getAlwaysReadReceiptSettingInteractor,
|
||||
@@ -205,14 +203,17 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
createFocusNodeInput();
|
||||
scrollControllerEmailAddress.addListener(_scrollControllerEmailAddressListener);
|
||||
_listenStreamEvent();
|
||||
if (PlatformInfo.isWeb) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_listenBrowserTabRefresh();
|
||||
});
|
||||
richTextWebController = getBinding<RichTextWebController>();
|
||||
} else {
|
||||
richTextMobileTabletController = getBinding<RichTextMobileTabletController>();
|
||||
}
|
||||
createFocusNodeInput();
|
||||
scrollControllerEmailAddress.addListener(_scrollControllerEmailAddressListener);
|
||||
_listenStreamEvent();
|
||||
_getAlwaysReadReceiptSetting();
|
||||
}
|
||||
|
||||
@@ -239,6 +240,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
_subscriptionOnDragOver?.cancel();
|
||||
_subscriptionOnDragLeave?.cancel();
|
||||
_subscriptionOnDrop?.cancel();
|
||||
subjectEmailInputFocusNode?.removeListener(_subjectEmailInputFocusListener);
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -266,7 +268,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
bccEmailAddressController.dispose();
|
||||
uploadInlineImageWorker.dispose();
|
||||
dashboardViewStateWorker.dispose();
|
||||
keyboardRichTextController.dispose();
|
||||
scrollController.dispose();
|
||||
scrollControllerEmailAddress.removeListener(_scrollControllerEmailAddressListener);
|
||||
scrollControllerEmailAddress.dispose();
|
||||
@@ -295,9 +296,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
} else if (success is DownloadImageAsBase64Success) {
|
||||
final inlineImage = InlineImage(fileInfo: success.fileInfo, base64Uri: success.base64Uri);
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController.insertImage(inlineImage);
|
||||
richTextWebController?.insertImage(inlineImage);
|
||||
} else {
|
||||
richTextMobileTabletController.insertImage(inlineImage);
|
||||
richTextMobileTabletController?.insertImage(inlineImage);
|
||||
}
|
||||
maxWithEditor = null;
|
||||
} else if (success is GetAlwaysReadReceiptSettingSuccess) {
|
||||
@@ -414,15 +415,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
|
||||
void createFocusNodeInput() {
|
||||
toAddressFocusNode = FocusNode();
|
||||
subjectEmailInputFocusNode = FocusNode(
|
||||
onKey: (focus, event) {
|
||||
if (event is RawKeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
richTextWebController.editorController.setFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
);
|
||||
ccAddressFocusNode = FocusNode();
|
||||
bccAddressFocusNode = FocusNode();
|
||||
searchIdentitiesFocusNode = FocusNode();
|
||||
@@ -430,24 +422,36 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
ccAddressFocusNodeKeyboard = FocusNode();
|
||||
bccAddressFocusNodeKeyboard = FocusNode();
|
||||
|
||||
subjectEmailInputFocusNode?.addListener(() {
|
||||
log('ComposerController::createFocusNodeInput():subjectEmailInputFocusNode: ${subjectEmailInputFocusNode?.hasFocus}');
|
||||
if (subjectEmailInputFocusNode?.hasFocus == true) {
|
||||
if (PlatformInfo.isMobile) {
|
||||
htmlEditorApi?.unfocus();
|
||||
}
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
subjectEmailInputFocusNode = FocusNode(
|
||||
onKey: PlatformInfo.isWeb ? _subjectEmailInputOnKeyListener : null
|
||||
);
|
||||
subjectEmailInputFocusNode?.addListener(_subjectEmailInputFocusListener);
|
||||
}
|
||||
|
||||
void _subjectEmailInputFocusListener() {
|
||||
if (subjectEmailInputFocusNode?.hasFocus == true) {
|
||||
if (PlatformInfo.isMobile) {
|
||||
htmlEditorApi?.unfocus();
|
||||
}
|
||||
});
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
}
|
||||
}
|
||||
|
||||
KeyEventResult _subjectEmailInputOnKeyListener(FocusNode node, RawKeyEvent event) {
|
||||
if (event is RawKeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
richTextWebController?.editorController.setFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
void onCreatedMobileEditorAction(BuildContext context, HtmlEditorApi editorApi, String? content) {
|
||||
if (identitySelected.value != null) {
|
||||
initTextEditor(content);
|
||||
}
|
||||
richTextMobileTabletController.htmlEditorApi = editorApi;
|
||||
keyboardRichTextController.onCreateHTMLEditor(
|
||||
richTextMobileTabletController?.htmlEditorApi = editorApi;
|
||||
richTextMobileTabletController?.richTextController.onCreateHTMLEditor(
|
||||
editorApi,
|
||||
onEnterKeyDown: _onEnterKeyDown,
|
||||
context: context,
|
||||
@@ -1325,7 +1329,10 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
}
|
||||
|
||||
void displayScreenTypeComposerAction(ScreenDisplayMode displayMode) async {
|
||||
_updateTextForEditor();
|
||||
if (richTextWebController != null && screenDisplayMode.value != ScreenDisplayMode.minimize) {
|
||||
final textCurrent = await richTextWebController!.editorController.getText();
|
||||
richTextWebController!.editorController.setText(textCurrent);
|
||||
}
|
||||
screenDisplayMode.value = displayMode;
|
||||
|
||||
await Future.delayed(
|
||||
@@ -1333,11 +1340,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
_autoFocusFieldWhenLauncher);
|
||||
}
|
||||
|
||||
void _updateTextForEditor() async {
|
||||
final textCurrent = await richTextWebController.editorController.getText();
|
||||
richTextWebController.editorController.setText(textCurrent);
|
||||
}
|
||||
|
||||
void deleteComposer() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
mailboxDashBoardController.closeComposerOverlay();
|
||||
@@ -1589,7 +1591,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
|
||||
Future<void> _applySignature(String signature) async {
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController.editorController.insertSignature(signature);
|
||||
richTextWebController?.editorController.insertSignature(signature);
|
||||
} else {
|
||||
await htmlEditorApi?.insertSignature(signature, allowCollapsed: false);
|
||||
}
|
||||
@@ -1598,7 +1600,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
Future<void> _removeSignature() async {
|
||||
log('ComposerController::_removeSignature():');
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController.editorController.removeSignature();
|
||||
richTextWebController?.editorController.removeSignature();
|
||||
} else {
|
||||
await htmlEditorApi?.removeSignature();
|
||||
}
|
||||
@@ -1712,7 +1714,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
} else if (subjectEmailInputController.text.isEmpty) {
|
||||
subjectEmailInputFocusNode?.requestFocus();
|
||||
} else if (PlatformInfo.isWeb) {
|
||||
richTextWebController.editorController.setFocus();
|
||||
richTextWebController?.editorController.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1725,10 +1727,10 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
void handleInitHtmlEditorWeb(String initContent) async {
|
||||
log('ComposerController::handleInitHtmlEditorWeb:');
|
||||
_isEmailBodyLoaded = true;
|
||||
richTextWebController.editorController.setFullScreen();
|
||||
richTextWebController.editorController.setOnDragDropEvent();
|
||||
richTextWebController?.editorController.setFullScreen();
|
||||
richTextWebController?.editorController.setOnDragDropEvent();
|
||||
onChangeTextEditorWeb(initContent);
|
||||
richTextWebController.setEnableCodeView();
|
||||
richTextWebController?.setEnableCodeView();
|
||||
if (identitySelected.value == null) {
|
||||
_getAllIdentities();
|
||||
} else {
|
||||
@@ -1739,8 +1741,8 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
|
||||
void handleOnFocusHtmlEditorWeb() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
richTextWebController.editorController.setFocus();
|
||||
richTextWebController.closeAllMenuPopup();
|
||||
richTextWebController?.editorController.setFocus();
|
||||
richTextWebController?.closeAllMenuPopup();
|
||||
}
|
||||
|
||||
void handleOnUnFocusHtmlEditorWeb() {
|
||||
@@ -1779,7 +1781,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
|
||||
String? get textEditorWeb => _textEditorWeb;
|
||||
|
||||
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController.htmlEditorApi;
|
||||
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController?.htmlEditorApi;
|
||||
|
||||
void onChangeTextEditorWeb(String? text) {
|
||||
if (identitySelected.value != null) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
return ResponsiveWidget(
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
mobile: MobileContainerView(
|
||||
keyboardRichTextController: controller.keyboardRichTextController,
|
||||
keyboardRichTextController: controller.richTextMobileTabletController!.richTextController,
|
||||
onCloseViewAction: () => controller.handleClickCloseComposer(context),
|
||||
onClearFocusAction: () => controller.clearFocus(context),
|
||||
onAttachFileAction: () => controller.isNetworkConnectionAvailable
|
||||
@@ -228,7 +228,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
),
|
||||
),
|
||||
tablet: TabletContainerView(
|
||||
keyboardRichTextController: controller.keyboardRichTextController,
|
||||
keyboardRichTextController: controller.richTextMobileTabletController!.richTextController,
|
||||
onCloseViewAction: () => controller.handleClickCloseComposer(context),
|
||||
onClearFocusAction: () => controller.clearFocus(context),
|
||||
onAttachFileAction: () => controller.isNetworkConnectionAvailable
|
||||
|
||||
@@ -43,9 +43,9 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Obx(() => MobileResponsiveAppBarComposerWidget(
|
||||
isCodeViewEnabled: controller.richTextWebController.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController.toggleFormattingOptions,
|
||||
isCodeViewEnabled: controller.richTextWebController!.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController!.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController!.toggleFormattingOptions,
|
||||
isSendButtonEnabled: controller.isEnableEmailSendButton.value,
|
||||
onCloseViewAction: () => controller.handleClickCloseComposer(context),
|
||||
attachFileAction: () => controller.openFilePickerByType(context, FileType.any),
|
||||
@@ -177,7 +177,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
child: Padding(
|
||||
padding: ComposerStyle.mobileEditorPadding,
|
||||
child: Obx(() => WebEditorView(
|
||||
editorController: controller.richTextWebController.editorController,
|
||||
editorController: controller.richTextWebController!.editorController,
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
currentWebContent: controller.textEditorWeb,
|
||||
@@ -186,8 +186,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onFocus: controller.handleOnFocusHtmlEditorWeb,
|
||||
onUnFocus: controller.handleOnUnFocusHtmlEditorWeb,
|
||||
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
|
||||
onEditorSettings: controller.richTextWebController.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController.onEditorTextSizeChanged,
|
||||
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
|
||||
@@ -207,9 +207,9 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
}
|
||||
}),
|
||||
Obx(() {
|
||||
if (controller.richTextWebController.isFormattingOptionsEnabled) {
|
||||
if (controller.richTextWebController!.isFormattingOptionsEnabled) {
|
||||
return ToolbarRichTextWebBuilder(
|
||||
richTextWebController: controller.richTextWebController,
|
||||
richTextWebController: controller.richTextWebController!,
|
||||
padding: ComposerStyle.richToolbarPadding,
|
||||
decoration: const BoxDecoration(
|
||||
color: ComposerStyle.richToolbarColor,
|
||||
@@ -418,7 +418,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
padding: ComposerStyle.desktopEditorPadding,
|
||||
child: Obx(() {
|
||||
return WebEditorView(
|
||||
editorController: controller.richTextWebController.editorController,
|
||||
editorController: controller.richTextWebController!.editorController,
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
currentWebContent: controller.textEditorWeb,
|
||||
@@ -427,8 +427,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onFocus: controller.handleOnFocusHtmlEditorWeb,
|
||||
onUnFocus: controller.handleOnUnFocusHtmlEditorWeb,
|
||||
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
|
||||
onEditorSettings: controller.richTextWebController.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController.onEditorTextSizeChanged,
|
||||
onEditorSettings: controller.richTextWebController?.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController?.onEditorTextSizeChanged,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
|
||||
@@ -449,9 +449,9 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
}
|
||||
}),
|
||||
Obx(() {
|
||||
if (controller.richTextWebController.isFormattingOptionsEnabled) {
|
||||
if (controller.richTextWebController!.isFormattingOptionsEnabled) {
|
||||
return ToolbarRichTextWebBuilder(
|
||||
richTextWebController: controller.richTextWebController,
|
||||
richTextWebController: controller.richTextWebController!,
|
||||
padding: ComposerStyle.richToolbarPadding,
|
||||
decoration: const BoxDecoration(
|
||||
color: ComposerStyle.richToolbarColor,
|
||||
@@ -467,12 +467,12 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
),
|
||||
),
|
||||
Obx(() => BottomBarComposerWidget(
|
||||
isCodeViewEnabled: controller.richTextWebController.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController.toggleFormattingOptions,
|
||||
isCodeViewEnabled: controller.richTextWebController!.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController!.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController!.toggleFormattingOptions,
|
||||
attachFileAction: () => controller.openFilePickerByType(context, FileType.any),
|
||||
insertImageAction: () => controller.insertImage(context, constraints.maxWidth),
|
||||
showCodeViewAction: controller.richTextWebController.toggleCodeView,
|
||||
showCodeViewAction: controller.richTextWebController!.toggleCodeView,
|
||||
deleteComposerAction: () => controller.handleClickDeleteComposer(context),
|
||||
saveToDraftAction: () => controller.handleClickSaveAsDraftsButton(context),
|
||||
sendMessageAction: () => controller.handleClickSendButton(context),
|
||||
@@ -680,7 +680,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
child: Padding(
|
||||
padding: ComposerStyle.tabletEditorPadding,
|
||||
child: Obx(() => WebEditorView(
|
||||
editorController: controller.richTextWebController.editorController,
|
||||
editorController: controller.richTextWebController!.editorController,
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
currentWebContent: controller.textEditorWeb,
|
||||
@@ -689,8 +689,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onFocus: controller.handleOnFocusHtmlEditorWeb,
|
||||
onUnFocus: controller.handleOnUnFocusHtmlEditorWeb,
|
||||
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
|
||||
onEditorSettings: controller.richTextWebController.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController.onEditorTextSizeChanged,
|
||||
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
|
||||
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
|
||||
@@ -710,9 +710,9 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
}
|
||||
}),
|
||||
Obx(() {
|
||||
if (controller.richTextWebController.isFormattingOptionsEnabled) {
|
||||
if (controller.richTextWebController!.isFormattingOptionsEnabled) {
|
||||
return ToolbarRichTextWebBuilder(
|
||||
richTextWebController: controller.richTextWebController,
|
||||
richTextWebController: controller.richTextWebController!,
|
||||
padding: ComposerStyle.richToolbarPadding,
|
||||
decoration: const BoxDecoration(
|
||||
color: ComposerStyle.richToolbarColor,
|
||||
@@ -777,12 +777,12 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
),
|
||||
),
|
||||
Obx(() => BottomBarComposerWidget(
|
||||
isCodeViewEnabled: controller.richTextWebController.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController.toggleFormattingOptions,
|
||||
isCodeViewEnabled: controller.richTextWebController!.codeViewEnabled,
|
||||
isFormattingOptionsEnabled: controller.richTextWebController!.isFormattingOptionsEnabled,
|
||||
openRichToolbarAction: controller.richTextWebController!.toggleFormattingOptions,
|
||||
attachFileAction: () => controller.openFilePickerByType(context, FileType.any),
|
||||
insertImageAction: () => controller.insertImage(context, constraints.maxWidth),
|
||||
showCodeViewAction: controller.richTextWebController.toggleCodeView,
|
||||
showCodeViewAction: controller.richTextWebController!.toggleCodeView,
|
||||
deleteComposerAction: () => controller.handleClickDeleteComposer(context),
|
||||
saveToDraftAction: () => controller.handleClickSaveAsDraftsButton(context),
|
||||
sendMessageAction: () => controller.handleClickSendButton(context),
|
||||
@@ -833,10 +833,10 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
colorIcon: ComposerStyle.popupItemIconColor,
|
||||
padding: ComposerStyle.popupItemPadding,
|
||||
selectedIcon: controller.imagePaths.icFilterSelected,
|
||||
isSelected: controller.richTextWebController.codeViewEnabled,
|
||||
isSelected: controller.richTextWebController?.codeViewEnabled,
|
||||
onCallbackAction: () {
|
||||
popBack();
|
||||
controller.richTextWebController.toggleCodeView();
|
||||
controller.richTextWebController?.toggleCodeView();
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
@@ -11,6 +11,8 @@ import 'package:tmail_ui_user/features/composer/presentation/model/inline_image.
|
||||
class RichTextMobileTabletController extends BaseRichTextController {
|
||||
HtmlEditorApi? htmlEditorApi;
|
||||
|
||||
final RichTextController richTextController = RichTextController();
|
||||
|
||||
void insertImage(InlineImage inlineImage) async {
|
||||
if (inlineImage.fileInfo.isShared == true) {
|
||||
await htmlEditorApi?.moveCursorAtLastNode();
|
||||
@@ -41,4 +43,11 @@ class RichTextMobileTabletController extends BaseRichTextController {
|
||||
logError('RichTextMobileTabletController::insertImageData:Exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
richTextController.dispose();
|
||||
htmlEditorApi = null;
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,14 +149,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
child: FocusScope(
|
||||
child: Focus(
|
||||
onFocusChange: (focus) => widget.onFocusEmailAddressChangeAction?.call(widget.prefix, focus),
|
||||
onKey: (focusNode, event) {
|
||||
if (event is RawKeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
widget.nextFocusNode?.requestFocus();
|
||||
widget.onFocusNextAddressAction?.call();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
onKey: PlatformInfo.isWeb ? _recipientInputOnKeyListener : null,
|
||||
child: StatefulBuilder(
|
||||
builder: (context, stateSetter) {
|
||||
if (PlatformInfo.isWeb || widget.isTestingForWeb) {
|
||||
@@ -389,6 +382,15 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
KeyEventResult _recipientInputOnKeyListener(FocusNode node, RawKeyEvent event) {
|
||||
if (event is RawKeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
widget.nextFocusNode?.requestFocus();
|
||||
widget.onFocusNextAddressAction?.call();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
bool get _isCollapse => _currentListEmailAddress.length > 1 && widget.expandMode == ExpandMode.COLLAPSE;
|
||||
|
||||
bool get _isAllRecipientInputEnabled => widget.fromState == PrefixRecipientState.enabled
|
||||
|
||||
@@ -67,15 +67,15 @@ class IdentityCreatorController extends BaseController {
|
||||
final isMobileEditorFocus = RxBool(false);
|
||||
final isCompressingInlineImage = RxBool(false);
|
||||
|
||||
final RichTextController keyboardRichTextController = RichTextController();
|
||||
final RichTextMobileTabletController richTextMobileTabletController = RichTextMobileTabletController();
|
||||
final RichTextWebController richTextWebController = RichTextWebController();
|
||||
final TextEditingController inputNameIdentityController = TextEditingController();
|
||||
final TextEditingController inputBccIdentityController = TextEditingController();
|
||||
final FocusNode inputNameIdentityFocusNode = FocusNode();
|
||||
final FocusNode inputBccIdentityFocusNode = FocusNode();
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
RichTextMobileTabletController? richTextMobileTabletController;
|
||||
RichTextWebController? richTextWebController;
|
||||
|
||||
String? _nameIdentity;
|
||||
String? _contentHtmlEditor;
|
||||
AccountId? accountId;
|
||||
@@ -110,6 +110,11 @@ class IdentityCreatorController extends BaseController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController = RichTextWebController();
|
||||
} else {
|
||||
richTextMobileTabletController = RichTextMobileTabletController();
|
||||
}
|
||||
log('IdentityCreatorController::onInit():arguments: ${Get.arguments}');
|
||||
arguments = Get.arguments;
|
||||
}
|
||||
@@ -132,13 +137,18 @@ class IdentityCreatorController extends BaseController {
|
||||
@override
|
||||
void onClose() {
|
||||
log('IdentityCreatorController::onClose():');
|
||||
keyboardRichTextController.dispose();
|
||||
inputNameIdentityFocusNode.dispose();
|
||||
inputBccIdentityFocusNode.dispose();
|
||||
inputNameIdentityController.dispose();
|
||||
inputBccIdentityController.dispose();
|
||||
scrollController.dispose();
|
||||
richTextWebController.onClose();
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController?.onClose();
|
||||
richTextWebController = null;
|
||||
} else {
|
||||
richTextMobileTabletController?.onClose();
|
||||
richTextMobileTabletController = null;
|
||||
}
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -171,7 +181,7 @@ class IdentityCreatorController extends BaseController {
|
||||
if (identity?.signatureAsString.isNotEmpty == true) {
|
||||
updateContentHtmlEditor(arguments?.identity?.signatureAsString ?? '');
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController.editorController.setText(arguments?.identity?.signatureAsString ?? '');
|
||||
richTextWebController?.editorController.setText(arguments?.identity?.signatureAsString ?? '');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,9 +309,9 @@ class IdentityCreatorController extends BaseController {
|
||||
|
||||
Future<String?> _getSignatureHtmlText() async {
|
||||
if (PlatformInfo.isWeb) {
|
||||
return richTextWebController.editorController.getText();
|
||||
return richTextWebController?.editorController.getText();
|
||||
} else {
|
||||
return keyboardRichTextController.htmlEditorApi?.getText();
|
||||
return richTextMobileTabletController?.richTextController.htmlEditorApi?.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +431,7 @@ class IdentityCreatorController extends BaseController {
|
||||
|
||||
void clearFocusEditor(BuildContext context) {
|
||||
if (PlatformInfo.isMobile) {
|
||||
keyboardRichTextController.htmlEditorApi?.unfocus();
|
||||
richTextMobileTabletController?.htmlEditorApi?.unfocus();
|
||||
KeyboardUtils.hideSystemKeyboardMobile();
|
||||
}
|
||||
KeyboardUtils.hideKeyboard(context);
|
||||
@@ -434,15 +444,15 @@ class IdentityCreatorController extends BaseController {
|
||||
}
|
||||
|
||||
void initRichTextForMobile(BuildContext context, HtmlEditorApi editorApi) {
|
||||
richTextMobileTabletController.htmlEditorApi = editorApi;
|
||||
keyboardRichTextController.onCreateHTMLEditor(
|
||||
richTextMobileTabletController?.htmlEditorApi = editorApi;
|
||||
richTextMobileTabletController?.richTextController.onCreateHTMLEditor(
|
||||
editorApi,
|
||||
onEnterKeyDown: _onEnterKeyDownOnMobile,
|
||||
onFocus: _onFocusHTMLEditorOnMobile,
|
||||
context: context
|
||||
);
|
||||
keyboardRichTextController.htmlEditorApi?.onFocusOut = () {
|
||||
keyboardRichTextController.hideRichTextView();
|
||||
richTextMobileTabletController?.htmlEditorApi?.onFocusOut = () {
|
||||
richTextMobileTabletController?.richTextController.hideRichTextView();
|
||||
isMobileEditorFocus.value = false;
|
||||
};
|
||||
}
|
||||
@@ -546,9 +556,9 @@ class IdentityCreatorController extends BaseController {
|
||||
}
|
||||
} else {
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController.insertImageAsBase64(platformFile: file, maxWidth: maxWidth);
|
||||
richTextWebController?.insertImageAsBase64(platformFile: file, maxWidth: maxWidth);
|
||||
} else if (PlatformInfo.isMobile) {
|
||||
richTextMobileTabletController.insertImageData(platformFile: file, maxWidth: maxWidth);
|
||||
richTextMobileTabletController?.insertImageData(platformFile: file, maxWidth: maxWidth);
|
||||
if (file.path != null) {
|
||||
_deleteCompressedFileOnMobile(file.path!);
|
||||
}
|
||||
|
||||
@@ -147,14 +147,14 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController>
|
||||
? AppColor.colorBackgroundKeyboard
|
||||
: AppColor.colorBackgroundKeyboardAndroid,
|
||||
isLandScapeMode: controller.responsiveUtils.isLandscapeMobile(context),
|
||||
richTextController: controller.keyboardRichTextController,
|
||||
richTextController: controller.richTextMobileTabletController!.richTextController,
|
||||
titleQuickStyleBottomSheet: AppLocalizations.of(context).titleQuickStyles,
|
||||
titleBackgroundBottomSheet: AppLocalizations.of(context).titleBackground,
|
||||
titleForegroundBottomSheet: AppLocalizations.of(context).titleForeground,
|
||||
titleFormatBottomSheet: AppLocalizations.of(context).titleFormat,
|
||||
insertImage: () => controller.pickImage(context),
|
||||
),
|
||||
richTextController: controller.keyboardRichTextController,
|
||||
richTextController: controller.richTextMobileTabletController!.richTextController,
|
||||
paddingChild: EdgeInsets.zero,
|
||||
child: responsiveWidget
|
||||
);
|
||||
@@ -311,7 +311,7 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController>
|
||||
children: [
|
||||
if (PlatformInfo.isWeb)
|
||||
ToolbarRichTextWebBuilder(
|
||||
richTextWebController: controller.richTextWebController,
|
||||
richTextWebController: controller.richTextWebController!,
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
extendedOption: [
|
||||
Padding(
|
||||
@@ -344,7 +344,7 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController>
|
||||
Widget _buildHtmlEditorWeb(BuildContext context, String initContent) {
|
||||
return html_editor_browser.HtmlEditor(
|
||||
key: const Key('identity_create_editor_web'),
|
||||
controller: controller.richTextWebController.editorController,
|
||||
controller: controller.richTextWebController!.editorController,
|
||||
htmlEditorOptions: html_editor_browser.HtmlEditorOptions(
|
||||
shouldEnsureVisible: true,
|
||||
hint: '',
|
||||
@@ -361,16 +361,16 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController>
|
||||
onBeforeCommand: controller.updateContentHtmlEditor,
|
||||
onChangeContent: controller.updateContentHtmlEditor,
|
||||
onInit: () {
|
||||
controller.richTextWebController.editorController.setFullScreen();
|
||||
controller.richTextWebController?.editorController.setFullScreen();
|
||||
controller.updateContentHtmlEditor(initContent);
|
||||
}, onFocus: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
controller.richTextWebController.editorController.setFocus();
|
||||
controller.richTextWebController?.editorController.setFocus();
|
||||
});
|
||||
controller.richTextWebController.closeAllMenuPopup();
|
||||
controller.richTextWebController?.closeAllMenuPopup();
|
||||
},
|
||||
onChangeSelection: controller.richTextWebController.onEditorSettingsChange,
|
||||
onChangeSelection: controller.richTextWebController?.onEditorSettingsChange,
|
||||
onChangeCodeview: controller.updateContentHtmlEditor
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user