merged to origin/devlop

This commit is contained in:
2024-04-07 15:58:51 +02:00
185 changed files with 500 additions and 866 deletions

View File

@ -26,14 +26,14 @@ class FileElement extends StatefulWidget {
const FileElement(this.file, this.path, this.refetch, {super.key});
static Future<DownloaderCore> download(BuildContext context, String remotePath, String name, Function(double) onProgress, Function(OpenResult) onDone) async {
Directory paths = await getTemporaryDirectory();
var paths = await getTemporaryDirectory();
var encodedPath = Uri.encodeComponent(remotePath);
encodedPath = encodedPath.replaceAll('%2F', '/');
String local = paths.path + Platform.pathSeparator + name;
var local = paths.path + Platform.pathSeparator + name;
DownloaderUtils options = DownloaderUtils(
var options = DownloaderUtils(
progressCallback: (current, total) {
final progress = (current / total) * 100;
onProgress(progress);
@ -52,7 +52,7 @@ class FileElement extends StatefulWidget {
);
return await Flowder.download(
"${await WebdavApi.webdavConnectString}$encodedPath",
'${await WebdavApi.webdavConnectString}$encodedPath',
options,
);
}
@ -89,8 +89,7 @@ class _FileElementState extends State<FileElement> {
}
@override
Widget build(BuildContext context) {
return ListTile(
Widget build(BuildContext context) => ListTile(
leading: CenteredLeading(
Icon(widget.file.isDirectory ? Icons.folder : Icons.description_outlined)
),
@ -100,9 +99,7 @@ class _FileElementState extends State<FileElement> {
onTap: () {
if(widget.file.isDirectory) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) {
return Files(widget.path.toList()..add(widget.file.name));
},
builder: (context) => Files(widget.path.toList()..add(widget.file.name)),
));
} else {
if(EndpointData().getEndpointMode() == EndpointMode.stage) {
@ -141,12 +138,10 @@ class _FileElementState extends State<FileElement> {
setState(() => percent = progress);
}, (result) {
if(result.type != ResultType.done) {
showDialog(context: context, builder: (context) {
return AlertDialog(
showDialog(context: context, builder: (context) => AlertDialog(
title: const Text('Download'),
content: Text(result.message),
);
});
));
}
setState(() {
@ -158,8 +153,7 @@ class _FileElementState extends State<FileElement> {
}
},
onLongPress: () {
showDialog(context: context, builder: (context) {
return SimpleDialog(
showDialog(context: context, builder: (context) => SimpleDialog(
children: [
ListTile(
leading: const Icon(Icons.delete_outline),
@ -189,9 +183,7 @@ class _FileElementState extends State<FileElement> {
),
),
],
);
});
));
},
);
}
}

View File

@ -113,7 +113,7 @@ class _FilesState extends State<Files> {
@override
Widget build(BuildContext context) {
List<CacheableFile> files = data?.sortBy(
var files = data?.sortBy(
sortOption: currentSort,
foldersToTop: Provider.of<SettingsProvider>(context).val().fileSettings.sortFoldersToTop,
reversed: currentSortDirection
@ -131,8 +131,7 @@ class _FilesState extends State<Files> {
// ),
PopupMenuButton<bool>(
icon: Icon(currentSortDirection ? Icons.text_rotate_up : Icons.text_rotation_down),
itemBuilder: (context) {
return [true, false].map((e) => PopupMenuItem<bool>(
itemBuilder: (context) => [true, false].map((e) => PopupMenuItem<bool>(
value: e,
enabled: e != currentSortDirection,
child: Row(
@ -142,8 +141,7 @@ class _FilesState extends State<Files> {
Text(e ? 'Aufsteigend' : 'Absteigend')
],
)
)).toList();
},
)).toList(),
onSelected: (e) {
setState(() {
currentSortDirection = e;
@ -153,8 +151,7 @@ class _FilesState extends State<Files> {
),
PopupMenuButton<SortOption>(
icon: const Icon(Icons.sort),
itemBuilder: (context) {
return SortOptions.options.keys.map((key) => PopupMenuItem<SortOption>(
itemBuilder: (context) => SortOptions.options.keys.map((key) => PopupMenuItem<SortOption>(
value: key,
enabled: key != currentSort,
child: Row(
@ -164,8 +161,7 @@ class _FilesState extends State<Files> {
Text(SortOptions.getOption(key).displayName),
],
)
)).toList();
},
)).toList(),
onSelected: (e) {
setState(() {
currentSort = e;
@ -179,8 +175,7 @@ class _FilesState extends State<Files> {
heroTag: 'uploadFile',
backgroundColor: Theme.of(context).primaryColor,
onPressed: () {
showDialog(context: context, builder: (context) {
return SimpleDialog(
showDialog(context: context, builder: (context) => SimpleDialog(
children: [
ListTile(
leading: const Icon(Icons.create_new_folder_outlined),
@ -234,8 +229,7 @@ class _FilesState extends State<Files> {
),
),
],
);
});
));
},
child: const Icon(Icons.add),
),
@ -249,7 +243,7 @@ class _FilesState extends State<Files> {
padding: EdgeInsets.zero,
itemCount: files.length,
itemBuilder: (context, index) {
CacheableFile file = files.toList()[index];
var file = files.toList()[index];
return FileElement(file, widget.path, _query);
},
),