added upload with multiple files
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:loader_overlay/loader_overlay.dart';
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart';
|
||||
@ -15,8 +17,8 @@ import '../../../storage/base/settingsProvider.dart';
|
||||
import '../../../widget/loadingSpinner.dart';
|
||||
import '../../../widget/placeholderView.dart';
|
||||
import '../../../widget/filePick.dart';
|
||||
import 'fileUploadDialog.dart';
|
||||
import 'fileElement.dart';
|
||||
import 'filesUploadDialog.dart';
|
||||
|
||||
class Files extends StatefulWidget {
|
||||
final List<String> path;
|
||||
@ -90,7 +92,8 @@ class _FilesState extends State<Files> {
|
||||
ListFilesCache(
|
||||
path: widget.path.isEmpty ? '/' : widget.path.join('/'),
|
||||
onUpdate: (ListFilesResponse d) {
|
||||
if(!context.mounted) return; // prevent setState when widget is possibly already disposed
|
||||
log('_query');
|
||||
if(!context.mounted) return; // prevent setState when widget is possibly already disposed
|
||||
d.files.removeWhere((element) => element.name.isEmpty || element.name == widget.path.lastOrNull());
|
||||
setState(() {
|
||||
data = d;
|
||||
@ -99,6 +102,18 @@ class _FilesState extends State<Files> {
|
||||
);
|
||||
}
|
||||
|
||||
void mediaUpload(List<String>? paths) async {
|
||||
if(paths == null) return;
|
||||
|
||||
pushScreen(
|
||||
context,
|
||||
withNavBar: false,
|
||||
screen: FilesUploadDialog(filePaths: paths, remotePath: widget.path.join('/'), onUploadFinished: (uploadedFilePaths) => _query),
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<CacheableFile> files = data?.sortBy(
|
||||
@ -149,7 +164,7 @@ class _FilesState extends State<Files> {
|
||||
children: [
|
||||
Icon(SortOptions.getOption(key).icon, color: Theme.of(context).colorScheme.onSurface),
|
||||
const SizedBox(width: 15),
|
||||
Text(SortOptions.getOption(key).displayName)
|
||||
Text(SortOptions.getOption(key).displayName),
|
||||
],
|
||||
)
|
||||
)).toList();
|
||||
@ -204,7 +219,6 @@ class _FilesState extends State<Files> {
|
||||
leading: const Icon(Icons.upload_file),
|
||||
title: const Text('Aus Dateien hochladen'),
|
||||
onTap: () {
|
||||
context.loaderOverlay.show();
|
||||
FilePick.documentPick().then(mediaUpload);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -215,9 +229,8 @@ class _FilesState extends State<Files> {
|
||||
leading: const Icon(Icons.add_a_photo_outlined),
|
||||
title: const Text('Aus Gallerie hochladen'),
|
||||
onTap: () {
|
||||
context.loaderOverlay.show();
|
||||
FilePick.galleryPick().then((value) {
|
||||
mediaUpload(value?.path);
|
||||
if(value != null) mediaUpload([value.path]);
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -247,15 +260,4 @@ class _FilesState extends State<Files> {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void mediaUpload(String? path) async {
|
||||
context.loaderOverlay.hide();
|
||||
|
||||
if(path == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var fileName = path.split(Platform.pathSeparator).last;
|
||||
showDialog(context: context, builder: (context) => FileUploadDialog(localPath: path, remotePath: widget.path, fileName: fileName, onUploadFinished: _query), barrierDismissible: false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user