Merge pull request #97 from flixcoo/feature/95-delete-all-games-button

Added Delete all games button to Settings
This commit is contained in:
2025-07-11 11:19:21 +02:00
committed by GitHub
7 changed files with 221 additions and 146 deletions

View File

@@ -96,6 +96,9 @@
"game_data": "Spieldaten",
"import_data": "Spieldaten importieren",
"export_data": "Spieldaten exportieren",
"delete_data": "Alle Spieldaten löschen",
"delete_data_title": "Spieldaten löschen?",
"delete_data_message": "Bist du sicher, dass du alle Spieldaten löschen möchtest? Diese Aktion kann nicht rückgängig gemacht werden.",
"app": "App",
"import_success_title": "Import erfolgreich",

View File

@@ -97,6 +97,9 @@
"game_data": "Game Data",
"import_data": "Import Data",
"export_data": "Export Data",
"delete_data": "Delete all Game Data",
"delete_data_title": "Delete game data?",
"delete_data_message": "Are you sure you want to delete all game data? This action cannot be undone.",
"app": "App",
"import_success_title": "Import successful",

View File

@@ -536,6 +536,24 @@ abstract class AppLocalizations {
/// **'Spieldaten exportieren'**
String get export_data;
/// No description provided for @delete_data.
///
/// In de, this message translates to:
/// **'Alle Spieldaten löschen'**
String get delete_data;
/// No description provided for @delete_data_title.
///
/// In de, this message translates to:
/// **'Spieldaten löschen?'**
String get delete_data_title;
/// No description provided for @delete_data_message.
///
/// In de, this message translates to:
/// **'Bist du sicher, dass du alle Spieldaten löschen möchtest? Diese Aktion kann nicht rückgängig gemacht werden.'**
String get delete_data_message;
/// No description provided for @app.
///
/// In de, this message translates to:

View File

@@ -241,6 +241,16 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get export_data => 'Spieldaten exportieren';
@override
String get delete_data => 'Alle Spieldaten löschen';
@override
String get delete_data_title => 'Spieldaten löschen?';
@override
String get delete_data_message =>
'Bist du sicher, dass du alle Spieldaten löschen möchtest? Diese Aktion kann nicht rückgängig gemacht werden.';
@override
String get app => 'App';

View File

@@ -238,6 +238,16 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get export_data => 'Export Data';
@override
String get delete_data => 'Delete all Game Data';
@override
String get delete_data_title => 'Delete game data?';
@override
String get delete_data_message =>
'Are you sure you want to delete all game data? This action cannot be undone.';
@override
String get app => 'App';

View File

@@ -32,9 +32,8 @@ class _SettingsViewState extends State<SettingsView> {
middle: Text(AppLocalizations.of(context).settings),
),
child: SafeArea(
child: Stack(
children: [
Column(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -52,7 +51,7 @@ class _SettingsViewState extends State<SettingsView> {
margin: EdgeInsets.zero,
children: [
CustomFormRow(
prefixText: 'Cabo-Strafe',
prefixText: AppLocalizations.of(context).cabo_penalty,
prefixIcon: CupertinoIcons.bolt_fill,
suffixWidget: CustomStepper(
key: _stepperKey1,
@@ -69,7 +68,7 @@ class _SettingsViewState extends State<SettingsView> {
),
),
CustomFormRow(
prefixText: 'Punkte-Limit',
prefixText: AppLocalizations.of(context).point_limit,
prefixIcon: FontAwesomeIcons.bullseye,
suffixWidget: CustomStepper(
key: _stepperKey2,
@@ -127,6 +126,11 @@ class _SettingsViewState extends State<SettingsView> {
onPressed: () => LocalStorageService.exportGameData(),
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow(
prefixText: AppLocalizations.of(context).delete_data,
prefixIcon: CupertinoIcons.trash,
onPressed: () => _deleteAllGames(),
),
])),
Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
@@ -149,23 +153,21 @@ class _SettingsViewState extends State<SettingsView> {
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow(
prefixText:
AppLocalizations.of(context).privacy_policy,
prefixText: AppLocalizations.of(context).privacy_policy,
prefixIcon: CupertinoIcons.doc_append,
onPressed: () => launchUrl(
Uri.parse(Constants.PRIVACY_POLICY_LINK)),
onPressed: () =>
launchUrl(Uri.parse(Constants.PRIVACY_POLICY_LINK)),
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow(
prefixText: AppLocalizations.of(context).error_found,
prefixIcon: FontAwesomeIcons.github,
onPressed: () => launchUrl(
Uri.parse(Constants.GITHUB_ISSUES_LINK)),
onPressed: () =>
launchUrl(Uri.parse(Constants.GITHUB_ISSUES_LINK)),
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow(
prefixText:
AppLocalizations.of(context).app_version,
prefixText: AppLocalizations.of(context).app_version,
prefixIcon: CupertinoIcons.tag,
onPressed: null,
suffixWidget: Text(VersionService.getVersion(),
@@ -181,13 +183,42 @@ class _SettingsViewState extends State<SettingsView> {
color: CustomTheme.primaryColor,
))),
])),
const SizedBox(height: 50)
],
),
],
)),
);
}
/// Shows a dialog to confirm the deletion of all game data.
/// When confirmed, it deletes all game data from local storage.
void _deleteAllGames() {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: Text(AppLocalizations.of(context).delete_data_title),
content: Text(AppLocalizations.of(context).delete_data_message),
actions: [
CupertinoDialogAction(
child: Text(AppLocalizations.of(context).cancel),
onPressed: () => Navigator.pop(context),
),
CupertinoDialogAction(
isDestructiveAction: true,
isDefaultAction: true,
child: Text(AppLocalizations.of(context).delete),
onPressed: () {
LocalStorageService.deleteAllGames();
Navigator.pop(context);
},
),
],
);
},
);
}
void showFeedbackDialog(ImportStatus status) {
if (status == ImportStatus.canceled) return;
final (title, message) = _getDialogContent(status);

View File

@@ -2,7 +2,7 @@ name: cabo_counter
description: "Mobile app for the card game Cabo"
publish_to: 'none'
version: 0.4.1+470
version: 0.4.2+473
environment:
sdk: ^3.5.4