193 lines
6.4 KiB
Dart
193 lines
6.4 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 '../../data/appTheme.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_outlined),
|
|
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(),
|
|
|
|
Consumer<AppTheme>(
|
|
builder: (context, value, child) {
|
|
return ListTile(
|
|
leading: const Icon(Icons.dark_mode_outlined),
|
|
title: const Text("Farbgebung"),
|
|
trailing: DropdownButton<ThemeMode>(
|
|
value: value.getMode,
|
|
icon: const Icon(Icons.arrow_drop_down),
|
|
items: ThemeMode.values.map((e) => DropdownMenuItem<ThemeMode>(
|
|
value: e,
|
|
enabled: e != value.getMode,
|
|
child: Row(
|
|
children: [
|
|
Icon(AppTheme.getDisplayOptions(e).icon),
|
|
const SizedBox(width: 10),
|
|
Text(AppTheme.getDisplayOptions(e).displayName),
|
|
],
|
|
),
|
|
)).toList(),
|
|
onChanged: (e) {
|
|
Provider.of<AppTheme>(context, listen: false).setTheme(e ?? ThemeMode.system);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.live_help_outlined),
|
|
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.policy_outlined),
|
|
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.badge_outlined),
|
|
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_outlined),
|
|
title: const Text("Entwicklermodus"),
|
|
trailing: Checkbox(
|
|
visualDensity: const VisualDensity(horizontal: VisualDensity.minimumDensity),
|
|
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) {
|
|
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|