TF-3759 Display correct context menu for web responsive

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-06-16 13:22:04 +07:00
committed by Dat H. Pham
parent d39d09663d
commit ecc3cf81d4
4 changed files with 41 additions and 84 deletions
@@ -204,21 +204,15 @@ abstract class BaseMailboxView extends GetWidget<MailboxController>
context, context,
mailboxNode.item, mailboxNode.item,
), ),
onDragItemAccepted: PlatformInfo.isMobile onDragItemAccepted: controller.handleDragItemAccepted,
? null onMenuActionClick: (position, mailboxNode) {
: controller.handleDragItemAccepted,
onMenuActionClick: PlatformInfo.isMobile
? null
: (position, mailboxNode) {
return controller.openMailboxContextMenuAction( return controller.openMailboxContextMenuAction(
context, context,
position, position,
mailboxNode.item, mailboxNode.item,
); );
}, },
onEmptyMailboxActionCallback: PlatformInfo.isMobile onEmptyMailboxActionCallback: (mailboxNode) => controller.emptyMailboxAction(
? null
: (mailboxNode) => controller.emptyMailboxAction(
context, context,
mailboxNode.item, mailboxNode.item,
), ),
@@ -75,28 +75,6 @@ extension HandleMailboxActionExtension on MailboxController {
final isSubAddressingSupported = final isSubAddressingSupported =
session?.isSubAddressingSupported(accountId) ?? false; session?.isSubAddressingSupported(accountId) ?? false;
if (responsiveUtils.isScreenWithShortestSide(context)) {
final contextMenuActions = listContextMenuItemAction(
mailbox,
mailboxDashBoardController.enableSpamReport,
deletedMessageVaultSupported,
isSubAddressingSupported,
imagePaths,
AppLocalizations.of(context),
);
if (contextMenuActions.isEmpty) return Future.value();
return openBottomSheetContextMenuAction(
context: context,
itemActions: contextMenuActions,
onContextMenuActionClick: (menuAction) => handleMailboxAction(
context,
menuAction.action,
mailbox,
),
);
} else {
final popupMenuActions = getListPopupMenuItemAction( final popupMenuActions = getListPopupMenuItemAction(
AppLocalizations.of(context), AppLocalizations.of(context),
imagePaths, imagePaths,
@@ -124,4 +102,3 @@ extension HandleMailboxActionExtension on MailboxController {
return openPopupMenuAction(context, position, popupMenuItems); return openPopupMenuAction(context, position, popupMenuItems);
} }
} }
}
@@ -1,5 +1,4 @@
import 'package:core/presentation/resources/image_paths.dart'; import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart'; import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -39,7 +38,6 @@ class DesktopListEmailActionHoverWidget extends StatefulWidget {
class _DesktopListEmailActionHoverWidgetState class _DesktopListEmailActionHoverWidgetState
extends State<DesktopListEmailActionHoverWidget> with BaseEmailItemTile { extends State<DesktopListEmailActionHoverWidget> with BaseEmailItemTile {
final _imagePaths = Get.find<ImagePaths>(); final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
bool _popupMenuVisible = false; bool _popupMenuVisible = false;
@@ -121,15 +119,11 @@ class _DesktopListEmailActionHoverWidgetState
: Colors.transparent, : Colors.transparent,
tooltipMessage: AppLocalizations.of(context).more, tooltipMessage: AppLocalizations.of(context).more,
onTapActionAtPositionCallback: (position) { onTapActionAtPositionCallback: (position) {
if (_responsiveUtils.isScreenWithShortestSide(context)) {
widget.onMoreActionClick?.call(widget.presentationEmail, null);
} else {
_onPopupMenuVisibleChange(true); _onPopupMenuVisibleChange(true);
widget.onMoreActionClick widget.onMoreActionClick
?.call(widget.presentationEmail, position) ?.call(widget.presentationEmail, position)
.whenComplete(() => _onPopupMenuVisibleChange(false)); .whenComplete(() => _onPopupMenuVisibleChange(false));
}
}, },
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
@@ -1,6 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart'; import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart'; import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart'; import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -54,7 +53,6 @@ class WebTabletBodyEmailItemWidget extends StatefulWidget {
class _WebTabletBodyEmailItemWidgetState class _WebTabletBodyEmailItemWidgetState
extends State<WebTabletBodyEmailItemWidget> with BaseEmailItemTile { extends State<WebTabletBodyEmailItemWidget> with BaseEmailItemTile {
final _imagePaths = Get.find<ImagePaths>(); final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
bool _isHover = false; bool _isHover = false;
bool _popupMenuVisible = false; bool _popupMenuVisible = false;
@@ -268,18 +266,12 @@ class _WebTabletBodyEmailItemWidgetState
: Colors.transparent, : Colors.transparent,
tooltipMessage: AppLocalizations.of(context).more, tooltipMessage: AppLocalizations.of(context).more,
onTapActionAtPositionCallback: (position) { onTapActionAtPositionCallback: (position) {
if (_responsiveUtils
.isScreenWithShortestSide(context)) {
widget.onMoreActionClick
?.call(widget.presentationEmail, null);
} else {
_onPopupMenuVisibleChange(true); _onPopupMenuVisibleChange(true);
widget.onMoreActionClick widget.onMoreActionClick
?.call(widget.presentationEmail, position) ?.call(widget.presentationEmail, position)
.whenComplete( .whenComplete(
() => _onPopupMenuVisibleChange(false)); () => _onPopupMenuVisibleChange(false));
}
}, },
) )
], ],