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 TextEditingController _textBoxController = TextEditingController();
|
||||
bool sending = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -157,6 +158,7 @@ class _ChatViewState extends State<ChatView> {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _textBoxController,
|
||||
readOnly: sending,
|
||||
maxLines: null,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Nachricht",
|
||||
@ -165,12 +167,25 @@ class _ChatViewState extends State<ChatView> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(onPressed: () {
|
||||
SendMessage(widget.user.token, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
||||
Provider.of<ChatProps>(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<ChatProps>(context, listen: false).run(),
|
||||
_textBoxController.text = "",
|
||||
setState(() {
|
||||
sending = false;
|
||||
}),
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.send)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user