updated chatTextfield.dart design and added file and gallery picker
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:marianum_mobile/widget/filePick.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../api/marianumcloud/talk/sendMessage/sendMessage.dart';
|
||||
@ -19,44 +22,94 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Theme.of(context).dividerColor,
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _textBoxController,
|
||||
readOnly: sending,
|
||||
maxLines: null,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Nachricht",
|
||||
border: OutlineInputBorder(),
|
||||
labelText: "",
|
||||
),
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 10, bottom: 10, top: 10),
|
||||
height: 60,
|
||||
width: double.infinity,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: (){
|
||||
showDialog(context: context, builder: (context) {
|
||||
return SimpleDialog(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.file_open),
|
||||
title: const Text("Aus Dateien auswählen"),
|
||||
onTap: () {
|
||||
FilePick.documentPick().then((value) {
|
||||
log(value ?? "?");
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.image),
|
||||
title: const Text("Aus Gallerie auswählen"),
|
||||
onTap: () {
|
||||
FilePick.galleryPick().then((value) {
|
||||
log(value?.path ?? "?");
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 30,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: const Icon(Icons.add, color: Colors.white, size: 20, ),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _textBoxController,
|
||||
readOnly: sending,
|
||||
maxLines: 10,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Nachricht schreiben...",
|
||||
hintStyle: TextStyle(color: Colors.black54),
|
||||
border: InputBorder.none
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
FloatingActionButton(
|
||||
onPressed: (){
|
||||
if(_textBoxController.text.isEmpty) return;
|
||||
setState(() {
|
||||
sending = true;
|
||||
});
|
||||
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
||||
Provider.of<ChatProps>(context, listen: false).run(),
|
||||
_textBoxController.text = "",
|
||||
setState(() {
|
||||
sending = false;
|
||||
}),
|
||||
});
|
||||
},
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
elevation: 0,
|
||||
child: const Icon(Icons.send, color: Colors.white, size: 18),
|
||||
),
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
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.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
||||
Provider.of<ChatProps>(context, listen: false).run(),
|
||||
_textBoxController.text = "",
|
||||
setState(() {
|
||||
sending = false;
|
||||
}),
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.send)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user