updated project linter-rules and enforced them
This commit is contained in:
@ -6,7 +6,7 @@ import 'package:flowder/flowder.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:marianum_mobile/widget/infoDialog.dart';
|
||||
import '../../../widget/infoDialog.dart';
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@ -29,7 +29,7 @@ class FileElement extends StatefulWidget {
|
||||
Directory paths = await getTemporaryDirectory();
|
||||
|
||||
var encodedPath = Uri.encodeComponent(remotePath);
|
||||
encodedPath = encodedPath.replaceAll("%2F", "/");
|
||||
encodedPath = encodedPath.replaceAll('%2F', '/');
|
||||
|
||||
String local = paths.path + Platform.pathSeparator + name;
|
||||
|
||||
@ -44,7 +44,7 @@ class FileElement extends StatefulWidget {
|
||||
onDone: () {
|
||||
//Future<OpenResult> result = OpenFile.open(local); // TODO legacy - refactor: remove onDone parameter
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => FileViewer(path: local)));
|
||||
onDone(OpenResult(message: "File viewer opened", type: ResultType.done));
|
||||
onDone(OpenResult(message: 'File viewer opened', type: ResultType.done));
|
||||
// result.then((value) => {
|
||||
// onDone(value)
|
||||
// });
|
||||
@ -71,21 +71,21 @@ class _FileElementState extends State<FileElement> {
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
child: const Text("Download:"),
|
||||
child: const Text('Download:'),
|
||||
),
|
||||
Expanded(
|
||||
child: LinearProgressIndicator(value: percent/100),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 10),
|
||||
child: Text("${percent.round()}%"),
|
||||
child: Text('${percent.round()}%'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return widget.file.isDirectory
|
||||
? Text("geändert ${Jiffy.parseFromDateTime(widget.file.modifiedAt ?? DateTime.now()).fromNow()}")
|
||||
: Text("${filesize(widget.file.size)}, ${Jiffy.parseFromDateTime(widget.file.modifiedAt ?? DateTime.now()).fromNow()}");
|
||||
? Text('geändert ${Jiffy.parseFromDateTime(widget.file.modifiedAt ?? DateTime.now()).fromNow()}')
|
||||
: Text('${filesize(widget.file.size)}, ${Jiffy.parseFromDateTime(widget.file.modifiedAt ?? DateTime.now()).fromNow()}');
|
||||
}
|
||||
|
||||
@override
|
||||
@ -106,17 +106,17 @@ class _FileElementState extends State<FileElement> {
|
||||
));
|
||||
} else {
|
||||
if(EndpointData().getEndpointMode() == EndpointMode.stage) {
|
||||
InfoDialog.show(context, "Virtuelle Dateien im Staging Prozess können nicht heruntergeladen werden!");
|
||||
InfoDialog.show(context, 'Virtuelle Dateien im Staging Prozess können nicht heruntergeladen werden!');
|
||||
return;
|
||||
}
|
||||
if(widget.file.currentlyDownloading) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ConfirmDialog(
|
||||
title: "Download abbrechen?",
|
||||
content: "Möchtest du den Download abbrechen?",
|
||||
cancelButton: "Nein",
|
||||
confirmButton: "Ja, Abbrechen",
|
||||
title: 'Download abbrechen?',
|
||||
content: 'Möchtest du den Download abbrechen?',
|
||||
cancelButton: 'Nein',
|
||||
confirmButton: 'Ja, Abbrechen',
|
||||
onConfirm: () {
|
||||
downloadCore?.then((value) {
|
||||
if(!value.isCancelled) value.cancel();
|
||||
@ -143,7 +143,7 @@ class _FileElementState extends State<FileElement> {
|
||||
if(result.type != ResultType.done) {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Download"),
|
||||
title: const Text('Download'),
|
||||
content: Text(result.message),
|
||||
);
|
||||
});
|
||||
@ -163,12 +163,12 @@ class _FileElementState extends State<FileElement> {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete_outline),
|
||||
title: const Text("Löschen"),
|
||||
title: const Text('Löschen'),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDialog(context: context, builder: (context) => ConfirmDialog(
|
||||
title: "Element löschen?",
|
||||
content: "Das Element wird unwiederruflich gelöscht.",
|
||||
title: 'Element löschen?',
|
||||
content: 'Das Element wird unwiederruflich gelöscht.',
|
||||
onConfirm: () {
|
||||
WebdavApi.webdav
|
||||
.then((value) => value.delete(PathUri.parse(widget.file.path)))
|
||||
@ -181,7 +181,7 @@ class _FileElementState extends State<FileElement> {
|
||||
visible: !kReleaseMode,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.share_outlined),
|
||||
title: const Text("Teilen"),
|
||||
title: const Text('Teilen'),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
UnimplementedDialog.show(context);
|
||||
|
@ -43,8 +43,8 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
setState(() {
|
||||
state = FileUploadState.checkConflict;
|
||||
});
|
||||
List<WebDavResponse> result = (await webdavClient.propfind(PathUri.parse(widget.remotePath.join("/")))).responses;
|
||||
if(result.any((element) => element.href!.endsWith("/$targetFileName"))) {
|
||||
List<WebDavResponse> result = (await webdavClient.propfind(PathUri.parse(widget.remotePath.join('/')))).responses;
|
||||
if(result.any((element) => element.href!.endsWith('/$targetFileName'))) {
|
||||
setState(() {
|
||||
state = FileUploadState.conflict;
|
||||
});
|
||||
@ -57,7 +57,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
}
|
||||
|
||||
Future<HttpClientResponse> uploadTask = webdavClient.putFile(File(widget.localPath), FileStat.statSync(widget.localPath), PathUri.parse(fullRemotePath)); // TODO use onProgress from putFile
|
||||
uploadTask.then((value) => Future<HttpClientResponse?>.value(value)).catchError((e) {
|
||||
uploadTask.then(Future<HttpClientResponse?>.value).catchError((e) {
|
||||
setState(() {
|
||||
state = FileUploadState.error;
|
||||
});
|
||||
@ -67,7 +67,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
|
||||
cancelableOperation = CancelableOperation<HttpClientResponse>.fromFuture(
|
||||
uploadTask,
|
||||
onCancel: () => log("Upload cancelled"),
|
||||
onCancel: () => log('Upload cancelled'),
|
||||
);
|
||||
|
||||
cancelableOperation!.then((value) {
|
||||
@ -88,7 +88,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
targetFileName = widget.fileName;
|
||||
remoteFolderName = widget.remotePath.isNotEmpty ? widget.remotePath.last : "/";
|
||||
remoteFolderName = widget.remotePath.isNotEmpty ? widget.remotePath.last : '/';
|
||||
fileNameController.text = widget.fileName;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
Widget build(BuildContext context) {
|
||||
if(state == FileUploadState.naming) {
|
||||
return AlertDialog(
|
||||
title: const Text("Datei hochladen"),
|
||||
title: const Text('Datei hochladen'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@ -107,7 +107,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
},
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
labelText: "Dateiname",
|
||||
labelText: 'Dateiname',
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -115,10 +115,10 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Abbrechen")),
|
||||
}, child: const Text('Abbrechen')),
|
||||
TextButton(onPressed: () async {
|
||||
upload();
|
||||
}, child: const Text("Hochladen")),
|
||||
}, child: const Text('Hochladen')),
|
||||
],
|
||||
|
||||
);
|
||||
@ -127,7 +127,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
if(state == FileUploadState.conflict) {
|
||||
return AlertDialog(
|
||||
icon: const Icon(Icons.error_outline),
|
||||
title: const Text("Datei konflikt"),
|
||||
title: const Text('Datei konflikt'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@ -139,10 +139,10 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
setState(() {
|
||||
state = FileUploadState.naming;
|
||||
});
|
||||
}, child: const Text("Datei umbenennen")),
|
||||
}, child: const Text('Datei umbenennen')),
|
||||
TextButton(onPressed: () {
|
||||
upload(override: true);
|
||||
}, child: const Text("Datei überschreiben")),
|
||||
}, child: const Text('Datei überschreiben')),
|
||||
],
|
||||
|
||||
);
|
||||
@ -151,15 +151,15 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
if(state == FileUploadState.upload || state == FileUploadState.checkConflict) {
|
||||
return AlertDialog(
|
||||
icon: const Icon(Icons.upload),
|
||||
title: const Text("Hochladen"),
|
||||
title: const Text('Hochladen'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: state == FileUploadState.upload,
|
||||
replacement: const Text("Prüfe auf dateikonflikte..."),
|
||||
child: const Text("Upload läuft!\nDies kann je nach Dateigröße einige Zeit dauern...", textAlign: TextAlign.center),
|
||||
replacement: const Text('Prüfe auf dateikonflikte...'),
|
||||
child: const Text('Upload läuft!\nDies kann je nach Dateigröße einige Zeit dauern...', textAlign: TextAlign.center),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const CircularProgressIndicator()
|
||||
@ -183,7 +183,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
}
|
||||
return AlertDialog(
|
||||
icon: const Icon(Icons.done),
|
||||
title: const Text("Upload fertig"),
|
||||
title: const Text('Upload fertig'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@ -193,7 +193,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Fertig")),
|
||||
}, child: const Text('Fertig')),
|
||||
],
|
||||
|
||||
);
|
||||
@ -202,23 +202,23 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
|
||||
if(state == FileUploadState.error) {
|
||||
return AlertDialog(
|
||||
icon: const Icon(Icons.error_outline),
|
||||
title: const Text("Fehler"),
|
||||
title: const Text('Fehler'),
|
||||
content: const Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text("Es ist ein Fehler aufgetreten!", textAlign: TextAlign.center),
|
||||
Text('Es ist ein Fehler aufgetreten!', textAlign: TextAlign.center),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Schlißen")),
|
||||
}, child: const Text('Schlißen')),
|
||||
],
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
throw UnimplementedError("Invalid state");
|
||||
throw UnimplementedError('Invalid state');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -43,17 +43,17 @@ enum SortOption {
|
||||
class SortOptions {
|
||||
static Map<SortOption, BetterSortOption> options = {
|
||||
SortOption.name: BetterSortOption(
|
||||
displayName: "Name",
|
||||
displayName: 'Name',
|
||||
icon: Icons.sort_by_alpha_outlined,
|
||||
compare: (CacheableFile a, CacheableFile b) => a.name.compareTo(b.name)
|
||||
),
|
||||
SortOption.date: BetterSortOption(
|
||||
displayName: "Datum",
|
||||
displayName: 'Datum',
|
||||
icon: Icons.history_outlined,
|
||||
compare: (CacheableFile a, CacheableFile b) => a.modifiedAt!.compareTo(b.modifiedAt!)
|
||||
),
|
||||
SortOption.size: BetterSortOption(
|
||||
displayName: "Größe",
|
||||
displayName: 'Größe',
|
||||
icon: Icons.sd_card_outlined,
|
||||
compare: (CacheableFile a, CacheableFile b) {
|
||||
if(a.isDirectory || b.isDirectory) return a.isDirectory ? 1 : 0;
|
||||
@ -88,7 +88,7 @@ class _FilesState extends State<Files> {
|
||||
|
||||
void _query() {
|
||||
ListFilesCache(
|
||||
path: widget.path.isEmpty ? "/" : widget.path.join("/"),
|
||||
path: widget.path.isEmpty ? '/' : widget.path.join('/'),
|
||||
onUpdate: (ListFilesResponse d) {
|
||||
if(!context.mounted) return; // prevent setState when widget is possibly already disposed
|
||||
d.files.removeWhere((element) => element.name.isEmpty || element.name == widget.path.lastOrNull());
|
||||
@ -109,7 +109,7 @@ class _FilesState extends State<Files> {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.path.isNotEmpty ? widget.path.last : "Dateien"),
|
||||
title: Text(widget.path.isNotEmpty ? widget.path.last : 'Dateien'),
|
||||
actions: [
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.search),
|
||||
@ -127,7 +127,7 @@ class _FilesState extends State<Files> {
|
||||
children: [
|
||||
Icon(e ? Icons.text_rotate_up : Icons.text_rotation_down, color: Theme.of(context).colorScheme.onSurface),
|
||||
const SizedBox(width: 15),
|
||||
Text(e ? "Aufsteigend" : "Absteigend")
|
||||
Text(e ? 'Aufsteigend' : 'Absteigend')
|
||||
],
|
||||
)
|
||||
)).toList();
|
||||
@ -164,7 +164,7 @@ class _FilesState extends State<Files> {
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: "uploadFile",
|
||||
heroTag: 'uploadFile',
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
onPressed: () {
|
||||
showDialog(context: context, builder: (context) {
|
||||
@ -172,29 +172,29 @@ class _FilesState extends State<Files> {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.create_new_folder_outlined),
|
||||
title: const Text("Ordner erstellen"),
|
||||
title: const Text('Ordner erstellen'),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDialog(context: context, builder: (context) {
|
||||
var inputController = TextEditingController();
|
||||
return AlertDialog(
|
||||
title: const Text("Neuer Ordner"),
|
||||
title: const Text('Neuer Ordner'),
|
||||
content: TextField(
|
||||
controller: inputController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: "Name",
|
||||
labelText: 'Name',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Abbrechen")),
|
||||
}, child: const Text('Abbrechen')),
|
||||
TextButton(onPressed: () {
|
||||
WebdavApi.webdav.then((webdav) {
|
||||
webdav.mkcol(PathUri.parse("${widget.path.join("/")}/${inputController.text}")).then((value) => _query());
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Ordner erstellen")),
|
||||
}, child: const Text('Ordner erstellen')),
|
||||
],
|
||||
);
|
||||
});
|
||||
@ -202,12 +202,10 @@ class _FilesState extends State<Files> {
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.upload_file),
|
||||
title: const Text("Aus Dateien hochladen"),
|
||||
title: const Text('Aus Dateien hochladen'),
|
||||
onTap: () {
|
||||
context.loaderOverlay.show();
|
||||
FilePick.documentPick().then((value) {
|
||||
mediaUpload(value);
|
||||
});
|
||||
FilePick.documentPick().then(mediaUpload);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
@ -215,7 +213,7 @@ class _FilesState extends State<Files> {
|
||||
visible: !Platform.isIOS,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.add_a_photo_outlined),
|
||||
title: const Text("Aus Gallerie hochladen"),
|
||||
title: const Text('Aus Gallerie hochladen'),
|
||||
onTap: () {
|
||||
context.loaderOverlay.show();
|
||||
FilePick.galleryPick().then((value) {
|
||||
@ -231,7 +229,7 @@ class _FilesState extends State<Files> {
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
body: data == null ? const LoadingSpinner() : data!.files.isEmpty ? const PlaceholderView(icon: Icons.folder_off_rounded, text: "Der Ordner ist leer") : LoaderOverlay(
|
||||
body: data == null ? const LoadingSpinner() : data!.files.isEmpty ? const PlaceholderView(icon: Icons.folder_off_rounded, text: 'Der Ordner ist leer') : LoaderOverlay(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () {
|
||||
_query();
|
||||
@ -258,6 +256,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, onUploadFinished: () => _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