diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index e51100e..ac29e15 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -44,6 +44,13 @@
+
+
+
+
+
+
+
@@ -163,6 +170,13 @@
+
+
+
+
+
+
+
@@ -170,6 +184,13 @@
+
+
+
+
+
+
+
@@ -191,13 +212,6 @@
-
-
-
-
-
-
-
@@ -429,6 +443,13 @@
+
+
+
+
+
+
+
@@ -555,6 +576,13 @@
+
+
+
+
+
+
+
@@ -786,6 +814,13 @@
+
+
+
+
+
+
+
@@ -800,10 +835,10 @@
-
+
-
+
@@ -838,12 +873,15 @@
+
+
+
@@ -861,11 +899,12 @@
+
+
-
@@ -914,6 +953,7 @@
+
@@ -946,9 +986,9 @@
+
-
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart
new file mode 100644
index 0000000..99f2c6d
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart
@@ -0,0 +1,46 @@
+// import 'package:json_annotation/json_annotation.dart';
+// import 'package:webdav_client/webdav_client.dart';
+//
+// part 'cacheableFile.g.dart';
+//
+// @JsonSerializable(explicitToJson: true)
+// class CacheableFile {
+// String? path;
+// bool? isDir;
+// String? name;
+// String? mimeType;
+// int? size;
+// String? eTag;
+// DateTime? cTime;
+// DateTime? mTime;
+//
+// CacheableFile(this.path, this.isDir, this.name, this.mimeType, this.size,
+// this.eTag, this.cTime, this.mTime);
+//
+// CacheableFile.fromDavFile(File file) {
+// path = file.path;
+// isDir = file.isDir;
+// name = file.name;
+// mimeType = file.mimeType;
+// size = file.size;
+// eTag = file.eTag;
+// cTime = file.cTime;
+// mTime = file.mTime;
+// }
+//
+// File toDavFile() {
+// return File(
+// path: path,
+// isDir: isDir,
+// name: name,
+// mimeType: mimeType,
+// size: size,
+// eTag: eTag,
+// cTime: cTime,
+// mTime: mTime
+// );
+// }
+//
+// factory CacheableFile.fromJson(Map json) => _$CacheableFileFromJson(json);
+// Map toJson() => _$CacheableFileToJson(this);
+// }
\ No newline at end of file
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.g.dart b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.g.dart
new file mode 100644
index 0000000..cf64503
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.g.dart
@@ -0,0 +1,31 @@
+// // GENERATED CODE - DO NOT MODIFY BY HAND
+//
+// part of 'cacheableFile.dart';
+//
+// // **************************************************************************
+// // JsonSerializableGenerator
+// // **************************************************************************
+//
+// CacheableFile _$CacheableFileFromJson(Map json) =>
+// CacheableFile(
+// json['path'] as String?,
+// json['isDir'] as bool?,
+// json['name'] as String?,
+// json['mimeType'] as String?,
+// json['size'] as int?,
+// json['eTag'] as String?,
+// json['cTime'] == null ? null : DateTime.parse(json['cTime'] as String),
+// json['mTime'] == null ? null : DateTime.parse(json['mTime'] as String),
+// );
+//
+// Map _$CacheableFileToJson(CacheableFile instance) =>
+// {
+// 'path': instance.path,
+// 'isDir': instance.isDir,
+// 'name': instance.name,
+// 'mimeType': instance.mimeType,
+// 'size': instance.size,
+// 'eTag': instance.eTag,
+// 'cTime': instance.cTime?.toIso8601String(),
+// 'mTime': instance.mTime?.toIso8601String(),
+// };
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart
new file mode 100644
index 0000000..497e097
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFiles.dart
@@ -0,0 +1,21 @@
+//
+// import 'package:marianum_mobile/api/apiParams.dart';
+// import 'package:marianum_mobile/api/apiResponse.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/webdavApi.dart';
+// import 'package:webdav_client/webdav_client.dart';
+//
+// class ListFiles extends WebdavApi {
+// ListFilesParams params;
+//
+// ListFiles(this.params) : super(params);
+//
+// @override
+// Future run() async {
+// Set files = (await (await WebdavApi.webdav).readDir(params.path)).map((e) => CacheableFile.fromDavFile(e)).toSet();
+//
+// return ListFilesResponse(files);
+// }
+// }
\ No newline at end of file
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart
new file mode 100644
index 0000000..d69c586
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart
@@ -0,0 +1,33 @@
+// import 'dart:convert';
+// import 'dart:developer';
+//
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFiles.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
+// import 'package:marianum_mobile/api/requestCache.dart';
+// import 'package:webdav_client/webdav_client.dart';
+//
+// class ListFilesCache extends RequestCache {
+// String path;
+//
+// ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
+// String cacheName = path.replaceAll(RegExp("[^A-Za-z0-9]"), "_"); //TODO this is very evil, "/ü/" > "___" also "/ä/" > "___"
+// log(cacheName);
+//
+// start("MarianumMobile", "wd-folder-$cacheName");
+// }
+//
+// @override
+// Future onLoad() async {
+// log("Loading remote data");
+// ListFilesResponse data = await ListFiles(ListFilesParams(path)).run();
+// return data;
+// }
+//
+// @override
+// ListFilesResponse onLocalData(String json) {
+// log("Loading local data");
+// return ListFilesResponse.fromJson(jsonDecode(json));
+// }
+//
+// }
\ No newline at end of file
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart
new file mode 100644
index 0000000..8f839f9
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart
@@ -0,0 +1,15 @@
+import 'package:json_annotation/json_annotation.dart';
+
+import '../../../../apiParams.dart';
+
+part 'listFilesParams.g.dart';
+
+@JsonSerializable(explicitToJson: true)
+class ListFilesParams extends ApiParams {
+ String path;
+
+ ListFilesParams(this.path);
+
+ factory ListFilesParams.fromJson(Map json) => _$ListFilesParamsFromJson(json);
+ Map toJson() => _$ListFilesParamsToJson(this);
+}
\ No newline at end of file
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.g.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.g.dart
new file mode 100644
index 0000000..e72b05c
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesParams.g.dart
@@ -0,0 +1,17 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'listFilesParams.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+ListFilesParams _$ListFilesParamsFromJson(Map json) =>
+ ListFilesParams(
+ json['path'] as String,
+ );
+
+Map _$ListFilesParamsToJson(ListFilesParams instance) =>
+ {
+ 'path': instance.path,
+ };
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart
new file mode 100644
index 0000000..656c688
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart
@@ -0,0 +1,16 @@
+// import 'package:json_annotation/json_annotation.dart';
+// import 'package:marianum_mobile/api/apiResponse.dart';
+//
+// import 'cacheableFile.dart';
+//
+// part 'listFilesResponse.g.dart';
+//
+// @JsonSerializable(explicitToJson: true)
+// class ListFilesResponse extends ApiResponse {
+// Set files;
+//
+// ListFilesResponse(this.files);
+//
+// factory ListFilesResponse.fromJson(Map json) => _$ListFilesResponseFromJson(json);
+// Map toJson() => _$ListFilesResponseToJson(this);
+// }
\ No newline at end of file
diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.g.dart b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.g.dart
new file mode 100644
index 0000000..092886a
--- /dev/null
+++ b/lib/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.g.dart
@@ -0,0 +1,19 @@
+// // GENERATED CODE - DO NOT MODIFY BY HAND
+//
+// part of 'listFilesResponse.dart';
+//
+// // **************************************************************************
+// // JsonSerializableGenerator
+// // **************************************************************************
+//
+// ListFilesResponse _$ListFilesResponseFromJson(Map json) =>
+// ListFilesResponse(
+// (json['files'] as List)
+// .map((e) => CacheableFile.fromJson(e as Map))
+// .toSet(),
+// );
+//
+// Map _$ListFilesResponseToJson(ListFilesResponse instance) =>
+// {
+// 'files': instance.files.map((e) => e.toJson()).toList(),
+// };
diff --git a/lib/data/files/filesProps.dart b/lib/data/files/filesProps.dart
new file mode 100644
index 0000000..5007bce
--- /dev/null
+++ b/lib/data/files/filesProps.dart
@@ -0,0 +1,31 @@
+// import 'dart:developer';
+//
+// import 'package:marianum_mobile/api/apiResponse.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart';
+// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
+// import 'package:marianum_mobile/data/dataHolder.dart';
+//
+// class FilesProps extends DataHolder {
+//
+// ListFilesResponse? _listFilesResponse;
+// ListFilesResponse get listFilesResponse => _listFilesResponse!;
+//
+// @override
+// List properties() {
+// return [_listFilesResponse];
+// }
+//
+// @override
+// void run() {
+// log("Query Cache");
+// ListFilesCache(
+// path: "/",
+// onUpdate: (ListFilesResponse data) => {
+// log("Got cache response"),
+// _listFilesResponse = data,
+// notifyListeners(),
+// }
+// );
+// }
+//
+// }
\ No newline at end of file
diff --git a/lib/main.dart b/lib/main.dart
index e2edf71..8136ba2 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:marianum_mobile/data/files/filesProps.dart';
import 'package:marianum_mobile/data/timetable/timetableProps.dart';
import 'package:marianum_mobile/screen/login/login.dart';
import 'package:marianum_mobile/widget/loadingSpinner.dart';
@@ -38,6 +39,7 @@ Future main() async {
ChangeNotifierProvider(create: (context) => TimetableProps()),
ChangeNotifierProvider(create: (context) => ChatListProps()),
ChangeNotifierProvider(create: (context) => ChatProps()),
+ //ChangeNotifierProvider(create: (context) => FilesProps()),
],
child: const Main(),
)
diff --git a/lib/screen/pages/files/files.dart b/lib/screen/pages/files/files.dart
index 1104312..21e2a67 100644
--- a/lib/screen/pages/files/files.dart
+++ b/lib/screen/pages/files/files.dart
@@ -1,11 +1,13 @@
+import 'dart:developer';
+
import 'package:flutter/material.dart';
+import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesCache.dart';
+import 'package:marianum_mobile/data/files/filesProps.dart';
import 'package:marianum_mobile/widget/loadingPacket.dart';
+import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart';
-import 'package:webdav_client/webdav_client.dart';
-
-import '../../../dataOld/incommingPackets/fileListPacket.dart';
-import '../../../widget/loadingSpinner.dart';
+import 'package:webdav/webdav.dart';
class Files extends StatefulWidget {
const Files({Key? key}) : super(key: key);
@@ -15,256 +17,110 @@ class Files extends StatefulWidget {
}
class _FilesState extends State {
- // List path = List.empty(growable: true);
- // List files = List.empty(growable: true);
- //
- // var client = newClient(
- // "https://cloud.marianum-fulda.de/remote.php/dav/files/***REMOVED***/",
- // user: "***REMOVED***",
- // password: "***REMOVED***",
- // );
-
@override
void initState() {
- Provider.of(context, listen: false).invoke();
+ WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
+ //Provider.of(context, listen: false).run();
+ });
+
super.initState();
- // client.setHeaders(
- // {
- // "Authorization": "Bearer",
- // "User-Agent": "Marianum Fulda/Alpha0.1 (Development build) ; https://mhsl.eu/id.html",
- // }
- // );
- //
- // path.add("/");
- // Future.delayed(Duration.zero).then((context) => updatePath());
}
- // void homeFolder() {
- // path.clear();
- // path.add("/");
- // updatePath();
- // }
- //
- // void popFolder() {
- // if(path.length == 1) return;
- // path.removeLast();
- // updatePath();
- // }
- //
- // void enterFolder(String sub) {
- // path.add(sub);
- // updatePath();
- // }
- //
- // void updatePath() {
- //
- // final files = client.readDir(path.join("/"));
- //
- // showDialog(
- // context: context,
- // barrierDismissible: false,
- // builder: (BuildContext context) {
- // return const LoadingSpinner();
- // }
- // );
- //
- // files.then((value) =>
- // setState(() {
- // Navigator.pop(context);
- // this.files.clear();
- // this.files = value;
- // })
- // );
- // }
-
@override
Widget build(BuildContext context) {
- // List items = List.empty(growable: true);
- //
- // var counter = 0;
- // for (final file in files) {
- // bool isDir = file.isDir ?? false;
- // String name = file.name ?? "?";
- //
- // items.add(ListTile(
- // title: Text(file.name ?? "?"),
- // leading: Icon(isDir ? Icons.folder_outlined : Icons.file_copy),
- // trailing: Icon(isDir ? Icons.arrow_right : null),
- // onTap: () {
- // enterFolder(file.name ?? "");
- // },
- // onLongPress: () {
- // setState(() {
- // items[counter] = ListTile(
- // title: Text(file.name ?? "?"),
- // trailing: const Icon(Icons.delete),
- // );
- // });
- // },
- // ));
- //
- // }
- //
- // items.insert(0, AppBar(
- // leading: path.length == 1 ? null : IconButton(
- // icon: const Icon(Icons.keyboard_arrow_left),
- // onPressed: () {
- // popFolder();
- // },
- // ),
- // actions: [
- // IconButton(
- // icon: const Icon(Icons.home),
- // onPressed: () {
- // homeFolder();
- // },
- // ),
- //
- // IconButton(
- // icon: const Icon(Icons.refresh),
- // onPressed: () {
- // updatePath();
- // },
- // )
- // ],
- //
- // title: Text(path.length == 1 ? "Dateien" : path.last),
- // ));
- //
- // return ListView(
- // children: items,
+
+ // log("NEW CLIENT");
+ // Client client = newClient(
+ // "https://***REMOVED***:***REMOVED***@cloud.marianum-fulda.de/remote.php/dav/files/***REMOVED***/",
+ // user: "***REMOVED***",
+ // password: "***REMOVED***",
+ // debug: true
// );
+ //
+ // // client.setHeaders(
+ // // {
+ // // "User-Agent": "Marianum Fulda/Alpha0.1 (Development build) ; https://mhsl.eu/id.html",
+ // // }
+ // // );
+ //
+ // log("DATA");
+ // log(client.readDir("/").toString());
- return Consumer(
- builder: (context, data, child) {
- List entries = List.empty(growable: true);
+ // Future> files = Client("https://cloud.marianum-fulda.de/remote.php/dav/files/***REMOVED***", "***REMOVED***", "***REMOVED***").ls();
+ // log(files.toString());
+ // log("REQUEST FINISH");
+ //
+ // files.then((asd) => {
+ // asd.forEach((element) {
+ // log(element.name);
+ // }),
+ // });
- data.entries.forEach((element) {
- entries.add(ListTile(
- title: Text(element.name),
- leading: Icon(element.isFolder ? Icons.folder : Icons.file_copy_outlined),
- onTap: () {
- if(element.isFolder) {
- Provider.of(context, listen: false).invoke(
- data: {
- "path": element.path
- },
- indicateLoading: true,
- );
- } else {
- // TODO: Open an File
- }
- },
-
- onLongPress: () {
- showModalBottomSheet(
- context: context,
- builder: (context) {
- return ListView(
- children: [
- ListTile(
- leading: Icon(Icons.delete),
- title: Text("'${element.name.replaceRange(20, element.name.length, " ...")}' Löschen"),
- ),
- const ListTile(
- leading: Icon(Icons.share),
- title: Text("Teilen"),
- )
- ],
- );
- },
- );
- },
- ));
- });
+ // var client = NextcloudClient("https://cloud.marianum-fulda.de", username: "***REMOVED***", password: "***REMOVED***");
+ //
+ // //client.baseHeaders.putIfAbsent("Authorization", () => "Basic ***REMOVED***");
+ // //client.authentication?.headers.putIfAbsent("Authorization", () => "Basic ***REMOVED***");
+ // //client.webdav.rootClient.baseHeaders.putIfAbsent("Authorization", () => "Basic ***REMOVED***");
+ //
+ // client.webdav.ls("/").then((value) => () {
+ // log("TEST");
+ // value.forEach((element) {
+ // log(element.name);
+ // });
+ // });
- return Scaffold(
- appBar: AppBar(
- leading: IconButton(
- icon: const Icon(Icons.arrow_back_outlined),
- onPressed: () {
- Provider.of(context, listen: false).invoke(
- data: {
- "path": data.lastPath
- },
- indicateLoading: true,
- );
- }
- ),
- title: Text(data.lastPath),
- actions: [
- IconButton(
- onPressed: () {
- Provider.of(context, listen: false).invoke(indicateLoading: true);
- },
- icon: const Icon(Icons.home)
- ),
- PopupMenuButton(
- icon: Icon(Icons.add),
- itemBuilder: (context) {
- return [
- const PopupMenuItem(
- value: 0,
- child: ListTile(
- leading: Icon(Icons.folder),
- title: Text("Ordner erstellen"),
- ),
- ),
- const PopupMenuItem(
- value: 1,
- child: ListTile(
- leading: Icon(Icons.upload),
- title: Text("Datei Hochladen"),
- ),
- )
- ];
- },
- )
- ],
- ),
-
- floatingActionButton: FloatingActionButton.small(
- onPressed: () {
- showModalBottomSheet(
- isScrollControlled: true,
- context: context,
- backgroundColor: Colors.transparent,
- builder: (context) {
- return Container(
- height: MediaQuery.of(context).size.height * 0.3,
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(25.0),
- topRight: Radius.circular(25.0),
- )
- ),
- child: ListView(
- children: const [
- ListTile(
- leading: Icon(Icons.create_new_folder_sharp),
- title: Text("Neuer Ordner"),
- ),
- ListTile(
- leading: Icon(Icons.upload),
- title: Text("Hochladen"),
- )
- ],
- ),
- );
- },
- );
- },
- backgroundColor: Theme.of(context).primaryColor,
- child: const Icon(Icons.add),
- ),
-
- body: LoadingPacket(packet: data, child: ListView(children: entries)),
- );
- },
+ return const Center(
+ child: Text("Currently not implemented!"),
);
+
+ // return Consumer(
+ // builder: (context, data, child) {
+ //
+ // if(data.primaryLoading()) {
+ // return const Center(child: CircularProgressIndicator());
+ // }
+ //
+ // List entries = List.empty(growable: true);
+ //
+ // data.listFilesResponse.files.forEach((element) {
+ // entries.add(ListTile(
+ // title: Text(element.name ?? "?"),
+ // leading: Icon(element.isDir ?? false ? Icons.folder : Icons.file_copy_outlined),
+ // onTap: () {
+ // if(element.isDir ?? false) {
+ // // TODO: Open Folder
+ // } else {
+ // // TODO: Open an File
+ // }
+ // },
+ //
+ // onLongPress: () {
+ // showModalBottomSheet(
+ // context: context,
+ // builder: (context) {
+ // return ListView(
+ // children: [
+ // ListTile(
+ // leading: const Icon(Icons.delete),
+ // title: Text("'${element.name?.replaceRange(20, element.name?.length, " ...")}' Löschen"),
+ // ),
+ // const ListTile(
+ // leading: Icon(Icons.share),
+ // title: Text("Teilen"),
+ // )
+ // ],
+ // );
+ // },
+ // );
+ // },
+ // ));
+ // });
+ //
+ // return ListView(children: entries);
+ // },
+ // );
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index af72320..c09eb30 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -40,7 +40,6 @@ dependencies:
flutter_login: ^4.1.0
bubble: ^1.2.1
http: ^0.13.5
- webdav_client: ^1.1.8
shared_preferences: ^2.0.15
provider: ^6.0.4
web_socket_channel: ^2.2.0
@@ -49,6 +48,18 @@ dependencies:
json_annotation: ^4.8.0
localstore: ^1.2.3
intl: ^0.17.0
+ webdav: #^1.0.9
+ git:
+ url: https://github.com/timestee/dart-webdav.git
+ ref: 1a70d3f7236484ed170f688980020b344d729d39
+ nextcloud:
+ git:
+ url: https://github.com/provokateurin/nextcloud-neon
+ path: packages/nextcloud
+
+dependency_overrides:
+ xml: ^6.2.2
+
dev_dependencies:
flutter_test: