Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! TW-1787: Update context menu for pinned s…
Browse files Browse the repository at this point in the history
…creen
  • Loading branch information
hieutbui committed Jun 4, 2024
1 parent 9c7e2d3 commit cc55504
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1468,16 +1468,16 @@ class ChatController extends State<Chat>
event,
);
_handleStateContextMenu();
final selectedAction = await showTwakeContextMenu(
final selectedActionIndex = await showTwakeContextMenu(
offset: offset,
context: context,
listActions: listContextMenuActions,
onClose: _handleStateContextMenu,
);

if (selectedAction != null) {
if (selectedActionIndex != null && selectedActionIndex is int) {
_handleClickOnContextMenuItem(
listPopupMenuActions[selectedAction],
listPopupMenuActions[selectedActionIndex],
event,
);
}
Expand Down Expand Up @@ -1815,7 +1815,7 @@ class ChatController extends State<Chat>
listActions: listContextMenuActions,
);

if (selectedActionIndex != null) {
if (selectedActionIndex != null && selectedActionIndex is int) {
final selectedAction = listAppBarActions[selectedActionIndex];
onSelectedAppBarActions(selectedAction);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/chat_pinned_events/pinned_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class PinnedMessagesController extends State<PinnedMessages>
listActions: listActions,
onClose: _handleStateContextMenu,
);
if (selectedActionIndex != null) {
if (selectedActionIndex != null && selectedActionIndex is int) {
_handleClickOnContextMenuItem(
getPinnedMessagesActionsList(event)[selectedActionIndex],
event,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class ChatListController extends State<ChatList>
context: context,
listActions: listContextActions,
);
if (selectedActionIndex != null) {
if (selectedActionIndex != null && selectedActionIndex is int) {
_handleClickOnContextMenuItem(
listPopupActions[selectedActionIndex],
room,
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/context_menu/twake_context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class TwakeContextMenuState extends State<TwakeContextMenu>
child: action,
closeMenuAction: () {
closeContextMenu(
indexOfAction: widget.listActions
popResult: widget.listActions
.indexOf(action),
);
},
Expand Down Expand Up @@ -164,9 +164,9 @@ class TwakeContextMenuState extends State<TwakeContextMenu>
);
}

void closeContextMenu({int? indexOfAction}) {
void closeContextMenu({dynamic popResult}) {
_animationController.reverse().whenComplete(() {
Navigator.of(widget.dialogContext).pop<int>(indexOfAction);
Navigator.of(widget.dialogContext).pop<dynamic>(popResult);
});
}

Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/mixins/twake_context_menu_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import 'package:flutter/material.dart';

/// Show a [TwakeContextMenu] on the given [BuildContext]. For other parameters, see [TwakeContextMenu].
mixin TwakeContextMenuMixin {
Future<int?> showTwakeContextMenu({
Future<dynamic> showTwakeContextMenu({
required List<ContextMenuAction> listActions,
required Offset offset,
required BuildContext context,
double? verticalPadding,
VoidCallback? onClose,
}) async {
int? result;
await showDialog<int>(
dynamic result;
await showDialog(
context: context,
barrierColor: Colors.transparent,
barrierDismissible: false,
Expand Down

0 comments on commit cc55504

Please sign in to comment.