Stabilize frontend login. Make chat messages multiline.
This commit is contained in:
1 parent
5bbdfe8747
commit
3f37f727af
6 files changed
+71
-31
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'app_menu.dart';
|
||||
import 'styles.dart';
|
||||
import 'backend.dart';
|
||||
@@ -36,6 +37,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
String? _title;
|
||||
List<Message> _messages = [];
|
||||
final TextEditingController _textController = TextEditingController();
|
||||
final FocusNode _inputFocusNode = FocusNode();
|
||||
StreamSubscription? _chatSubscription;
|
||||
|
||||
@override
|
||||
@@ -137,23 +139,36 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _textController,
|
||||
decoration: inputDecoration(),
|
||||
onSubmitted: sendMessage, // Send message on Enter key
|
||||
child: KeyboardListener(
|
||||
focusNode: _inputFocusNode,
|
||||
onKeyEvent: (event) {
|
||||
// TODO: Probably doing this in the input focus node would be cleaner
|
||||
if (HardwareKeyboard.instance.isControlPressed && HardwareKeyboard.instance.isLogicalKeyPressed(LogicalKeyboardKey.enter)) {
|
||||
sendMessage(_textController.text);
|
||||
_textController.clear();
|
||||
//return KeyEventResult.handled;
|
||||
}
|
||||
//return KeyEventResult.ignored;
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _textController,
|
||||
maxLines: null,
|
||||
decoration: inputDecoration(),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
sendMessage(_textController.text);
|
||||
},
|
||||
child: Text('Send'),
|
||||
),
|
||||
],
|
||||
SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
sendMessage(_textController.text);
|
||||
_textController.clear();
|
||||
},
|
||||
child: Text('Send'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user