diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index 4eceac1..ff98d4f 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -219,6 +219,13 @@ + + + + + + @@ -282,6 +289,13 @@ + + + + + + @@ -359,6 +373,13 @@ + + + + + + @@ -436,6 +457,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1060,6 +1116,7 @@ + @@ -1069,6 +1126,7 @@ + @@ -1078,6 +1136,7 @@ + @@ -1087,6 +1146,11 @@ + + + + + diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 8a3ee45..a1271f3 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -22,6 +22,11 @@ + + + + + diff --git a/lib/screen/pages/talk/chatBubble.dart b/lib/screen/pages/talk/chatBubble.dart index c96dff9..30d564a 100644 --- a/lib/screen/pages/talk/chatBubble.dart +++ b/lib/screen/pages/talk/chatBubble.dart @@ -15,7 +15,7 @@ class ChatBubble { color: Color(0xffd4eaf4), borderWidth: 1, elevation: 2, - margin: BubbleEdges.only(bottom: 15), + margin: BubbleEdges.only(bottom: 20, top: 10), alignment: Alignment.center, ); @@ -25,7 +25,7 @@ class ChatBubble { color: seamless ? Colors.transparent : Colors.white, borderWidth: seamless ? 0 : 1, elevation: seamless ? 0 : 1, - margin: const BubbleEdges.only(bottom: 15, left: 10, right: 50), + margin: const BubbleEdges.only(bottom: 10, left: 10, right: 50), alignment: Alignment.topLeft, ); } @@ -36,7 +36,7 @@ class ChatBubble { color: seamless ? Colors.transparent : const Color(0xffd9fdd3), borderWidth: seamless ? 0 : 1, elevation: seamless ? 0 : 1, - margin: const BubbleEdges.only(bottom: 15, right: 10, left: 50), + margin: const BubbleEdges.only(bottom: 10, right: 10, left: 50), alignment: Alignment.topRight, ); } diff --git a/lib/screen/pages/talk/chatList.dart b/lib/screen/pages/talk/chatList.dart index 506e88b..6d9771a 100644 --- a/lib/screen/pages/talk/chatList.dart +++ b/lib/screen/pages/talk/chatList.dart @@ -5,6 +5,7 @@ import 'package:jiffy/jiffy.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/chat/richObjectStringProcessor.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/room/getRoomResponse.dart'; import 'package:marianum_mobile/data/chatList/chatListProps.dart'; +import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -91,13 +92,11 @@ class _ChatListState extends State { ), leading: circleAvatar, onTap: () async { - Navigator.of(context).push(MaterialPageRoute(builder: (context) { - return ChatView( - room: chatRoom, - selfId: username, - avatar: circleAvatar, - ); - })); + PersistentNavBarNavigator.pushNewScreen( + context, + screen: ChatView(room: chatRoom, selfId: username, avatar: circleAvatar), + withNavBar: false + ); }, )); } diff --git a/lib/screen/pages/talk/chatTextfield.dart b/lib/screen/pages/talk/chatTextfield.dart index ea91587..83b50f9 100644 --- a/lib/screen/pages/talk/chatTextfield.dart +++ b/lib/screen/pages/talk/chatTextfield.dart @@ -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 { @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: [ + 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: [ + 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(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(context, listen: false).run(), - _textBoxController.text = "", - setState(() { - sending = false; - }), - }); - }, - icon: const Icon(Icons.send) - ), - ) - ], - ), + ), + ], ); } } diff --git a/lib/widget/filePick.dart b/lib/widget/filePick.dart new file mode 100644 index 0000000..3ec9938 --- /dev/null +++ b/lib/widget/filePick.dart @@ -0,0 +1,22 @@ +import 'dart:developer'; + +import 'package:file_picker/file_picker.dart'; +import 'package:image_picker/image_picker.dart'; + +class FilePick { + static final _picker = ImagePicker(); + + static Future galleryPick() async { + final XFile? pickedImage = await _picker.pickImage(source: ImageSource.gallery); + if (pickedImage != null) { + log("Picked ${pickedImage.path} (${pickedImage.mimeType})"); + return pickedImage; + } + return null; + } + + static Future documentPick() async { + FilePickerResult? result = await FilePicker.platform.pickFiles(); + return result?.files.single.path; + } +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 58fda17..99cc9a0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,8 @@ dependencies: url: https://github.com/Harsh223/flowder.git persistent_bottom_nav_bar: ^5.0.2 badges: ^3.0.2 + image_picker: ^0.8.7+4 + file_picker: ^5.2.11 dependency_overrides: xml: ^6.2.2