refs #22: add keyboardType parameter and close keyboard using drag gesture

This commit is contained in:
Salvatore Giordano
2020-04-10 10:08:25 +02:00
parent 4abdcfc335
commit 11765cfd7f
+12 -1
View File
@@ -62,6 +62,7 @@ class MessageInput extends StatefulWidget {
this.parentMessage, this.parentMessage,
this.editMessage, this.editMessage,
this.maxHeight = 150, this.maxHeight = 150,
this.keyboardType = TextInputType.multiline,
}) : super(key: key); }) : super(key: key);
/// Message to edit /// Message to edit
@@ -76,6 +77,9 @@ class MessageInput extends StatefulWidget {
/// Maximum Height for the TextField to grow before it starts scrolling /// Maximum Height for the TextField to grow before it starts scrolling
final double maxHeight; final double maxHeight;
/// The keyboard type assigned to the TextField
final TextInputType keyboardType;
@override @override
_MessageInputState createState() => _MessageInputState(); _MessageInputState createState() => _MessageInputState();
} }
@@ -93,6 +97,12 @@ class _MessageInputState extends State<MessageInput> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return SafeArea(
child: GestureDetector(
onPanUpdate: (details) {
if (details.delta.dy > 0) {
_focusNode.unfocus();
}
},
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Stack( child: Stack(
@@ -109,6 +119,7 @@ class _MessageInputState extends State<MessageInput> {
], ],
), ),
), ),
),
); );
} }
@@ -147,7 +158,7 @@ class _MessageInputState extends State<MessageInput> {
onSubmitted: (_) { onSubmitted: (_) {
_sendMessage(context); _sendMessage(context);
}, },
keyboardType: TextInputType.text, keyboardType: widget.keyboardType,
controller: _textController, controller: _textController,
focusNode: _focusNode, focusNode: _focusNode,
onChanged: (s) { onChanged: (s) {