Added file upload in talk
This commit is contained in:
@ -1,14 +1,17 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:loader_overlay/loader_overlay.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../api/marianumcloud/files-sharing/fileSharingApi.dart';
|
||||
import '../../../api/marianumcloud/files-sharing/fileSharingApiParams.dart';
|
||||
import '../../../api/marianumcloud/talk/sendMessage/sendMessage.dart';
|
||||
import '../../../api/marianumcloud/talk/sendMessage/sendMessageParams.dart';
|
||||
import '../../../model/chatList/chatProps.dart';
|
||||
import '../../../widget/filePick.dart';
|
||||
import '../files/fileUploadDialog.dart';
|
||||
|
||||
class ChatTextfield extends StatefulWidget {
|
||||
final String sendToToken;
|
||||
@ -23,27 +26,34 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
bool sending = false;
|
||||
bool isLoading = false;
|
||||
|
||||
void mediaUpload(String? path) {
|
||||
void _query() {
|
||||
Provider.of<ChatProps>(context, listen: false).run();
|
||||
}
|
||||
|
||||
void mediaUpload(String? path) async {
|
||||
context.loaderOverlay.hide();
|
||||
|
||||
if(path == null) {
|
||||
context.loaderOverlay.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Datei senden"),
|
||||
content: Image.file(File(path)),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
context.loaderOverlay.hide();
|
||||
}, child: const Text("Abbrechen")),
|
||||
TextButton(onPressed: () {
|
||||
context.loaderOverlay.hide();
|
||||
}, child: const Text("Senden")),
|
||||
],
|
||||
);
|
||||
});
|
||||
String filename = "${path.split("/").last.split(".").first}-${const Uuid().v4()}.${path.split(".").last}";
|
||||
String shareFolder = "MarianumMobile";
|
||||
showDialog(context: context, builder: (context) => FileUploadDialog(
|
||||
doShowFinish: false,
|
||||
fileName: filename,
|
||||
localPath: path,
|
||||
remotePath: [shareFolder],
|
||||
onUploadFinished: () {
|
||||
FileSharingApi().share(FileSharingApiParams(
|
||||
shareType: 10,
|
||||
shareWith: widget.sendToToken,
|
||||
path: "$shareFolder/$filename",
|
||||
//referenceId: "eae2d4497f0e1ffa1c71e6d86f7a59a43fd49198e799cc08a8a0fa8205b99969",
|
||||
//talkMetaData: "{\"messageType\":\"\"}"
|
||||
)).then((value) => _query());
|
||||
},
|
||||
), barrierDismissible: false);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -123,7 +133,7 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
sending = true;
|
||||
});
|
||||
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) => {
|
||||
Provider.of<ChatProps>(context, listen: false).run(),
|
||||
_query(),
|
||||
_textBoxController.text = "",
|
||||
setState(() {
|
||||
sending = false;
|
||||
|
Reference in New Issue
Block a user