Made cache deletable with better dev-view
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -8,7 +9,7 @@ import '../../model/accountModel.dart';
|
||||
import '../../storage/base/settingsProvider.dart';
|
||||
import '../../theming/appTheme.dart';
|
||||
import '../../widget/confirmDialog.dart';
|
||||
import 'debug/debugOverview.dart';
|
||||
import 'debug/cacheView.dart';
|
||||
import 'debug/jsonViewer.dart';
|
||||
|
||||
class Settings extends StatefulWidget {
|
||||
@ -178,20 +179,59 @@ class _SettingsState extends State<Settings> {
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.data_object),
|
||||
title: const Text("Cache JSON dump"),
|
||||
title: FutureBuilder(
|
||||
future: const CacheView().totalSize(),
|
||||
builder: (context, snapshot) {
|
||||
return Text("Cache JSON dump (${snapshot.hasError ? "?" : snapshot.hasData ? "est. ${filesize(snapshot.data)}" : "Berechnen..."})");
|
||||
},
|
||||
),
|
||||
subtitle: const Text("Tippen und halten um zu löschen"),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return const DebugOverview();
|
||||
return const CacheView();
|
||||
}));
|
||||
},
|
||||
onLongPress: () {
|
||||
ConfirmDialog(
|
||||
title: "Cache löschen",
|
||||
content: "Alle cache Einträge werden gelöscht. Der cache wird bei benutzung der App erneut aufgebaut",
|
||||
confirmButton: "Unwiederruflich löschen",
|
||||
onConfirm: () => const CacheView().clear(),
|
||||
).asDialog(context);
|
||||
},
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.broken_image),
|
||||
title: const Text("Cached Thumbnails löschen"),
|
||||
onTap: () {
|
||||
ConfirmDialog(
|
||||
title: "Thumbs cache löschen",
|
||||
content: "Alle zwischengespeicherten Bilder werden gelöscht.",
|
||||
confirmButton: "Unwiederruflich löschen",
|
||||
onConfirm: () => PaintingBinding.instance.imageCache.clear(),
|
||||
).asDialog(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings_applications_outlined),
|
||||
title: const Text("Storage JSON dump"),
|
||||
subtitle: const Text("Tippen und halten um zu löschen"),
|
||||
onTap: () {
|
||||
JsonViewer.asDialog(context, settings.val().toJson());
|
||||
},
|
||||
onLongPress: () {
|
||||
ConfirmDialog(
|
||||
title: "App-Speicher löschen",
|
||||
content: "Alle Einstellungen und gespeicherten Inhalte gehen verloren! Accountdaten sind nicht betroffen.",
|
||||
confirmButton: "Unwiederruflich Löschen",
|
||||
onConfirm: () {
|
||||
setState(() {
|
||||
Provider.of<SettingsProvider>(context, listen: false).init(resetConfig: true);
|
||||
});
|
||||
},
|
||||
).asDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user