Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#650): add checkbox when deleting data #656

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
40 changes: 31 additions & 9 deletions app/lib/settings/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SettingsPage extends StatelessWidget {
trailing: Icon(Icons.chevron_right_rounded),
onTap: () => showDialog(
context: context,
builder: (_) => _deleteDataDialog(context),
builder: (_) => DeleteDataDialog(),
),
),
Divider(),
Expand Down Expand Up @@ -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),
),
),
],
Expand Down
Loading