From 9369defe114266077b0e4e0663e8ccb9fa100337 Mon Sep 17 00:00:00 2001 From: lightrabbit Date: Mon, 24 Oct 2022 17:28:28 +0800 Subject: [PATCH] feat(ui): show custom action on context menu (#1353) * fix(ui): Show message custom actions on desktop context menu. * fix(ui): don't handle keyboard shortcut when callback is null. Co-authored-by: Salvatore Giordano --- packages/stream_chat_flutter/CHANGELOG.md | 5 +++++ .../src/keyboard_shortcuts/keyboard_shortcut_runner.dart | 9 +++++---- .../lib/src/message_widget/message_widget.dart | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 92266e73..c225c677 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,5 +1,10 @@ ## Upcoming +🐞 Fixed + +- Show message custom actions on desktop context menu. +- Can move cursor by left/right arrow in StreamMessageInput on web/desktop. + ✅ Added - `VideoAttachment` now uses `thumbUrl` to show the thumbnail diff --git a/packages/stream_chat_flutter/lib/src/keyboard_shortcuts/keyboard_shortcut_runner.dart b/packages/stream_chat_flutter/lib/src/keyboard_shortcuts/keyboard_shortcut_runner.dart index 178c2690..706adad4 100644 --- a/packages/stream_chat_flutter/lib/src/keyboard_shortcuts/keyboard_shortcut_runner.dart +++ b/packages/stream_chat_flutter/lib/src/keyboard_shortcuts/keyboard_shortcut_runner.dart @@ -35,10 +35,11 @@ class KeyboardShortcutRunner extends StatelessWidget { return FocusableActionDetector( autofocus: true, shortcuts: { - enterKeySet: EnterKeyIntent(), - escapeKeySet: EscapeKeyIntent(), - rightArrowKeySet: RightArrowKeyIntent(), - leftArrowKeySet: LeftArrowKeyIntent(), + if (onEnterKeypress != null) enterKeySet: EnterKeyIntent(), + if (onEscapeKeypress != null) escapeKeySet: EscapeKeyIntent(), + if (onRightArrowKeypress != null) + rightArrowKeySet: RightArrowKeyIntent(), + if (onLeftArrowKeypress != null) leftArrowKeySet: LeftArrowKeyIntent(), }, actions: { EnterKeyIntent: CallbackAction( diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart index 7d73fbfc..9a054e39 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart @@ -1033,6 +1033,11 @@ class _StreamMessageWidgetState extends State } }, ), + ...widget.customActions.map((e) => StreamChatContextMenuItem( + leading: e.leading, + title: e.title, + onClick: () => e.onTap?.call(widget.message), + )) ]; }