diff --git a/app/lib/common/utilities/hive_utils.dart b/app/lib/common/utilities/hive_utils.dart index 0d267db5..f3a5d810 100644 --- a/app/lib/common/utilities/hive_utils.dart +++ b/app/lib/common/utilities/hive_utils.dart @@ -22,14 +22,18 @@ Future> retrieveExistingOrGenerateKey() async { return base64Url.decode(key!); } -Future deleteAllAppData() async { - await _deleteCacheDir(); - await _deleteAppDir(); +Future unsetAllData() async { await UserData.erase(); await MetaData.erase(); await DrugsWithGuidelines.erase(); } +Future deleteAllAppData() async { + await unsetAllData(); + await _deleteCacheDir(); + await _deleteAppDir(); +} + // The folders themselves cannot be deleted on iOS, therefore delete all content // inside the folders void _deleteFolderContent(Directory directory) { diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index cb30ed56..6e49a76b 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -553,7 +553,11 @@ "@more_page_delete_data": {}, "more_page_delete_data_text": "Are you sure that you want to delete all app data? This also includes your genetic data and will reset the app.", "@more_page_delete_data_text": {}, - "more_page_delete_data_additional_text": "Your genetic data will be deleted and it might not be possible to import it again.", + "more_page_delete_data_additional_text": "Your genetic data will be deleted from your phone and it might not be possible to import it again.\n\nAfter deleting the data, you will be asked to close the app.", + "delete_data_restart_title": "All data deleted", + "@delete_data_restart_title": {}, + "delete_data_restart_text": "Please close the app now. To setup PharMe again, please restart the app.", + "@delete_data_restart_text": {}, "@more_page_delete_data_additional_text": {}, "more_page_delete_data_confirmation": "I understand the consequences and want to delete all app data", "@more_page_delete_data_confirmation": {}, diff --git a/app/lib/more/pages/more.dart b/app/lib/more/pages/more.dart index cd296ac1..84357bd3 100644 --- a/app/lib/more/pages/more.dart +++ b/app/lib/more/pages/more.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import '../../common/module.dart'; import '../../common/utilities/hive_utils.dart'; @@ -134,7 +136,27 @@ class DeleteDataDialog extends HookWidget { ? () async { await deleteAllAppData(); // ignore: use_build_context_synchronously - await overwriteRoutes(context, nextPage: LoginRoute()); + await context.router.root.maybePop(); + // ignore: use_build_context_synchronously + await showAdaptiveDialog( + // ignore: use_build_context_synchronously + context: context, + builder: (context) => DialogWrapper( + title: context.l10n.delete_data_restart_title, + content: Column( + children: [ + SizedBox(height: PharMeTheme.smallSpace), + Text(context.l10n.delete_data_restart_text), + ], + ), + actions: [ + DialogAction( + text: context.l10n.error_close_app, + onPressed: () => exit(0), + ), + ], + ), + ); } : null, text: context.l10n.action_continue,