162 lines
5.1 KiB
Dart
162 lines
5.1 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:package_info/package_info.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../../data/accountModel.dart';
|
|
import 'debug/debugOverview.dart';
|
|
|
|
class Settings extends StatefulWidget {
|
|
const Settings({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<Settings> createState() => _SettingsState();
|
|
}
|
|
|
|
class _SettingsState extends State<Settings> {
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
bool developerMode = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("Einstellungen"),
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.logout),
|
|
title: const Text("Konto abmelden"),
|
|
onTap: () {
|
|
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);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.info),
|
|
title: const Text("Informationen und Lizenzen"),
|
|
onTap: () async {
|
|
final appInfo = await PackageInfo.fromPlatform();
|
|
|
|
if(!context.mounted) return;
|
|
showAboutDialog(
|
|
context: context,
|
|
applicationIcon: const Icon(Icons.apps),
|
|
applicationName: "MarianumMobile",
|
|
applicationVersion: "${appInfo.appName}\n\nPackage: ${appInfo.packageName}\n\nVersion: ${appInfo.version}\nBuild: ${appInfo.buildNumber}",
|
|
applicationLegalese: "Dies ist ein Inoffizieller Nextcloud & Webuntis Client und wird nicht vom Marianum selbst betrieben.\n"
|
|
"Keinerlei Gewähr für Vollständigkeit, Richtigkeit und Aktualität!\n\n"
|
|
"Development build\n"
|
|
"Marianum Fulda 2023 Elias Müller",
|
|
);
|
|
},
|
|
trailing: const Icon(Icons.arrow_right),
|
|
),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.privacy_tip),
|
|
title: const Text("Datenschutz"),
|
|
onTap: () {
|
|
launchUrl(Uri.parse("https://mhsl.eu/datenschutz.html"));
|
|
},
|
|
trailing: const Icon(Icons.open_in_new),
|
|
),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.person_pin_rounded),
|
|
title: const Text("Impressum"),
|
|
onTap: () {
|
|
launchUrl(Uri.parse("https://mhsl.eu/id.html"));
|
|
},
|
|
trailing: const Icon(Icons.open_in_new),
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.developer_mode),
|
|
title: const Text("Entwicklermodus"),
|
|
trailing: Checkbox(
|
|
value: developerMode,
|
|
onChanged: (state) {
|
|
setState(() {
|
|
developerMode = !developerMode;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
|
|
Visibility(
|
|
visible: developerMode,
|
|
child: ListTile(
|
|
leading: const Icon(Icons.data_object),
|
|
title: const Text("Storage view"),
|
|
onTap: () {
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
|
return const DebugOverview();
|
|
}));
|
|
},
|
|
trailing: const Icon(Icons.arrow_right),
|
|
),
|
|
),
|
|
|
|
Visibility(
|
|
visible: developerMode && false, // TODO Implement verbose logging
|
|
child: ListTile(
|
|
leading: const Icon(Icons.logo_dev),
|
|
title: const Text("Logging verbosity"),
|
|
trailing: DropdownButton<String>(
|
|
value: "1",
|
|
items: ["1", "2", "3"].map((e) => DropdownMenuItem<String>(value: e, child: Text(e))).toList(),
|
|
onChanged: (e) {
|
|
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|