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,24 +204,18 @@ abstract class BaseMailboxView extends GetWidget<MailboxController>
context, context,
mailboxNode.item, mailboxNode.item,
), ),
onDragItemAccepted: PlatformInfo.isMobile onDragItemAccepted: controller.handleDragItemAccepted,
? null onMenuActionClick: (position, mailboxNode) {
: controller.handleDragItemAccepted, return controller.openMailboxContextMenuAction(
onMenuActionClick: PlatformInfo.isMobile context,
? null position,
: (position, mailboxNode) { mailboxNode.item,
return controller.openMailboxContextMenuAction( );
context, },
position, onEmptyMailboxActionCallback: (mailboxNode) => controller.emptyMailboxAction(
mailboxNode.item, context,
); mailboxNode.item,
}, ),
onEmptyMailboxActionCallback: PlatformInfo.isMobile
? null
: (mailboxNode) => controller.emptyMailboxAction(
context,
mailboxNode.item,
),
)); ));
if (mailboxNode.hasChildren()) { if (mailboxNode.hasChildren()) {
@@ -75,53 +75,30 @@ extension HandleMailboxActionExtension on MailboxController {
final isSubAddressingSupported = final isSubAddressingSupported =
session?.isSubAddressingSupported(accountId) ?? false; session?.isSubAddressingSupported(accountId) ?? false;
if (responsiveUtils.isScreenWithShortestSide(context)) { final popupMenuActions = getListPopupMenuItemAction(
final contextMenuActions = listContextMenuItemAction( AppLocalizations.of(context),
mailbox, imagePaths,
mailboxDashBoardController.enableSpamReport, mailbox,
deletedMessageVaultSupported, mailboxDashBoardController.enableSpamReport,
isSubAddressingSupported, deletedMessageVaultSupported,
imagePaths, isSubAddressingSupported,
AppLocalizations.of(context), );
);
if (contextMenuActions.isEmpty) return Future.value(); if (popupMenuActions.isEmpty) return Future.value();
return openBottomSheetContextMenuAction( final popupMenuItems = popupMenuActions.map((menuAction) {
context: context, return PopupMenuItem(
itemActions: contextMenuActions, padding: EdgeInsets.zero,
onContextMenuActionClick: (menuAction) => handleMailboxAction( child: PopupMenuItemActionWidget(
context, menuAction: menuAction,
menuAction.action, menuActionClick: (menuAction) {
mailbox, popBack();
handleMailboxAction(context, menuAction.action, mailbox);
},
), ),
); );
} else { }).toList();
final popupMenuActions = getListPopupMenuItemAction(
AppLocalizations.of(context),
imagePaths,
mailbox,
mailboxDashBoardController.enableSpamReport,
deletedMessageVaultSupported,
isSubAddressingSupported,
);
if (popupMenuActions.isEmpty) return Future.value(); return openPopupMenuAction(context, position, popupMenuItems);
final popupMenuItems = popupMenuActions.map((menuAction) {
return PopupMenuItem(
padding: EdgeInsets.zero,
child: PopupMenuItemActionWidget(
menuAction: menuAction,
menuActionClick: (menuAction) {
popBack();
handleMailboxAction(context, menuAction.action, mailbox);
},
),
);
}).toList();
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)) { _onPopupMenuVisibleChange(true);
widget.onMoreActionClick?.call(widget.presentationEmail, null);
} else {
_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 _onPopupMenuVisibleChange(true);
.isScreenWithShortestSide(context)) {
widget.onMoreActionClick
?.call(widget.presentationEmail, null);
} else {
_onPopupMenuVisibleChange(true);
widget.onMoreActionClick widget.onMoreActionClick
?.call(widget.presentationEmail, position) ?.call(widget.presentationEmail, position)
.whenComplete( .whenComplete(
() => _onPopupMenuVisibleChange(false)); () => _onPopupMenuVisibleChange(false));
}
}, },
) )
], ],