From 2de33a47d8ef10e42227e2de2221d86fb9b6e691 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Thu, 24 Aug 2023 16:14:48 +0200 Subject: [PATCH] feat(#650): add checkbox when deleting data --- app/lib/l10n/app_en.arb | 3 ++- app/lib/settings/pages/settings.dart | 40 +++++++++++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index b18c91261..e59704447 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -233,7 +233,8 @@ "settings_page_account_settings": "Account settings", "settings_page_delete_data": "Delete app data", - "settings_page_delete_data_text": "Are you sure that you want to delete all app data? This also includes your genetic data.", + "settings_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.", + "settings_page_delete_data_confirmation": "I understand that my genetic data will be deleted and it might not be possible to import it again.", "settings_page_more": "More", "settings_page_onboarding": "Onboarding", "settings_page_about_us": "About us", diff --git a/app/lib/settings/pages/settings.dart b/app/lib/settings/pages/settings.dart index 9b3410663..7a4a68c8a 100644 --- a/app/lib/settings/pages/settings.dart +++ b/app/lib/settings/pages/settings.dart @@ -19,7 +19,7 @@ class SettingsPage extends StatelessWidget { trailing: Icon(Icons.chevron_right_rounded), onTap: () => showDialog( context: context, - builder: (_) => _deleteDataDialog(context), + builder: (_) => DeleteDataDialog(), ), ), Divider(), @@ -57,25 +57,47 @@ class SettingsPage extends StatelessWidget { onTap: sendEmail) ]); } +} + +class DeleteDataDialog extends HookWidget { + @override + Widget build(BuildContext context) { + final agreedToDeletion = useState(false); - Widget _deleteDataDialog(BuildContext context) { return AlertDialog( title: Text(context.l10n.settings_page_delete_data), - content: Text(context.l10n.settings_page_delete_data_text), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(context.l10n.settings_page_delete_data_text), + SizedBox(height: PharMeTheme.mediumSpace), + CheckboxListTile( + value: agreedToDeletion.value, + onChanged: (value) => agreedToDeletion.value = value + ?? agreedToDeletion.value, + title: Text(context.l10n.settings_page_delete_data_confirmation), + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.zero, + ), + ]), actions: [ TextButton( onPressed: context.router.root.pop, child: Text(context.l10n.action_cancel), ), TextButton( - onPressed: () async { - await deleteAllAppData(); - // ignore: use_build_context_synchronously - await context.router.replaceAll([LoginRouter()]); - }, + onPressed: agreedToDeletion.value + ? () async { + await deleteAllAppData(); + // ignore: use_build_context_synchronously + await context.router.replaceAll([LoginRouter()]); + } + : null, child: Text( context.l10n.action_continue, - style: TextStyle(color: PharMeTheme.errorColor), + style: agreedToDeletion.value + ? TextStyle(color: PharMeTheme.secondaryColor) + : TextStyle(color: PharMeTheme.onSurfaceColor), ), ), ],