From 054afbbedd70a1933d8241ff5b63a772f90b555f Mon Sep 17 00:00:00 2001 From: EvadeMaster <93124920+EvadeMaster@users.noreply.github.com> Date: Sat, 1 Apr 2023 21:02:28 +0700 Subject: [PATCH] feat: confirmation dialog for deleting keystore (#764) * feat: confirmation dialog for deleting keystore * refactor(i18n): apply suggestion from code-reviewer Co-authored-by: Ushie * refactor: apply suggestion from code-reviewer Co-authored-by: Mipirakas --------- Co-authored-by: Ushie Co-authored-by: Mipirakas --- assets/i18n/en_US.json | 1 + .../settings_advanced_section.dart | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index 49a95bf5..1a86cb62 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -151,6 +151,7 @@ "restartAppForChanges": "Restart the app to apply changes", "deleteKeystoreLabel": "Delete keystore", "deleteKeystoreHint": "Delete the keystore used to sign the app", + "deleteKeystoreDialogText": "Are you sure you want to delete the keystore used to sign patched applications?", "deletedKeystore": "Keystore deleted", "deleteTempDirLabel": "Delete temporary files", "deleteTempDirHint": "Delete unused temporary files", diff --git a/lib/ui/widgets/settingsView/settings_advanced_section.dart b/lib/ui/widgets/settingsView/settings_advanced_section.dart index 2dda210e..23cfbcda 100644 --- a/lib/ui/widgets/settingsView/settings_advanced_section.dart +++ b/lib/ui/widgets/settingsView/settings_advanced_section.dart @@ -8,6 +8,7 @@ import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_patches.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_universal_patches.dart'; import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart'; +import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; final _settingsViewModel = SettingsViewModel(); @@ -36,7 +37,7 @@ class SAdvancedSection extends StatelessWidget { ), ), subtitle: I18nText('settingsView.deleteKeystoreHint'), - onTap: () => _settingsViewModel.deleteKeystore, + onTap: () => _showDeleteKeystoreDialog(context), ), ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 20.0), @@ -71,4 +72,31 @@ class SAdvancedSection extends StatelessWidget { ], ); } + + Future _showDeleteKeystoreDialog(context) { + return showDialog( + context: context, + builder: (context) => AlertDialog( + title: I18nText('warning'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + content: I18nText( + 'settingsView.deleteKeystoreDialogText', + ), + actions: [ + CustomMaterialButton( + isFilled: false, + label: I18nText('noButton'), + onPressed: () => Navigator.of(context).pop(), + ), + CustomMaterialButton( + label: I18nText('yesButton'), + onPressed: () => { + Navigator.of(context).pop(), + _settingsViewModel.deleteKeystore() + }, + ) + ], + ), + ); + } }