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
+26 -15
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,20 +97,27 @@ class _MessageInputState extends State<MessageInput> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return SafeArea(
child: Padding( child: GestureDetector(
padding: const EdgeInsets.all(8.0), onPanUpdate: (details) {
child: Stack( if (details.delta.dy > 0) {
overflow: Overflow.visible, _focusNode.unfocus();
children: <Widget>[ }
_buildBorder(context), },
Column( child: Padding(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.all(8.0),
children: [ child: Stack(
_buildAttachments(), overflow: Overflow.visible,
_buildTextField(context), children: <Widget>[
], _buildBorder(context),
), Column(
], crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildAttachments(),
_buildTextField(context),
],
),
],
),
), ),
), ),
); );
@@ -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) {