mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-11 19:17:04 +10:00
fix: <enter> to send giphy
This commit is contained in:
@@ -849,30 +849,45 @@ 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(
|
||||||
children: [
|
autofocus: true,
|
||||||
Expanded(
|
onKeyEvent: (node, event) {
|
||||||
child: ClipRRect(
|
if (event is KeyDownEvent &&
|
||||||
borderRadius: BorderRadius.circular(12),
|
(event.logicalKey == LogicalKeyboardKey.enter ||
|
||||||
child: GifMessage(
|
event.logicalKey == LogicalKeyboardKey.numpadEnter)) {
|
||||||
url:
|
_sendMessage();
|
||||||
'https://media.giphy.com/media/$gifId/giphy.gif',
|
return KeyEventResult.handled;
|
||||||
backgroundColor: Theme.of(
|
}
|
||||||
context,
|
return KeyEventResult.ignored;
|
||||||
).colorScheme.surfaceContainerHighest,
|
},
|
||||||
fallbackTextColor: Theme.of(
|
child: Row(
|
||||||
context,
|
children: [
|
||||||
).colorScheme.onSurface.withValues(alpha: 0.6),
|
Expanded(
|
||||||
maxSize: 160,
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: GifMessage(
|
||||||
|
url:
|
||||||
|
'https://media.giphy.com/media/$gifId/giphy.gif',
|
||||||
|
backgroundColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainerHighest,
|
||||||
|
fallbackTextColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurface.withValues(alpha: 0.6),
|
||||||
|
maxSize: 160,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
IconButton(
|
||||||
IconButton(
|
icon: const Icon(Icons.close),
|
||||||
icon: const Icon(Icons.close),
|
onPressed: () {
|
||||||
onPressed: () => _textController.clear(),
|
_textController.clear();
|
||||||
),
|
_textFieldFocusNode.requestFocus();
|
||||||
],
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,28 +340,43 @@ 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(
|
||||||
children: [
|
autofocus: true,
|
||||||
Expanded(
|
onKeyEvent: (node, event) {
|
||||||
child: ClipRRect(
|
if (event is KeyDownEvent &&
|
||||||
borderRadius: BorderRadius.circular(12),
|
(event.logicalKey == LogicalKeyboardKey.enter ||
|
||||||
child: GifMessage(
|
event.logicalKey == LogicalKeyboardKey.numpadEnter)) {
|
||||||
url:
|
_sendMessage(connector);
|
||||||
'https://media.giphy.com/media/$gifId/giphy.gif',
|
return KeyEventResult.handled;
|
||||||
backgroundColor:
|
}
|
||||||
colorScheme.surfaceContainerHighest,
|
return KeyEventResult.ignored;
|
||||||
fallbackTextColor: colorScheme.onSurface
|
},
|
||||||
.withValues(alpha: 0.6),
|
child: Row(
|
||||||
maxSize: 160,
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: GifMessage(
|
||||||
|
url:
|
||||||
|
'https://media.giphy.com/media/$gifId/giphy.gif',
|
||||||
|
backgroundColor:
|
||||||
|
colorScheme.surfaceContainerHighest,
|
||||||
|
fallbackTextColor: colorScheme.onSurface
|
||||||
|
.withValues(alpha: 0.6),
|
||||||
|
maxSize: 160,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
IconButton(
|
||||||
IconButton(
|
icon: const Icon(Icons.close),
|
||||||
icon: const Icon(Icons.close),
|
onPressed: () {
|
||||||
onPressed: () => _textController.clear(),
|
_textController.clear();
|
||||||
),
|
_textFieldFocusNode.requestFocus();
|
||||||
],
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user