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" "type": "string"
}, },
"players": { "players": {
"type": "null" "type": "object"
}, },
"group": { "group": {
"type": "null" "type": "object"
}, },
"winner": { "winner": {
"type": "string" "type": "string"
@@ -33,8 +33,6 @@
"id", "id",
"createdAt", "createdAt",
"name", "name",
"players",
"group",
"winner" "winner"
] ]
} }

View File

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

View File

@@ -80,7 +80,7 @@ class _SettingsViewState extends State<SettingsView> {
await DataTransferService.getAppDataAsJson(context); await DataTransferService.getAppDataAsJson(context);
final result = await DataTransferService.exportData( final result = await DataTransferService.exportData(
json, json,
'exported_data', 'game_tracker-data',
); );
if (!context.mounted) return; if (!context.mounted) return;
showExportSnackBar(context: context, result: result); showExportSnackBar(context: context, result: result);
@@ -103,11 +103,31 @@ class _SettingsViewState extends State<SettingsView> {
icon: Icons.download_outlined, icon: Icons.download_outlined,
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16), suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
onPressed: () { onPressed: () {
DataTransferService.deleteAllData(context); showDialog<bool>(
showSnackbar(
context: context, 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',
);
}
});
}, },
), ),
], ],