Added Nextcloud base
This commit is contained in:
90
lib/screen/settings/debug/debugOverview.dart
Normal file
90
lib/screen/settings/debug/debugOverview.dart
Normal file
@ -0,0 +1,90 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:localstore/localstore.dart';
|
||||
import 'package:marianum_mobile/screen/settings/debug/jsonViewer.dart';
|
||||
|
||||
class DebugOverview extends StatefulWidget {
|
||||
const DebugOverview({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DebugOverview> createState() => _DebugOverviewState();
|
||||
}
|
||||
|
||||
class _DebugOverviewState extends State<DebugOverview> {
|
||||
|
||||
final Localstore storage = Localstore.instance;
|
||||
Future<Map<String, dynamic>?> files = Localstore.instance.collection("MarianumMobile").get();
|
||||
dynamic data;
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Lokaler cache"),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete_forever),
|
||||
title: const Text("Cache löschen"),
|
||||
onTap: () {
|
||||
storage.collection("MarianumMobile").delete().then((value) => {
|
||||
Navigator.pop(context)
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
FutureBuilder(
|
||||
future: files,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.hasData) {
|
||||
List<String> files = snapshot.data?.keys.map((e) => e.toString()).toList() ?? List<String>.empty();
|
||||
|
||||
Map<String, dynamic> getValue(int index) {
|
||||
return snapshot.data?[files[index]];
|
||||
}
|
||||
|
||||
return Expanded(
|
||||
flex: 5,
|
||||
child: ListView.builder(
|
||||
itemCount: files.length,
|
||||
itemBuilder: (context, index) {
|
||||
String filename = files[index].split("/").last;
|
||||
//String data = getValue(index).toString().replaceAll("{", "{\n ").replaceAll("[", "[\n ").replaceAll(",", ",\n ");
|
||||
String data = getValue(index).toString();
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.text_snippet_outlined),
|
||||
title: Text("(${data.length} z) [$filename] ${Jiffy.unixFromMillisecondsSinceEpoch(getValue(index)['lastupdate']).fromNow()}"),
|
||||
textColor: Colors.black,
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return JsonViewer(title: filename, data: data);
|
||||
},));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return snapshot.data == null ? const Text("No data") : const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
21
lib/screen/settings/debug/jsonViewer.dart
Normal file
21
lib/screen/settings/debug/jsonViewer.dart
Normal file
@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class JsonViewer extends StatelessWidget {
|
||||
String title;
|
||||
String data;
|
||||
|
||||
JsonViewer({Key? key, required this.title, required this.data}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Text(data.replaceAllMapped(RegExp(r'[{,}]'), (match) => "${match.group(0)}\n ")),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user