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 ")),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../dataOld/accountModel.dart';
|
||||
import '../../dataOld/incommingPackets/serverInfoPacket.dart';
|
||||
import '../../widget/ListItem.dart';
|
||||
import 'debug/debugOverview.dart';
|
||||
|
||||
class Settings extends StatefulWidget {
|
||||
const Settings({Key? key}) : super(key: key);
|
||||
@ -19,7 +20,6 @@ class _SettingsState extends State<Settings> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Provider.of<ServerInfoPacket>(context, listen: false).invoke();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -31,56 +31,64 @@ class _SettingsState extends State<Settings> {
|
||||
body: ListView(
|
||||
children: [
|
||||
|
||||
const ListItemNavigator(icon: Icons.info, text: "Über diese App", target: AboutDialog(
|
||||
applicationIcon: Icon(Icons.send_time_extension_outlined),
|
||||
applicationLegalese: "Released under MIT-License",
|
||||
applicationName: "Marianum Fulda",
|
||||
applicationVersion: "ALPHA 0.1",
|
||||
)),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: const Text("Account abmelden"),
|
||||
title: const Text("Konto abmelden"),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (builder) => AlertDialog(
|
||||
title: const Text("Abmelden?"),
|
||||
content: const Text("Möchtest du dich wirklich abmelden?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Abmelden"),
|
||||
onPressed: () {
|
||||
SharedPreferences.getInstance().then((value) => {
|
||||
value.clear(),
|
||||
}).then((value) => {
|
||||
Provider.of<AccountModel>(context, listen: false).logout(),
|
||||
Navigator.popUntil(context, (route) => !Navigator.canPop(context)),
|
||||
});
|
||||
}
|
||||
),
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Abmelden?"),
|
||||
content: const Text("Möchtest du dich wirklich abmelden?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Abmelden"),
|
||||
onPressed: () {
|
||||
SharedPreferences.getInstance().then((value) => {
|
||||
value.clear(),
|
||||
}).then((value) => {
|
||||
Provider.of<AccountModel>(context, listen: false).logout(),
|
||||
Navigator.popUntil(context, (route) => !Navigator.canPop(context)),
|
||||
});
|
||||
}
|
||||
),
|
||||
|
||||
TextButton(
|
||||
child: const Text("Abbrechen"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
)));
|
||||
TextButton(
|
||||
child: const Text("Abbrechen"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Consumer<ServerInfoPacket>(
|
||||
builder: (context, serverInfo, child) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.home_work_outlined),
|
||||
title: Text("Server: ${serverInfo.serverName}"),
|
||||
subtitle: Text(
|
||||
"Betreiber: ${serverInfo.serverOwner}\n"
|
||||
"Serverversion: ${serverInfo.serverVersion}\n"
|
||||
"Rechtliche hinweise: ${serverInfo.legal}\n"
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info),
|
||||
title: const Text("Informationen und Lizenzen"),
|
||||
onTap: () {
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
applicationIcon: const Icon(Icons.send_time_extension_outlined),
|
||||
applicationName: "MarianumMobile",
|
||||
applicationVersion: "Development Build",
|
||||
applicationLegalese: "Marianum Fulda 2023 Elias Müller",
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.bug_report_outlined),
|
||||
title: const Text("Speicheransicht"),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return const DebugOverview();
|
||||
}));
|
||||
},
|
||||
)
|
||||
|
||||
],
|
||||
|
Reference in New Issue
Block a user