TF-2116 Apply new design composer mobile
(cherry picked from commit fe4ec144d1a18a94de782f87fff56bbf1cd3a00a)
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/web/desktop_responsive_container_view_style.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/minimize_composer_widget.dart';
|
||||
|
||||
class DesktopResponsiveContainerView extends StatelessWidget {
|
||||
|
||||
final ScreenDisplayMode displayMode;
|
||||
final String emailSubject;
|
||||
final VoidCallback onCloseViewAction;
|
||||
final OnChangeDisplayModeAction onChangeDisplayModeAction;
|
||||
final Widget Function(BuildContext context, BoxConstraints constraints) childBuilder;
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
DesktopResponsiveContainerView({
|
||||
super.key,
|
||||
required this.childBuilder,
|
||||
required this.displayMode,
|
||||
required this.emailSubject,
|
||||
required this.onCloseViewAction,
|
||||
required this.onChangeDisplayModeAction,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (displayMode == ScreenDisplayMode.minimize) {
|
||||
return PositionedDirectional(
|
||||
end: DesktopResponsiveContainerViewStyle.margin,
|
||||
bottom: DesktopResponsiveContainerViewStyle.margin,
|
||||
child: PointerInterceptor(
|
||||
child: MinimizeComposerWidget(
|
||||
emailSubject: emailSubject,
|
||||
onCloseViewAction: onCloseViewAction,
|
||||
onChangeDisplayModeAction: onChangeDisplayModeAction,
|
||||
),
|
||||
)
|
||||
);
|
||||
} else if (displayMode == ScreenDisplayMode.normal) {
|
||||
final maxWidth = _responsiveUtils.getSizeScreenWidth(context) * 0.5;
|
||||
final maxHeight = _responsiveUtils.getSizeScreenHeight(context) * 0.75;
|
||||
|
||||
return PositionedDirectional(
|
||||
end: DesktopResponsiveContainerViewStyle.margin,
|
||||
bottom: DesktopResponsiveContainerViewStyle.margin,
|
||||
child: Card(
|
||||
elevation: DesktopResponsiveContainerViewStyle.elevation,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(DesktopResponsiveContainerViewStyle.radius))
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Container(
|
||||
color: DesktopResponsiveContainerViewStyle.backgroundColor,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
child: LayoutBuilder(builder: (context, constraints) =>
|
||||
PointerInterceptor(
|
||||
child: childBuilder.call(context, constraints)
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
} else if (displayMode == ScreenDisplayMode.fullScreen) {
|
||||
final maxWidth = _responsiveUtils.getSizeScreenWidth(context) * 0.85;
|
||||
final maxHeight = _responsiveUtils.getSizeScreenHeight(context) * 0.9;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: DesktopResponsiveContainerViewStyle.outSideBackgroundColor,
|
||||
body: Center(
|
||||
child: Card(
|
||||
elevation: DesktopResponsiveContainerViewStyle.elevation,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(DesktopResponsiveContainerViewStyle.radius))
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Container(
|
||||
color: DesktopResponsiveContainerViewStyle.backgroundColor,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
child: LayoutBuilder(builder: (context, constraints) =>
|
||||
PointerInterceptor(
|
||||
child: childBuilder.call(context, constraints)
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/web/mobile_responsive_container_view_style.dart';
|
||||
|
||||
class MobileResponsiveContainerView extends StatelessWidget {
|
||||
|
||||
final Widget Function(BuildContext context, BoxConstraints constraints) childBuilder;
|
||||
|
||||
const MobileResponsiveContainerView({
|
||||
super.key,
|
||||
required this.childBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: MobileResponsiveContainerViewStyle.outSideBackgroundColor,
|
||||
body: LayoutBuilder(builder: (context, constraints) =>
|
||||
PointerInterceptor(
|
||||
child: childBuilder.call(context, constraints)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/web/tablet_responsive_container_view_style.dart';
|
||||
|
||||
class TabletResponsiveContainerView extends StatelessWidget {
|
||||
|
||||
final Widget Function(BuildContext context, BoxConstraints constraints) childBuilder;
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
TabletResponsiveContainerView({
|
||||
super.key,
|
||||
required this.childBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: TabletResponsiveContainerViewStyle.outSideBackgroundColor,
|
||||
body: Center(
|
||||
child: Card(
|
||||
elevation: TabletResponsiveContainerViewStyle.elevation,
|
||||
margin: TabletResponsiveContainerViewStyle.getMargin(context, _responsiveUtils),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(TabletResponsiveContainerViewStyle.radius))
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Container(
|
||||
color: TabletResponsiveContainerViewStyle.backgroundColor,
|
||||
width: TabletResponsiveContainerViewStyle.getWidth(context, _responsiveUtils),
|
||||
child: LayoutBuilder(builder: (context, constraints) =>
|
||||
PointerInterceptor(
|
||||
child: childBuilder.call(context, constraints)
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
import 'package:core/presentation/extensions/html_extension.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html_editor_enhanced/html_editor.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/cupertino_loading_widget.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/view/editor_view_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/web_editor_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/get_email_content_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/transform_html_email_content_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
class WebEditorView extends StatelessWidget with EditorViewMixin {
|
||||
|
||||
final HtmlEditorController editorController;
|
||||
final ComposerArguments? arguments;
|
||||
final Either<Failure, Success>? contentViewState;
|
||||
final String? currentWebContent;
|
||||
final OnInitialContentEditorAction? onInitial;
|
||||
final OnChangeContentEditorAction? onChangeContent;
|
||||
final VoidCallback? onFocus;
|
||||
final VoidCallback? onUnFocus;
|
||||
final OnMouseDownEditorAction? onMouseDown;
|
||||
final OnEditorSettingsChange? onEditorSettings;
|
||||
|
||||
const WebEditorView({
|
||||
super.key,
|
||||
required this.editorController,
|
||||
this.arguments,
|
||||
this.contentViewState,
|
||||
this.currentWebContent,
|
||||
this.onInitial,
|
||||
this.onChangeContent,
|
||||
this.onFocus,
|
||||
this.onUnFocus,
|
||||
this.onMouseDown,
|
||||
this.onEditorSettings,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (arguments == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
switch(arguments!.emailActionType) {
|
||||
case EmailActionType.compose:
|
||||
case EmailActionType.composeFromEmailAddress:
|
||||
case EmailActionType.composeFromFileShared:
|
||||
return WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
);
|
||||
case EmailActionType.editDraft:
|
||||
case EmailActionType.editSendingEmail:
|
||||
case EmailActionType.composeFromContentShared:
|
||||
case EmailActionType.reopenComposerBrowser:
|
||||
if (contentViewState == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return contentViewState!.fold(
|
||||
(failure) => WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
),
|
||||
(success) {
|
||||
if (success is GetEmailContentLoading) {
|
||||
return const CupertinoLoadingWidget(padding: EdgeInsets.all(16.0));
|
||||
} else {
|
||||
var newContent = success is GetEmailContentSuccess
|
||||
? success.htmlEmailContent
|
||||
: HtmlExtension.editorStartTags;
|
||||
if (newContent.isEmpty) {
|
||||
newContent = HtmlExtension.editorStartTags;
|
||||
}
|
||||
return WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? newContent,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
case EmailActionType.reply:
|
||||
case EmailActionType.replyAll:
|
||||
case EmailActionType.forward:
|
||||
if (contentViewState == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return contentViewState!.fold(
|
||||
(failure) {
|
||||
final emailContentQuoted = getEmailContentQuotedAsHtml(
|
||||
context: context,
|
||||
emailContent: '',
|
||||
emailActionType: arguments!.emailActionType,
|
||||
presentationEmail: arguments!.presentationEmail!
|
||||
);
|
||||
return WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? emailContentQuoted,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
if (success is TransformHtmlEmailContentLoading) {
|
||||
return const CupertinoLoadingWidget(padding: EdgeInsets.all(16.0));
|
||||
} else {
|
||||
final emailContentQuoted = getEmailContentQuotedAsHtml(
|
||||
context: context,
|
||||
emailContent: success is TransformHtmlEmailContentSuccess
|
||||
? success.htmlContent
|
||||
: '',
|
||||
emailActionType: arguments!.emailActionType,
|
||||
presentationEmail: arguments!.presentationEmail!
|
||||
);
|
||||
return WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? emailContentQuoted,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
default:
|
||||
return WebEditorWidget(
|
||||
editorController: editorController,
|
||||
content: currentWebContent ?? HtmlExtension.editorStartTags,
|
||||
direction: AppUtils.getCurrentDirection(context),
|
||||
onInitial: onInitial,
|
||||
onChangeContent: onChangeContent,
|
||||
onFocus: onFocus,
|
||||
onUnFocus: onUnFocus,
|
||||
onMouseDown: onMouseDown,
|
||||
onEditorSettings: onEditorSettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user