Fix Textfield sending issues
This commit is contained in:
parent
693b226bdc
commit
b464ad4e60
@ -49,6 +49,7 @@ class _ChatViewState extends State<ChatView> {
|
|||||||
|
|
||||||
final ScrollController _listController = ScrollController();
|
final ScrollController _listController = ScrollController();
|
||||||
final TextEditingController _textBoxController = TextEditingController();
|
final TextEditingController _textBoxController = TextEditingController();
|
||||||
|
bool sending = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -157,6 +158,7 @@ class _ChatViewState extends State<ChatView> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _textBoxController,
|
controller: _textBoxController,
|
||||||
|
readOnly: sending,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: "Nachricht",
|
hintText: "Nachricht",
|
||||||
@ -165,12 +167,25 @@ class _ChatViewState extends State<ChatView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(onPressed: () {
|
Padding(
|
||||||
SendMessage(widget.user.token, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
Provider.of<ChatProps>(context, listen: false).run(),
|
child: sending ? const Center(child: CircularProgressIndicator()) : IconButton(
|
||||||
_textBoxController.text = "",
|
onPressed: () {
|
||||||
});
|
if(_textBoxController.text.isEmpty) return;
|
||||||
}, icon: const Icon(Icons.send))
|
setState(() {
|
||||||
|
sending = true;
|
||||||
|
});
|
||||||
|
SendMessage(widget.user.token, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
||||||
|
Provider.of<ChatProps>(context, listen: false).run(),
|
||||||
|
_textBoxController.text = "",
|
||||||
|
setState(() {
|
||||||
|
sending = false;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.send)
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user