add back shift+enter for newline

This commit is contained in:
Henry Hiles 2026-06-05 19:40:12 -04:00
commit b25840756d
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -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,21 +136,34 @@ class Composer extends HookConsumerWidget {
query.value = newQuery; query.value = newQuery;
}, },
triggerCharacterAndStyles: {"@": style, "#": style}, triggerCharacterAndStyles: {"@": style, "#": style},
builder: (context, key) => TextField( builder: (context, key) => Focus(
maxLines: 12, onKeyEvent: (_, event) {
minLines: 1, if (event is KeyDownEvent &&
autofocus: true, event.logicalKey ==
decoration: .new( LogicalKeyboardKey.enter) {
hintText: "Your message here...", final shiftPressed =
border: .none, HardwareKeyboard.instance.isShiftPressed;
if (!shiftPressed) {
send();
return KeyEventResult.handled;
}
}
return KeyEventResult.ignored;
},
child: TextField(
maxLines: 12,
minLines: 1,
autofocus: true,
decoration: .new(
hintText: "Your message here...",
border: .none,
),
controller: controller.value,
key: key,
focusNode: node,
), ),
controller: controller.value,
key: key,
onSubmitted: (_) => send(),
// Don't defocus on submit
onEditingComplete: () {},
textInputAction: .done,
focusNode: node,
), ),
), ),
), ),