4 Commits

Author SHA1 Message Date
f40a9ad09b Updated schema
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m5s
2025-11-19 21:42:07 +01:00
822bc03c83 Added dialog 2025-11-19 21:41:30 +01:00
a8d4e640cf Tabs update themselves after settings view 2025-11-19 21:39:01 +01:00
cf71b40718 changed export file name 2025-11-19 21:19:54 +01:00
3 changed files with 53 additions and 19 deletions

View File

@@ -20,10 +20,10 @@
"type": "string"
},
"players": {
"type": "null"
"type": "object"
},
"group": {
"type": "null"
"type": "object"
},
"winner": {
"type": "string"
@@ -33,8 +33,6 @@
"id",
"createdAt",
"name",
"players",
"group",
"winner"
]
}

View File

@@ -17,12 +17,7 @@ class CustomNavigationBar extends StatefulWidget {
class _CustomNavigationBarState extends State<CustomNavigationBar>
with SingleTickerProviderStateMixin {
int currentIndex = 0;
final List<Widget> tabs = [
const HomeView(),
const GameHistoryView(),
const GroupsView(),
const StatisticsView(),
];
int tabKeyCount = 0;
@override
void initState() {
@@ -31,6 +26,22 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
@override
Widget build(BuildContext context) {
// Pretty ugly but works
final List<Widget> tabs = [
KeyedSubtree(key: ValueKey('home_$tabKeyCount'), child: const HomeView()),
KeyedSubtree(
key: ValueKey('games_$tabKeyCount'),
child: const GameHistoryView(),
),
KeyedSubtree(
key: ValueKey('groups_$tabKeyCount'),
child: const GroupsView(),
),
KeyedSubtree(
key: ValueKey('stats_$tabKeyCount'),
child: const StatisticsView(),
),
];
return Scaffold(
appBar: AppBar(
centerTitle: true,
@@ -42,10 +53,15 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
scrolledUnderElevation: 0,
actions: [
IconButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const SettingsView()),
),
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute(builder: (_) => const SettingsView()),
);
setState(() {
tabKeyCount++;
});
},
icon: const Icon(Icons.settings),
),
],

View File

@@ -80,7 +80,7 @@ class _SettingsViewState extends State<SettingsView> {
await DataTransferService.getAppDataAsJson(context);
final result = await DataTransferService.exportData(
json,
'exported_data',
'game_tracker-data',
);
if (!context.mounted) return;
showExportSnackBar(context: context, result: result);
@@ -103,11 +103,31 @@ class _SettingsViewState extends State<SettingsView> {
icon: Icons.download_outlined,
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
onPressed: () {
DataTransferService.deleteAllData(context);
showSnackbar(
showDialog<bool>(
context: context,
message: 'Data successfully deleted',
);
builder: (context) => AlertDialog(
title: const Text('Delete all data?'),
content: const Text('This can\'t be undone'),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Abbrechen'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Löschen'),
),
],
),
).then((confirmed) {
if (confirmed == true && context.mounted) {
DataTransferService.deleteAllData(context);
showSnackbar(
context: context,
message: 'Daten erfolgreich gelöscht',
);
}
});
},
),
],