Compare commits
4 Commits
f7c1d6e975
...
f40a9ad09b
| Author | SHA1 | Date | |
|---|---|---|---|
| f40a9ad09b | |||
| 822bc03c83 | |||
| a8d4e640cf | |||
| cf71b40718 |
@@ -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"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
onPressed: () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsView()),
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
tabKeyCount++;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.settings),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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: () {
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
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: 'Data successfully deleted',
|
||||
message: 'Daten erfolgreich gelöscht',
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user