Added file upload in talk
This commit is contained in:
@ -11,8 +11,11 @@ class FileUploadDialog extends StatefulWidget {
|
||||
final String localPath;
|
||||
final List<String> remotePath;
|
||||
final String fileName;
|
||||
final void Function() triggerReload;
|
||||
const FileUploadDialog({Key? key, required this.localPath, required this.remotePath, required this.fileName, required this.triggerReload}) : super(key: key);
|
||||
final void Function() onUploadFinished;
|
||||
|
||||
final bool doShowFinish;
|
||||
|
||||
const FileUploadDialog({Key? key, required this.localPath, required this.remotePath, required this.fileName, required this.onUploadFinished, this.doShowFinish = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FileUploadDialog> createState() => _FileUploadDialogState();
|
||||
@ -40,6 +43,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
setState(() {
|
||||
state = FileUploadState.checkConflict;
|
||||
});
|
||||
await (await WebdavApi.webdav).mkdirs(widget.remotePath.join("/"));
|
||||
List<WebDavResponse> result = (await webdavClient.ls(widget.remotePath.join("/"))).responses;
|
||||
if(result.any((element) => element.href!.endsWith("/$targetFileName"))) {
|
||||
setState(() {
|
||||
@ -174,9 +178,13 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
}
|
||||
|
||||
if(state == FileUploadState.done) {
|
||||
widget.triggerReload();
|
||||
widget.onUploadFinished();
|
||||
if(!widget.doShowFinish) {
|
||||
Navigator.of(context).pop();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return AlertDialog(
|
||||
icon: const Icon(Icons.upload),
|
||||
icon: const Icon(Icons.done),
|
||||
title: const Text("Upload fertig"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -243,6 +243,6 @@ class _FilesState extends State<Files> {
|
||||
}
|
||||
|
||||
var fileName = path.split(Platform.pathSeparator).last;
|
||||
showDialog(context: context, builder: (context) => FileUploadDialog(localPath: path, remotePath: widget.path, fileName: fileName, triggerReload: () => _query()), barrierDismissible: false);
|
||||
showDialog(context: context, builder: (context) => FileUploadDialog(localPath: path, remotePath: widget.path, fileName: fileName, onUploadFinished: () => _query()), barrierDismissible: false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user