Prepare webdavApi.dart implementation
This commit is contained in:
		@@ -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<String, dynamic> json) => _$CacheableFileFromJson(json);
 | 
			
		||||
//   Map<String, dynamic> toJson() => _$CacheableFileToJson(this);
 | 
			
		||||
// }
 | 
			
		||||
@@ -0,0 +1,31 @@
 | 
			
		||||
// // GENERATED CODE - DO NOT MODIFY BY HAND
 | 
			
		||||
//
 | 
			
		||||
// part of 'cacheableFile.dart';
 | 
			
		||||
//
 | 
			
		||||
// // **************************************************************************
 | 
			
		||||
// // JsonSerializableGenerator
 | 
			
		||||
// // **************************************************************************
 | 
			
		||||
//
 | 
			
		||||
// CacheableFile _$CacheableFileFromJson(Map<String, dynamic> 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<String, dynamic> _$CacheableFileToJson(CacheableFile instance) =>
 | 
			
		||||
//     <String, dynamic>{
 | 
			
		||||
//       '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(),
 | 
			
		||||
//     };
 | 
			
		||||
@@ -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> {
 | 
			
		||||
//   ListFilesParams params;
 | 
			
		||||
//
 | 
			
		||||
//   ListFiles(this.params) : super(params);
 | 
			
		||||
//
 | 
			
		||||
//   @override
 | 
			
		||||
//   Future<ListFilesResponse> run() async {
 | 
			
		||||
//     Set<CacheableFile> files = (await (await WebdavApi.webdav).readDir(params.path)).map((e) => CacheableFile.fromDavFile(e)).toSet();
 | 
			
		||||
//
 | 
			
		||||
//     return ListFilesResponse(files);
 | 
			
		||||
//   }
 | 
			
		||||
// }
 | 
			
		||||
@@ -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<ListFilesResponse> {
 | 
			
		||||
//   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<ListFilesResponse> 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));
 | 
			
		||||
//   }
 | 
			
		||||
//
 | 
			
		||||
// }
 | 
			
		||||
@@ -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<String, dynamic> json) => _$ListFilesParamsFromJson(json);
 | 
			
		||||
  Map<String, dynamic> toJson() => _$ListFilesParamsToJson(this);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,17 @@
 | 
			
		||||
// GENERATED CODE - DO NOT MODIFY BY HAND
 | 
			
		||||
 | 
			
		||||
part of 'listFilesParams.dart';
 | 
			
		||||
 | 
			
		||||
// **************************************************************************
 | 
			
		||||
// JsonSerializableGenerator
 | 
			
		||||
// **************************************************************************
 | 
			
		||||
 | 
			
		||||
ListFilesParams _$ListFilesParamsFromJson(Map<String, dynamic> json) =>
 | 
			
		||||
    ListFilesParams(
 | 
			
		||||
      json['path'] as String,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
Map<String, dynamic> _$ListFilesParamsToJson(ListFilesParams instance) =>
 | 
			
		||||
    <String, dynamic>{
 | 
			
		||||
      'path': instance.path,
 | 
			
		||||
    };
 | 
			
		||||
@@ -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<CacheableFile> files;
 | 
			
		||||
//
 | 
			
		||||
//     ListFilesResponse(this.files);
 | 
			
		||||
//
 | 
			
		||||
//     factory ListFilesResponse.fromJson(Map<String, dynamic> json) => _$ListFilesResponseFromJson(json);
 | 
			
		||||
//     Map<String, dynamic> toJson() => _$ListFilesResponseToJson(this);
 | 
			
		||||
// }
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
// // GENERATED CODE - DO NOT MODIFY BY HAND
 | 
			
		||||
//
 | 
			
		||||
// part of 'listFilesResponse.dart';
 | 
			
		||||
//
 | 
			
		||||
// // **************************************************************************
 | 
			
		||||
// // JsonSerializableGenerator
 | 
			
		||||
// // **************************************************************************
 | 
			
		||||
//
 | 
			
		||||
// ListFilesResponse _$ListFilesResponseFromJson(Map<String, dynamic> json) =>
 | 
			
		||||
//     ListFilesResponse(
 | 
			
		||||
//       (json['files'] as List<dynamic>)
 | 
			
		||||
//           .map((e) => CacheableFile.fromJson(e as Map<String, dynamic>))
 | 
			
		||||
//           .toSet(),
 | 
			
		||||
//     );
 | 
			
		||||
//
 | 
			
		||||
// Map<String, dynamic> _$ListFilesResponseToJson(ListFilesResponse instance) =>
 | 
			
		||||
//     <String, dynamic>{
 | 
			
		||||
//       'files': instance.files.map((e) => e.toJson()).toList(),
 | 
			
		||||
//     };
 | 
			
		||||
							
								
								
									
										31
									
								
								lib/data/files/filesProps.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								lib/data/files/filesProps.dart
									
									
									
									
									
										Normal file
									
								
							@@ -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<ApiResponse?> properties() {
 | 
			
		||||
//     return [_listFilesResponse];
 | 
			
		||||
//   }
 | 
			
		||||
//
 | 
			
		||||
//   @override
 | 
			
		||||
//   void run() {
 | 
			
		||||
//     log("Query Cache");
 | 
			
		||||
//     ListFilesCache(
 | 
			
		||||
//       path: "/",
 | 
			
		||||
//       onUpdate: (ListFilesResponse data) => {
 | 
			
		||||
//         log("Got cache response"),
 | 
			
		||||
//         _listFilesResponse = data,
 | 
			
		||||
//         notifyListeners(),
 | 
			
		||||
//       }
 | 
			
		||||
//     );
 | 
			
		||||
//   }
 | 
			
		||||
//
 | 
			
		||||
// }
 | 
			
		||||
@@ -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<void> main() async {
 | 
			
		||||
          ChangeNotifierProvider(create: (context) => TimetableProps()),
 | 
			
		||||
          ChangeNotifierProvider(create: (context) => ChatListProps()),
 | 
			
		||||
          ChangeNotifierProvider(create: (context) => ChatProps()),
 | 
			
		||||
          //ChangeNotifierProvider(create: (context) => FilesProps()),
 | 
			
		||||
        ],
 | 
			
		||||
        child: const Main(),
 | 
			
		||||
      )
 | 
			
		||||
 
 | 
			
		||||
@@ -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<Files> {
 | 
			
		||||
  // List<String> path = List<String>.empty(growable: true);
 | 
			
		||||
  // List<File> files = List<File>.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<FileListPacket>(context, listen: false).invoke();
 | 
			
		||||
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
 | 
			
		||||
      //Provider.of<FilesProps>(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<Widget> items = List<Widget>.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<FileListPacket>(
 | 
			
		||||
      builder: (context, data, child) {
 | 
			
		||||
        List<ListTile> entries = List<ListTile>.empty(growable: true);
 | 
			
		||||
    // Future<List<FileInfo>> 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<FileListPacket>(context, listen: false).invoke(
 | 
			
		||||
                    data: {
 | 
			
		||||
                      "path": element.path
 | 
			
		||||
                    },
 | 
			
		||||
                    indicateLoading: true,
 | 
			
		||||
                );
 | 
			
		||||
              } else {
 | 
			
		||||
                // TODO: Open an File
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            
 | 
			
		||||
            onLongPress: () {
 | 
			
		||||
              showModalBottomSheet<void>(
 | 
			
		||||
                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<FileListPacket>(context, listen: false).invoke(
 | 
			
		||||
                  data: {
 | 
			
		||||
                    "path": data.lastPath
 | 
			
		||||
                  },
 | 
			
		||||
                  indicateLoading: true,
 | 
			
		||||
                );
 | 
			
		||||
              }
 | 
			
		||||
            ),
 | 
			
		||||
 | 
			
		||||
            title: Text(data.lastPath),
 | 
			
		||||
            actions: [
 | 
			
		||||
              IconButton(
 | 
			
		||||
                onPressed: () {
 | 
			
		||||
                  Provider.of<FileListPacket>(context, listen: false).invoke(indicateLoading: true);
 | 
			
		||||
                },
 | 
			
		||||
                icon: const Icon(Icons.home)
 | 
			
		||||
              ),
 | 
			
		||||
              PopupMenuButton(
 | 
			
		||||
                icon: Icon(Icons.add),
 | 
			
		||||
                itemBuilder: (context) {
 | 
			
		||||
                  return [
 | 
			
		||||
                    const PopupMenuItem<int>(
 | 
			
		||||
                      value: 0,
 | 
			
		||||
                      child: ListTile(
 | 
			
		||||
                        leading: Icon(Icons.folder),
 | 
			
		||||
                        title: Text("Ordner erstellen"),
 | 
			
		||||
                      ),
 | 
			
		||||
                    ),
 | 
			
		||||
                    const PopupMenuItem<int>(
 | 
			
		||||
                      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<FilesProps>(
 | 
			
		||||
  //     builder: (context, data, child) {
 | 
			
		||||
  //
 | 
			
		||||
  //       if(data.primaryLoading()) {
 | 
			
		||||
  //         return const Center(child: CircularProgressIndicator());
 | 
			
		||||
  //       }
 | 
			
		||||
  //
 | 
			
		||||
  //       List<ListTile> entries = List<ListTile>.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<void>(
 | 
			
		||||
  //               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);
 | 
			
		||||
  //     },
 | 
			
		||||
  //   );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user