fix: <enter> to send giphy

This commit is contained in:
Ben Allfree
2026-02-22 09:20:20 -08:00
parent b3ad54f296
commit 3ca53e967c
2 changed files with 72 additions and 42 deletions
+17 -2
View File
@@ -849,7 +849,18 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
builder: (context, value, child) { builder: (context, value, child) {
final gifId = _parseGifId(value.text); final gifId = _parseGifId(value.text);
if (gifId != null) { if (gifId != null) {
return Row( return Focus(
autofocus: true,
onKeyEvent: (node, event) {
if (event is KeyDownEvent &&
(event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.numpadEnter)) {
_sendMessage();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: Row(
children: [ children: [
Expanded( Expanded(
child: ClipRRect( child: ClipRRect(
@@ -870,9 +881,13 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
const SizedBox(width: 8), const SizedBox(width: 8),
IconButton( IconButton(
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
onPressed: () => _textController.clear(), onPressed: () {
_textController.clear();
_textFieldFocusNode.requestFocus();
},
), ),
], ],
),
); );
} }
+17 -2
View File
@@ -340,7 +340,18 @@ class _ChatScreenState extends State<ChatScreen> {
builder: (context, value, child) { builder: (context, value, child) {
final gifId = _parseGifId(value.text); final gifId = _parseGifId(value.text);
if (gifId != null) { if (gifId != null) {
return Row( return Focus(
autofocus: true,
onKeyEvent: (node, event) {
if (event is KeyDownEvent &&
(event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.numpadEnter)) {
_sendMessage(connector);
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: Row(
children: [ children: [
Expanded( Expanded(
child: ClipRRect( child: ClipRRect(
@@ -359,9 +370,13 @@ class _ChatScreenState extends State<ChatScreen> {
const SizedBox(width: 8), const SizedBox(width: 8),
IconButton( IconButton(
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
onPressed: () => _textController.clear(), onPressed: () {
_textController.clear();
_textFieldFocusNode.requestFocus();
},
), ),
], ],
),
); );
} }