TF-3601 Fix content gone blank in composer on IOS
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -138,6 +138,7 @@ class ComposerController extends BaseController
|
||||
final listFromIdentities = RxList<Identity>();
|
||||
final isEmailChanged = Rx<bool>(false);
|
||||
final isMarkAsImportant = Rx<bool>(false);
|
||||
final isContentHeightExceeded = Rx<bool>(false);
|
||||
|
||||
final LocalFilePickerInteractor _localFilePickerInteractor;
|
||||
final LocalImagePickerInteractor _localImagePickerInteractor;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:core/presentation/views/context_menu/simple_context_menu_action_builder.dart';
|
||||
import 'package:core/presentation/views/responsive/responsive_widget.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -8,6 +9,7 @@ import 'package:get/get.dart';
|
||||
import 'package:model/email/prefix_email_address.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/popup_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/handle_content_height_exceeded_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/mark_as_important_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/prefix_recipient_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
@@ -25,6 +27,7 @@ import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/tabl
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/recipient_composer_widget.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/subject_composer_widget.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/from_composer_drop_down_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/view_entire_message_with_message_clipped_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
@@ -107,6 +110,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
controller: controller.scrollController,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Obx(() {
|
||||
if (controller.fromRecipientState.value == PrefixRecipientState.enabled) {
|
||||
@@ -260,8 +264,20 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
onEditorContentHeightChanged: controller.onEditorContentHeightChangedOnIOS,
|
||||
),
|
||||
)),
|
||||
Obx(() {
|
||||
if (controller.isContentHeightExceeded.isTrue && PlatformInfo.isIOS) {
|
||||
return ViewEntireMessageWithMessageClippedWidget(
|
||||
buttonActionName: AppLocalizations.of(context).viewEntireMessage.toUpperCase(),
|
||||
onViewEntireMessageAction: () => controller.viewEntireContent(context),
|
||||
topPadding: 12,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
SizedBox(height: MediaQuery.viewInsetsOf(context).bottom + 64),
|
||||
],
|
||||
),
|
||||
@@ -296,6 +312,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
controller: controller.scrollController,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Obx(() => Column(
|
||||
children: [
|
||||
@@ -433,8 +450,20 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
onEditorContentHeightChanged: controller.onEditorContentHeightChangedOnIOS,
|
||||
),
|
||||
)),
|
||||
Obx(() {
|
||||
if (controller.isContentHeightExceeded.isTrue && PlatformInfo.isIOS) {
|
||||
return ViewEntireMessageWithMessageClippedWidget(
|
||||
buttonActionName: AppLocalizations.of(context).viewEntireMessage.toUpperCase(),
|
||||
onViewEntireMessageAction: () => controller.viewEntireContent(context),
|
||||
topPadding: 12,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
SizedBox(height: MediaQuery.viewInsetsOf(context).bottom + 64),
|
||||
],
|
||||
),
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
import 'package:core/presentation/constants/constants_ui.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/view/mobile/editor_fullscreen_dialog_view.dart';
|
||||
|
||||
extension HandleContentHeightExceededExtension on ComposerController {
|
||||
|
||||
void onEditorContentHeightChangedOnIOS(double height) {
|
||||
log('HandleContentHeightExceededExtension::onEditorContentHeightChangedOnIOS:height: $height');
|
||||
isContentHeightExceeded.value = height == ConstantsUI.composerHtmlContentMaxHeight;
|
||||
}
|
||||
|
||||
Future<void> viewEntireContent(BuildContext context) async {
|
||||
clearFocus(context);
|
||||
|
||||
final currentContent = await getContentInEditor();
|
||||
log('HandleContentHeightExceededExtension::showComposerFullscreen:currentContent = $currentContent');
|
||||
Get.dialog(
|
||||
EditorFullscreenDialogView(
|
||||
content: currentContent,
|
||||
imagePaths: imagePaths,
|
||||
subject: subjectEmail.value,
|
||||
),
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||
import 'package:core/presentation/views/html_viewer/ios_html_content_viewer_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
class EditorFullscreenDialogView extends StatelessWidget {
|
||||
final String content;
|
||||
final ImagePaths imagePaths;
|
||||
final String? subject;
|
||||
|
||||
const EditorFullscreenDialogView({
|
||||
super.key,
|
||||
required this.imagePaths,
|
||||
required this.content,
|
||||
this.subject,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(16),
|
||||
topLeft: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
insetPadding: EdgeInsets.zero,
|
||||
alignment: Alignment.center,
|
||||
backgroundColor: Colors.white,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(16),
|
||||
topLeft: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 52,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 40),
|
||||
Expanded(child: Text(
|
||||
subject ?? AppLocalizations.of(context).compose_email,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.black,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: imagePaths.icComposerClose,
|
||||
backgroundColor: Colors.transparent,
|
||||
margin: const EdgeInsetsDirectional.only(end: 12),
|
||||
onTapActionCallback: popBack,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(color: AppColor.colorDivider, height: 1),
|
||||
Expanded(
|
||||
child: IosHtmlContentViewerWidget(
|
||||
contentHtml: content,
|
||||
useDefaultFont: true,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
final Either<Failure, Success>? contentViewState;
|
||||
final OnCreatedEditorAction onCreatedEditorAction;
|
||||
final OnLoadCompletedEditorAction onLoadCompletedEditorAction;
|
||||
final OnEditorContentHeightChanged? onEditorContentHeightChanged;
|
||||
|
||||
const MobileEditorView({
|
||||
super.key,
|
||||
@@ -25,6 +26,7 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
required this.onLoadCompletedEditorAction,
|
||||
this.arguments,
|
||||
this.contentViewState,
|
||||
this.onEditorContentHeightChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -41,7 +43,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
);
|
||||
case EmailActionType.editDraft:
|
||||
case EmailActionType.editSendingEmail:
|
||||
@@ -58,7 +61,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
),
|
||||
(success) {
|
||||
if (success is GetEmailContentLoading) {
|
||||
@@ -77,7 +81,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: newContent,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +107,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: emailContentQuoted,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
@@ -122,7 +128,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: emailContentQuoted,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +139,8 @@ class MobileEditorView extends StatelessWidget with EditorViewMixin {
|
||||
content: HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onCreatedEditorAction: onCreatedEditorAction,
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction
|
||||
onLoadCompletedEditorAction: onLoadCompletedEditorAction,
|
||||
onEditorContentHeightChanged: onEditorContentHeightChanged,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
|
||||
import 'package:core/presentation/constants/constants_ui.dart';
|
||||
import 'package:core/utils/html/html_utils.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rich_text_composer/rich_text_composer.dart';
|
||||
|
||||
typedef OnCreatedEditorAction = Function(BuildContext context, HtmlEditorApi editorApi, String content);
|
||||
typedef OnLoadCompletedEditorAction = Function(HtmlEditorApi editorApi, WebUri? url);
|
||||
typedef OnEditorContentHeightChanged = Function(double height);
|
||||
|
||||
class MobileEditorWidget extends StatelessWidget {
|
||||
|
||||
@@ -12,6 +15,7 @@ class MobileEditorWidget extends StatelessWidget {
|
||||
final TextDirection direction;
|
||||
final OnCreatedEditorAction onCreatedEditorAction;
|
||||
final OnLoadCompletedEditorAction onLoadCompletedEditorAction;
|
||||
final OnEditorContentHeightChanged? onEditorContentHeightChanged;
|
||||
|
||||
const MobileEditorWidget({
|
||||
super.key,
|
||||
@@ -19,6 +23,7 @@ class MobileEditorWidget extends StatelessWidget {
|
||||
required this.direction,
|
||||
required this.onCreatedEditorAction,
|
||||
required this.onLoadCompletedEditorAction,
|
||||
this.onEditorContentHeightChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,6 +31,7 @@ class MobileEditorWidget extends StatelessWidget {
|
||||
return HtmlEditor(
|
||||
key: const Key('mobile_editor'),
|
||||
minHeight: 550,
|
||||
maxHeight: PlatformInfo.isIOS ? ConstantsUI.composerHtmlContentMaxHeight : null,
|
||||
addDefaultSelectionMenuItems: false,
|
||||
initialContent: content,
|
||||
customStyleCss: HtmlUtils.customCssStyleHtmlEditor(
|
||||
@@ -34,6 +40,7 @@ class MobileEditorWidget extends StatelessWidget {
|
||||
),
|
||||
onCreated: (editorApi) => onCreatedEditorAction.call(context, editorApi, content),
|
||||
onCompleted: onLoadCompletedEditorAction,
|
||||
onContentHeightChanged: PlatformInfo.isIOS ? onEditorContentHeightChanged : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user