Fixed keyboard closing and reopening when writing messages
This commit is contained in:
parent
7b4c698a8e
commit
7a411a34c9
@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:photo_view/photo_view.dart';
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ class ChatTextfield extends StatefulWidget {
|
|||||||
|
|
||||||
class _ChatTextfieldState extends State<ChatTextfield> {
|
class _ChatTextfieldState extends State<ChatTextfield> {
|
||||||
final TextEditingController _textBoxController = TextEditingController();
|
final TextEditingController _textBoxController = TextEditingController();
|
||||||
bool sending = false;
|
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
void _query() {
|
void _query() {
|
||||||
@ -128,7 +127,6 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
controller: _textBoxController,
|
controller: _textBoxController,
|
||||||
readOnly: sending,
|
|
||||||
maxLines: 7,
|
maxLines: 7,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -143,20 +141,24 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
|||||||
mini: true,
|
mini: true,
|
||||||
onPressed: (){
|
onPressed: (){
|
||||||
if(_textBoxController.text.isEmpty) return;
|
if(_textBoxController.text.isEmpty) return;
|
||||||
|
if(isLoading) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
sending = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) {
|
||||||
_query(),
|
_query();
|
||||||
_textBoxController.text = "",
|
|
||||||
setState(() {
|
setState(() {
|
||||||
sending = false;
|
isLoading = false;
|
||||||
}),
|
});
|
||||||
|
_textBoxController.text = "";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
child: const Icon(Icons.send, color: Colors.white, size: 18),
|
child: isLoading
|
||||||
|
? Container(padding: const EdgeInsets.all(10), child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||||
|
: const Icon(Icons.send, color: Colors.white, size: 18),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user