Skip to content

Commit

Permalink
TW-1787: Update context menu for chat list
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed Jun 7, 2024
1 parent 1e75ab6 commit 9068e6e
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/utils/tor_stub.dart'
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
import 'package:fluffychat/utils/twake_snackbar.dart';
import 'package:fluffychat/widgets/context_menu/context_menu_action.dart';
import 'package:fluffychat/widgets/layouts/agruments/app_adaptive_scaffold_body_args.dart';
import 'package:fluffychat/widgets/layouts/agruments/logged_in_other_account_body_args.dart';
import 'package:fluffychat/widgets/mixins/popup_context_menu_action_mixin.dart';
Expand Down Expand Up @@ -541,35 +542,47 @@ class ChatListController extends State<ChatList>
BuildContext context,
Room room,
TapDownDetails details,
) {
) async {
final offset = details.globalPosition;
showTwakeContextMenu(
final listPopupActions = _popupMenuActions(room);
final listContextActions = _mapPopupMenuActionsToContextMenuActions(
context,
room,
listPopupActions,
);
final selectedActionIndex = await showTwakeContextMenu(
offset: offset,
context: context,
builder: (context) => _popupMenuActionTile(context, room),
listActions: listContextActions,
);
if (selectedActionIndex != null) {
_handleClickOnContextMenuItem(
listPopupActions[selectedActionIndex],
room,
);
}
}

List<Widget> _popupMenuActionTile(
BuildContext context,
Room room,
) {
List<ChatListSelectionActions> _popupMenuActions(Room room) {
final listAction = [
if (!room.isInvitation) ...[
ChatListSelectionActions.read,
ChatListSelectionActions.pin,
],
ChatListSelectionActions.mute,
];
return listAction.map((action) {
return popupItemByTwakeAppRouter(
context,
action.getTitleContextMenuSelection(context, room),
iconAction: action.getIconContextMenuSelection(room),
onCallbackAction: () => _handleClickOnContextMenuItem(
action,
room,
),
return listAction;
}

List<ContextMenuAction> _mapPopupMenuActionsToContextMenuActions(
BuildContext context,
Room room,
List<ChatListSelectionActions> listActions,
) {
return listActions.map((action) {
return ContextMenuAction(
name: action.getTitleContextMenuSelection(context, room),
icon: action.getIconContextMenuSelection(room),
);
}).toList();
}
Expand Down

0 comments on commit 9068e6e

Please sign in to comment.