Skip to content

Commit

Permalink
fix(ui): extends predicates to mobile (#1947)
Browse files Browse the repository at this point in the history
* extends predicates to mobile

* added changelog entry
  • Loading branch information
deven98 authored Jun 14, 2024
1 parent 1806fab commit a7f6652
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added `StreamMediaAttachmentBuilder` widget to show media attachments in a message.
- Added export for `message_widget_content_components.dart` to allow for easier customization of message content components.
- Fixed error when channel image is not set.
- Extends predicates for sending and clearing messages to mobile.

## 7.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,32 @@ class StreamMessageInput extends StatefulWidget {
FocusNode node,
KeyEvent event,
) {
// On desktop/web, send the message when the user presses the enter key.
return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.enter;
if (CurrentPlatform.isWeb ||
CurrentPlatform.isMacOS ||
CurrentPlatform.isWindows ||
CurrentPlatform.isLinux) {
// On desktop/web, send the message when the user presses the enter key.
return event is KeyUpEvent &&
event.logicalKey == LogicalKeyboardKey.enter;
}

return false;
}

static bool _defaultClearQuotedMessageKeyPredicate(
FocusNode node,
KeyEvent event,
) {
// On desktop/web, clear the quoted message when the user presses the escape key.
return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.escape;
if (CurrentPlatform.isWeb ||
CurrentPlatform.isMacOS ||
CurrentPlatform.isWindows ||
CurrentPlatform.isLinux) {
// On desktop/web, clear the quoted message when the user presses the escape key.
return event is KeyUpEvent &&
event.logicalKey == LogicalKeyboardKey.escape;
}

return false;
}

@override
Expand Down Expand Up @@ -908,7 +924,11 @@ class StreamMessageInputState extends State<StreamMessageInput>
onKeyEvent: _handleKeyPressed,
child: child!,
),
mobile: (context, child) => child,
mobile: (context, child) => Focus(
skipTraversal: true,
onKeyEvent: _handleKeyPressed,
child: child!,
),
child: StreamMessageTextField(
key: const Key('messageInputText'),
maxLines: widget.maxLines,
Expand Down

0 comments on commit a7f6652

Please sign in to comment.