Skip to content

Commit

Permalink
feat: remove forward from quick action in web
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian KOUNE committed Oct 3, 2023
1 parent 56942b2 commit 1ca08f3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 24 deletions.
24 changes: 18 additions & 6 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1382,12 +1382,9 @@ class ChatController extends State<Chat>
openingPopupMenu.value = !openingPopupMenu.value;
}

List<ContextMenuItemChatAction> listHorizontalActionMenuBuilder() {
final listAction = [
ChatHorizontalActionMenu.reply,
ChatHorizontalActionMenu.forward,
ChatHorizontalActionMenu.more,
];
List<ContextMenuItemChatAction> _buildListHorizontalActionMenu(
List<ChatHorizontalActionMenu> listAction,
) {
return listAction
.map(
(action) => ContextMenuItemChatAction(
Expand All @@ -1398,6 +1395,21 @@ class ChatController extends State<Chat>
.toList();
}

List<ContextMenuItemChatAction> listHorizontalActionMenuBuilder() {
if (PlatformInfos.isMobile) {
return _buildListHorizontalActionMenu([
ChatHorizontalActionMenu.reply,
ChatHorizontalActionMenu.forward,
ChatHorizontalActionMenu.more,
]);
} else {
return _buildListHorizontalActionMenu([
ChatHorizontalActionMenu.reply,
ChatHorizontalActionMenu.more,
]);
}
}

void handleHorizontalActionMenu(
BuildContext context,
ChatHorizontalActionMenu actions,
Expand Down
57 changes: 39 additions & 18 deletions lib/pages/chat/events/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,24 +590,10 @@ class Message extends StatelessWidget {
color: Colors.transparent,
borderRadius: BorderRadius.circular(24),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: listHorizontalActionMenu.map((item) {
return Padding(
padding: const EdgeInsetsDirectional.all(4),
child: TwakeIconButton(
icon: item.action.getIcon(),
imagePath: item.action.getImagePath(),
tooltip: item.action.getTitle(context),
preferBelow: false,
onTapDown: (context) => onMenuAction!(
context,
item.action,
event,
),
),
);
}).toList(),
child: _ListHorizontalActionMenuWidget(
listHorizontalActionMenu: listHorizontalActionMenu,
onMenuAction: onMenuAction,
event: event,
),
),
);
Expand Down Expand Up @@ -703,6 +689,41 @@ class Message extends StatelessWidget {
}
}

class _ListHorizontalActionMenuWidget extends StatelessWidget {
const _ListHorizontalActionMenuWidget({
required this.listHorizontalActionMenu,
required this.onMenuAction,
required this.event,
});

final List<ContextMenuItemChatAction> listHorizontalActionMenu;
final OnMenuAction? onMenuAction;
final Event event;

@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: listHorizontalActionMenu.map((item) {
return Padding(
padding: const EdgeInsetsDirectional.all(4),
child: TwakeIconButton(
icon: item.action.getIcon(),
imagePath: item.action.getImagePath(),
tooltip: item.action.getTitle(context),
preferBelow: false,
onTapDown: (context) => onMenuAction!(
context,
item.action,
event,
),
),
);
}).toList(),
);
}
}

class ReplyIconWidget extends StatelessWidget {
final bool isOwnMessage;

Expand Down

0 comments on commit 1ca08f3

Please sign in to comment.