add back shift+enter for newline
This commit is contained in:
parent
735a3357d7
commit
b25840756d
1 changed files with 28 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
import "package:flutter/services.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:fluttertagger/fluttertagger.dart";
|
import "package:fluttertagger/fluttertagger.dart";
|
||||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
|
|
@ -135,7 +136,23 @@ class Composer extends HookConsumerWidget {
|
||||||
query.value = newQuery;
|
query.value = newQuery;
|
||||||
},
|
},
|
||||||
triggerCharacterAndStyles: {"@": style, "#": style},
|
triggerCharacterAndStyles: {"@": style, "#": style},
|
||||||
builder: (context, key) => TextField(
|
builder: (context, key) => Focus(
|
||||||
|
onKeyEvent: (_, event) {
|
||||||
|
if (event is KeyDownEvent &&
|
||||||
|
event.logicalKey ==
|
||||||
|
LogicalKeyboardKey.enter) {
|
||||||
|
final shiftPressed =
|
||||||
|
HardwareKeyboard.instance.isShiftPressed;
|
||||||
|
|
||||||
|
if (!shiftPressed) {
|
||||||
|
send();
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
},
|
||||||
|
child: TextField(
|
||||||
maxLines: 12,
|
maxLines: 12,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
|
|
@ -145,14 +162,11 @@ class Composer extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
controller: controller.value,
|
controller: controller.value,
|
||||||
key: key,
|
key: key,
|
||||||
onSubmitted: (_) => send(),
|
|
||||||
// Don't defocus on submit
|
|
||||||
onEditingComplete: () {},
|
|
||||||
textInputAction: .done,
|
|
||||||
focusNode: node,
|
focusNode: node,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: send,
|
onPressed: send,
|
||||||
icon: Icon(Icons.send),
|
icon: Icon(Icons.send),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue