Implemented basic Fileviewing
This commit is contained in:
@ -1,5 +1,16 @@
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jiffy/jiffy.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:provider/provider.dart';
|
||||
|
||||
import '../../../api/marianumcloud/webdav/queries/listFiles/listFiles.dart';
|
||||
import '../../../api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
|
||||
import '../../../data/files/filesProps.dart';
|
||||
|
||||
class Files extends StatefulWidget {
|
||||
const Files({Key? key}) : super(key: key);
|
||||
@ -13,7 +24,7 @@ class _FilesState extends State<Files> {
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
//Provider.of<FilesProps>(context, listen: false).run();
|
||||
Provider.of<FilesProps>(context, listen: false).run();
|
||||
});
|
||||
|
||||
super.initState();
|
||||
@ -22,50 +33,31 @@ class _FilesState extends State<Files> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Future<ListFilesResponse> files = ListFiles(ListFilesParams("/")).run();
|
||||
files.then((value) => log(value.toJson().toString()));
|
||||
|
||||
// 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<FilesProps>(
|
||||
builder: (context, value, child) {
|
||||
if(value.primaryLoading()) return const Center(child: CircularProgressIndicator());
|
||||
|
||||
// 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);
|
||||
// }),
|
||||
// });
|
||||
|
||||
// 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 const Center(
|
||||
child: Text("Currently not implemented!"),
|
||||
return ListView.builder(
|
||||
itemCount: value.listFilesResponse.files.length,
|
||||
itemBuilder: (context, index) {
|
||||
CacheableFile file = value.listFilesResponse.files.skip(index).first;
|
||||
return ListTile(
|
||||
leading: Icon(file.isDirectory ? Icons.folder : Icons.file_open_outlined),
|
||||
title: Text(file.name),
|
||||
subtitle: file.isDirectory ? Text("geändert ${Jiffy(file.modifiedAt).fromNow()}") : Text("${filesize(file.size)}, ${Jiffy(file.modifiedAt).fromNow()}}"),
|
||||
trailing: Icon(file.isDirectory ? Icons.arrow_right : Icons.open_in_new),
|
||||
onTap: () {
|
||||
if(file.isDirectory) {
|
||||
Provider.of<FilesProps>(context, listen: false).setPath(file.path);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// return Consumer<FilesProps>(
|
||||
|
Reference in New Issue
Block a user