TF-3479 Remove ComposerUtils & only sync composer state when composers is not empty
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
extension UpdateScreenDisplayModeExtension on ComposerController {
|
||||
@@ -21,9 +21,9 @@ extension UpdateScreenDisplayModeExtension on ComposerController {
|
||||
double get composerWidth {
|
||||
switch (screenDisplayMode.value) {
|
||||
case ScreenDisplayMode.normal:
|
||||
return ComposerUtils.normalWidth;
|
||||
return ComposerStyle.normalWidth;
|
||||
case ScreenDisplayMode.minimize:
|
||||
return ComposerUtils.minimizeWidth;
|
||||
return ComposerStyle.minimizeWidth;
|
||||
case ScreenDisplayMode.hidden:
|
||||
case ScreenDisplayMode.fullScreen:
|
||||
return 0;
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:tmail_ui_user/features/composer/presentation/composer_controller
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_view_web.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/update_screen_display_mode_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
@@ -90,9 +90,9 @@ class ComposerManager extends GetxController {
|
||||
}
|
||||
|
||||
final availableWidth = screenWidth
|
||||
- ComposerUtils.composerExpandMoreButtonMaxWidth
|
||||
- ComposerUtils.padding * 3
|
||||
- (countDisplayedComposer - 1) * ComposerUtils.space;
|
||||
- ComposerStyle.composerExpandMoreButtonMaxWidth
|
||||
- ComposerStyle.padding * 3
|
||||
- (countDisplayedComposer - 1) * ComposerStyle.space;
|
||||
|
||||
return (
|
||||
availableWidth,
|
||||
@@ -110,7 +110,7 @@ class ComposerManager extends GetxController {
|
||||
if (currentHiddenComposerIds.isEmpty) return;
|
||||
|
||||
for (var index = currentHiddenComposerIds.length - 1; index >= 0; index--) {
|
||||
final newTotalWidth = totalWidth + ComposerUtils.minimizeWidth;
|
||||
final newTotalWidth = totalWidth + ComposerStyle.minimizeWidth;
|
||||
if (newTotalWidth > availableWidth) break;
|
||||
|
||||
final id = currentHiddenComposerIds.elementAt(index);
|
||||
@@ -126,18 +126,18 @@ class ComposerManager extends GetxController {
|
||||
final controller = composerControllers[id]!;
|
||||
|
||||
if (controller.isNormalScreen) {
|
||||
var newTotalWidth = totalWidth - (ComposerUtils.normalWidth - ComposerUtils.minimizeWidth);
|
||||
var newTotalWidth = totalWidth - (ComposerStyle.normalWidth - ComposerStyle.minimizeWidth);
|
||||
var newDisplayMode = ScreenDisplayMode.minimize;
|
||||
|
||||
if (newTotalWidth > availableWidth) {
|
||||
newTotalWidth = totalWidth - ComposerUtils.normalWidth;
|
||||
newTotalWidth = totalWidth - ComposerStyle.normalWidth;
|
||||
newDisplayMode = ScreenDisplayMode.hidden;
|
||||
}
|
||||
|
||||
controller.setScreenDisplayMode(newDisplayMode);
|
||||
totalWidth = newTotalWidth;
|
||||
} else if (controller.isMinimizeScreen) {
|
||||
final newTotalWidth = totalWidth - ComposerUtils.minimizeWidth;
|
||||
final newTotalWidth = totalWidth - ComposerStyle.minimizeWidth;
|
||||
controller.setScreenDisplayMode(ScreenDisplayMode.hidden);
|
||||
totalWidth = newTotalWidth;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class ComposerManager extends GetxController {
|
||||
if (currentHiddenComposerIds.isEmpty) return;
|
||||
|
||||
for (var index = currentHiddenComposerIds.length - 1; index >= 0; index--) {
|
||||
final newTotalWidth = totalWidth + ComposerUtils.minimizeWidth;
|
||||
final newTotalWidth = totalWidth + ComposerStyle.minimizeWidth;
|
||||
if (newTotalWidth > availableWidth) break;
|
||||
|
||||
final id = currentHiddenComposerIds.elementAt(index);
|
||||
@@ -174,7 +174,7 @@ class ComposerManager extends GetxController {
|
||||
if (id == updatedComposerId) continue;
|
||||
|
||||
composerControllers[id]!.setScreenDisplayMode(ScreenDisplayMode.hidden);
|
||||
totalWidth -= ComposerUtils.minimizeWidth;
|
||||
totalWidth -= ComposerStyle.minimizeWidth;
|
||||
if (totalWidth <= availableWidth) return;
|
||||
}
|
||||
|
||||
@@ -182,14 +182,14 @@ class ComposerManager extends GetxController {
|
||||
if (id == updatedComposerId) continue;
|
||||
|
||||
final controller = composerControllers[id]!;
|
||||
var newTotalWidth = totalWidth - (ComposerUtils.normalWidth - ComposerUtils.minimizeWidth);
|
||||
var newTotalWidth = totalWidth - (ComposerStyle.normalWidth - ComposerStyle.minimizeWidth);
|
||||
|
||||
if (newTotalWidth <= availableWidth) {
|
||||
controller.setScreenDisplayMode(ScreenDisplayMode.minimize);
|
||||
return;
|
||||
}
|
||||
|
||||
newTotalWidth = totalWidth - ComposerUtils.normalWidth;
|
||||
newTotalWidth = totalWidth - ComposerStyle.normalWidth;
|
||||
if (newTotalWidth <= availableWidth) {
|
||||
controller.setScreenDisplayMode(ScreenDisplayMode.hidden);
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,14 @@ class ComposerStyle {
|
||||
static const double keyboardToolBarHeight = 200;
|
||||
static const double popupMenuRadius = 8;
|
||||
static const double suggestionItemHeight = 60;
|
||||
static const double normalWidth = 725;
|
||||
static const double normalHeight = 525;
|
||||
static const double minimizeWidth = 400;
|
||||
static const double minimizeHeight = 52;
|
||||
static const double composerExpandMoreButtonMaxWidth = 130;
|
||||
static const double composerExpandMoreButtonMaxHeight = 52;
|
||||
static const double padding = 16;
|
||||
static const double space = 8;
|
||||
|
||||
static const Color borderColor = AppColor.colorLineComposer;
|
||||
static const Color backgroundEditorColor = Colors.white;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
|
||||
class MinimizeComposerWidgetStyle {
|
||||
static const double radius = 24;
|
||||
static const double elevation = 16;
|
||||
static const double width = ComposerUtils.minimizeWidth;
|
||||
static const double height = ComposerUtils.minimizeHeight;
|
||||
static const double width = ComposerStyle.minimizeWidth;
|
||||
static const double height = ComposerStyle.minimizeHeight;
|
||||
static const double space = 8;
|
||||
static const double iconSize = 20;
|
||||
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
|
||||
class DesktopResponsiveContainerViewStyle {
|
||||
static const double radius = 28;
|
||||
static const double margin = 20;
|
||||
static const double elevation = 16;
|
||||
static const double normalScreenMaxWidth = ComposerUtils.normalWidth;
|
||||
static const double normalScreenMaxHeight = ComposerUtils.normalHeight;
|
||||
static const double normalScreenMaxWidth = ComposerStyle.normalWidth;
|
||||
static const double normalScreenMaxHeight = ComposerStyle.normalHeight;
|
||||
|
||||
static const Color backgroundColor = Colors.white;
|
||||
static const Color outSideBackgroundColor = Colors.black38;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
class ComposerUtils {
|
||||
static const double normalWidth = 725;
|
||||
static const double normalHeight = 525;
|
||||
static const double minimizeWidth = 400;
|
||||
static const double minimizeHeight = 52;
|
||||
static const double composerExpandMoreButtonMaxWidth = 130;
|
||||
static const double composerExpandMoreButtonMaxHeight = 52;
|
||||
static const double padding = 16;
|
||||
static const double space = 8;
|
||||
}
|
||||
@@ -4,32 +4,23 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/update_screen_display_mode_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/manager/composer_manager.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/expand_composer_button.dart';
|
||||
|
||||
class ComposerOverlayView extends StatefulWidget {
|
||||
const ComposerOverlayView({super.key});
|
||||
class ComposerOverlayView extends StatelessWidget {
|
||||
final ComposerManager _composerManager = Get.find<ComposerManager>();
|
||||
final ResponsiveUtils _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
@override
|
||||
State<ComposerOverlayView> createState() => _ComposerOverlayViewState();
|
||||
}
|
||||
|
||||
class _ComposerOverlayViewState extends State<ComposerOverlayView> {
|
||||
late final ComposerManager _composerManager;
|
||||
late final ResponsiveUtils _responsiveUtils;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_composerManager = Get.find<ComposerManager>();
|
||||
_responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
}
|
||||
ComposerOverlayView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_composerManager.syncComposerStateWhenResponsiveChanged(
|
||||
screenWidth: context.width,
|
||||
);
|
||||
if (_composerManager.composers.isNotEmpty) {
|
||||
_composerManager.syncComposerStateWhenResponsiveChanged(
|
||||
screenWidth: context.width,
|
||||
);
|
||||
}
|
||||
|
||||
return Obx(() {
|
||||
final composers = _composerManager.composers;
|
||||
final composerIdsQueue = _composerManager.composerIdsQueue;
|
||||
@@ -58,7 +49,7 @@ class _ComposerOverlayViewState extends State<ComposerOverlayView> {
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.all(ComposerUtils.padding),
|
||||
padding: const EdgeInsetsDirectional.all(ComposerStyle.padding),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/manager/composer_manager.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/hidden_composer_list_view_overlay.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
@@ -57,8 +57,8 @@ class _ExpandComposerButtonState extends State<ExpandComposerButton> {
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
width: ComposerUtils.composerExpandMoreButtonMaxWidth,
|
||||
height: ComposerUtils.composerExpandMoreButtonMaxHeight,
|
||||
width: ComposerStyle.composerExpandMoreButtonMaxWidth,
|
||||
height: ComposerStyle.composerExpandMoreButtonMaxHeight,
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
+3
-3
@@ -4,8 +4,8 @@ import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/manager/composer_manager.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/web/hidden_composer_item_style.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/utils/composer_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/hidden_composer_item.dart';
|
||||
|
||||
typedef OnRemoveHiddenComposerItem = Function(ComposerController controller);
|
||||
@@ -32,8 +32,8 @@ class HiddenComposerListViewOverlay extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final hiddenComposerIds = composerManager.hiddenComposerIds;
|
||||
final maxHeight = responsiveUtils.getSizeScreenHeight(context)
|
||||
- ComposerUtils.composerExpandMoreButtonMaxHeight
|
||||
- ComposerUtils.padding * 2;
|
||||
- ComposerStyle.composerExpandMoreButtonMaxHeight
|
||||
- ComposerStyle.padding * 2;
|
||||
|
||||
return Container(
|
||||
constraints: BoxConstraints(maxHeight: maxHeight),
|
||||
|
||||
@@ -198,7 +198,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
||||
}
|
||||
}),
|
||||
),
|
||||
const ComposerOverlayView(),
|
||||
ComposerOverlayView(),
|
||||
Obx(() => controller.searchMailboxActivated.value == true && !controller.responsiveUtils.isWebDesktop(context)
|
||||
? const SearchMailboxView()
|
||||
: const SizedBox.shrink()
|
||||
|
||||
Reference in New Issue
Block a user