2022-08-28 20:51:12 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2022-08-29 15:16:51 +00:00
|
|
|
import '../DrawerPage.dart';
|
|
|
|
import '../api/token.dart';
|
2022-08-28 20:51:12 +00:00
|
|
|
import '../db/database.dart';
|
2022-08-29 15:16:51 +00:00
|
|
|
import '../login/logincontext.dart';
|
2022-08-28 20:51:12 +00:00
|
|
|
|
|
|
|
class SettingsScreen extends StatefulWidget {
|
|
|
|
const SettingsScreen({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
int dbsize = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2022-08-29 15:16:51 +00:00
|
|
|
Db().getDbSize().then((v) => setState(() {
|
|
|
|
dbsize = v;
|
|
|
|
}));
|
2022-08-28 20:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-29 15:16:51 +00:00
|
|
|
final loginCtx = LoginContext.of(context);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text("Temp"),
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () async {
|
|
|
|
await Db().clear();
|
|
|
|
Db().getDbSize().then((v) => setState(() {
|
|
|
|
dbsize = v;
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
child: const Text("Delete cache!")),
|
|
|
|
Text("db size: ${dbsize / 1024} kb"),
|
|
|
|
ElevatedButton(onPressed: () {
|
|
|
|
loginCtx.onLoggin(false);
|
|
|
|
Token.getInstance().setToken("", "");
|
|
|
|
Db().clear();
|
|
|
|
}, child: Text("Logout"))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
drawer: MyDrawer());
|
2022-08-28 20:51:12 +00:00
|
|
|
}
|
|
|
|
}
|