Compare commits
12 Commits
45a419cae7
...
feature/12
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ebcfc9e57 | |||
| 22ce742d43 | |||
| 3ceae8341b | |||
| 76ce3af643 | |||
| 906c8d8450 | |||
| 000bdc8cbc | |||
| 497f30421d | |||
| adedb85eb2 | |||
| 2a72332bcd | |||
| 7aa41abe61 | |||
| e1263d51ad | |||
| 6f0e5ba5c2 |
@@ -17,7 +17,7 @@
|
||||
"data_successfully_imported": "Daten erfolgreich importiert",
|
||||
"days_ago": "vor {count} Tagen",
|
||||
"delete": "Löschen",
|
||||
"delete_all_data": "Alle Daten löschen?",
|
||||
"delete_all_data": "Alle Daten löschen",
|
||||
"error_creating_group": "Fehler beim Erstellen der Gruppe, bitte erneut versuchen",
|
||||
"error_reading_file": "Fehler beim Lesen der Datei",
|
||||
"export_canceled": "Export abgebrochen",
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
"data_successfully_imported": "Data successfully imported",
|
||||
"days_ago": "{count} days ago",
|
||||
"delete": "Delete",
|
||||
"delete_all_data": "Delete all data?",
|
||||
"delete_all_data": "Delete all data",
|
||||
"error_creating_group": "Error while creating group, please try again",
|
||||
"error_reading_file": "Error reading file",
|
||||
"export_canceled": "Export canceled",
|
||||
|
||||
@@ -209,7 +209,7 @@ abstract class AppLocalizations {
|
||||
/// Confirmation dialog for deleting all data
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Delete all data?'**
|
||||
/// **'Delete all data'**
|
||||
String get delete_all_data;
|
||||
|
||||
/// Error message when group creation fails
|
||||
|
||||
@@ -67,7 +67,7 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
String get delete => 'Löschen';
|
||||
|
||||
@override
|
||||
String get delete_all_data => 'Alle Daten löschen?';
|
||||
String get delete_all_data => 'Alle Daten löschen';
|
||||
|
||||
@override
|
||||
String get error_creating_group =>
|
||||
|
||||
@@ -67,7 +67,7 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
String get delete => 'Delete';
|
||||
|
||||
@override
|
||||
String get delete_all_data => 'Delete all data?';
|
||||
String get delete_all_data => 'Delete all data';
|
||||
|
||||
@override
|
||||
String get error_creating_group =>
|
||||
|
||||
@@ -140,7 +140,11 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
|
||||
filteredGroups.clear();
|
||||
filteredGroups.addAll(
|
||||
widget.groups.where(
|
||||
(group) => group.name.toLowerCase().contains(query.toLowerCase()),
|
||||
(group) =>
|
||||
group.name.toLowerCase().contains(query.toLowerCase()) ||
|
||||
group.members.any(
|
||||
(player) => player.name.toLowerCase().contains(query.toLowerCase()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
||||
import 'package:game_tracker/services/data_transfer_service.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:game_tracker/presentation/widgets/custom_alert_dialog.dart';
|
||||
|
||||
class SettingsView extends StatefulWidget {
|
||||
const SettingsView({super.key});
|
||||
@@ -13,9 +15,16 @@ class SettingsView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SettingsViewState extends State<SettingsView> {
|
||||
PackageInfo _packageInfo = PackageInfo(
|
||||
appName: 'n.A.',
|
||||
packageName: 'n.A.',
|
||||
version: 'n.A.',
|
||||
buildNumber: 'n.A.',
|
||||
);
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initPackageInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -25,102 +34,107 @@ class _SettingsViewState extends State<SettingsView> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
||||
backgroundColor: CustomTheme.backgroundColor,
|
||||
body: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) =>
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.menu,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.settings,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.export_data,
|
||||
icon: Icons.upload_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final String json =
|
||||
await DataTransferService.getAppDataAsJson(context);
|
||||
final result = await DataTransferService.exportData(
|
||||
json,
|
||||
'game_tracker-data',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showExportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.import_data,
|
||||
icon: Icons.download_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final result = await DataTransferService.importData(
|
||||
context,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showImportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.delete_all_data,
|
||||
icon: Icons.delete_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () {
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(loc.delete_all_data),
|
||||
content: Text(loc.this_cannot_be_undone),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((confirmed) {
|
||||
if (confirmed == true && context.mounted) {
|
||||
DataTransferService.deleteAllData(context);
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
).data_successfully_deleted,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.menu,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.start,
|
||||
loc.settings,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.export_data,
|
||||
icon: Icons.upload_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final String json = await DataTransferService.getAppDataAsJson(
|
||||
context,
|
||||
);
|
||||
final result = await DataTransferService.exportData(
|
||||
json,
|
||||
'game_tracker-data',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showExportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.import_data,
|
||||
icon: Icons.download_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () async {
|
||||
final result = await DataTransferService.importData(context);
|
||||
if (!context.mounted) return;
|
||||
showImportSnackBar(context: context, result: result);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
title: loc.delete_all_data,
|
||||
icon: Icons.delete_rounded,
|
||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
onPressed: () {
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CustomAlertDialog(
|
||||
title: '${loc.delete_all_data}?',
|
||||
content: loc.this_cannot_be_undone,
|
||||
actions: [
|
||||
_PressableButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor)),
|
||||
),
|
||||
_PressableButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor)),
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((confirmed) {
|
||||
if (confirmed == true && context.mounted) {
|
||||
DataTransferService.deleteAllData(context);
|
||||
showSnackbar(
|
||||
context: context,
|
||||
message: AppLocalizations.of(
|
||||
context,
|
||||
).data_successfully_deleted,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Version ${_packageInfo.version} (${_packageInfo.buildNumber})',
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -196,4 +210,67 @@ class _SettingsViewState extends State<SettingsView> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _initPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
setState(() {
|
||||
_packageInfo = info;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _PressableButton extends StatefulWidget {
|
||||
final VoidCallback onPressed;
|
||||
final Widget child;
|
||||
|
||||
const _PressableButton({required this.onPressed, required this.child});
|
||||
|
||||
@override
|
||||
State<_PressableButton> createState() => _PressableButtonState();
|
||||
}
|
||||
|
||||
class _PressableButtonState extends State<_PressableButton> {
|
||||
bool _isPressed = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTapDown: (_) => setState(() => _isPressed = true),
|
||||
onTapUp: (_) => setState(() => _isPressed = false),
|
||||
onTapCancel: () => setState(() => _isPressed = false),
|
||||
onTap: widget.onPressed,
|
||||
child: AnimatedScale(
|
||||
scale: _isPressed ? 0.95 : 1.0,
|
||||
duration: const Duration(milliseconds: 100),
|
||||
child: AnimatedOpacity(
|
||||
opacity: _isPressed ? 0.6 : 1.0,
|
||||
duration: const Duration(milliseconds: 100),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
overlayColor: Colors.transparent,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor),),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
overlayColor: Colors.transparent,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),),
|
||||
),
|
||||
*/
|
||||
|
||||
30
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
30
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
|
||||
class CustomAlertDialog extends StatelessWidget {
|
||||
final String title;
|
||||
final String content;
|
||||
final List<Widget> actions;
|
||||
|
||||
const CustomAlertDialog({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.actions,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(title, style: const TextStyle(color: CustomTheme.textColor,),),
|
||||
content: Text(content, style: const TextStyle(color: CustomTheme.textColor),),
|
||||
actions: actions,
|
||||
backgroundColor: CustomTheme.boxColor,
|
||||
actionsAlignment: MainAxisAlignment.spaceAround,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||
side: BorderSide(color: CustomTheme.boxBorder),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
name: game_tracker
|
||||
description: "Game Tracking App for Card Games"
|
||||
publish_to: 'none'
|
||||
version: 0.0.3+93
|
||||
version: 0.0.4+101
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@@ -22,6 +22,7 @@ dependencies:
|
||||
intl: any
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
package_info_plus: ^9.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user