diff --git a/lib/screen/pages/talk/chatView.dart b/lib/screen/pages/talk/chatView.dart index 76a4b4b..575851c 100644 --- a/lib/screen/pages/talk/chatView.dart +++ b/lib/screen/pages/talk/chatView.dart @@ -49,6 +49,7 @@ class _ChatViewState extends State { final ScrollController _listController = ScrollController(); final TextEditingController _textBoxController = TextEditingController(); + bool sending = false; @override void initState() { @@ -157,6 +158,7 @@ class _ChatViewState extends State { Expanded( child: TextField( controller: _textBoxController, + readOnly: sending, maxLines: null, decoration: const InputDecoration( hintText: "Nachricht", @@ -165,12 +167,25 @@ class _ChatViewState extends State { ), ), ), - IconButton(onPressed: () { - SendMessage(widget.user.token, SendMessageParams(_textBoxController.text)).run().then((value) => { - Provider.of(context, listen: false).run(), - _textBoxController.text = "", - }); - }, icon: const Icon(Icons.send)) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: sending ? const Center(child: CircularProgressIndicator()) : IconButton( + onPressed: () { + if(_textBoxController.text.isEmpty) return; + setState(() { + sending = true; + }); + SendMessage(widget.user.token, SendMessageParams(_textBoxController.text)).run().then((value) => { + Provider.of(context, listen: false).run(), + _textBoxController.text = "", + setState(() { + sending = false; + }), + }); + }, + icon: const Icon(Icons.send) + ), + ) ], ), )