feat: show warning dialog when resetting stored patches

This prevent user from accidentally resetting stored patches by showing
them warning dialog.
This commit is contained in:
Pun Butrach 2023-07-08 11:01:10 +07:00
parent 16318efb01
commit 9e93177afd
No known key found for this signature in database
GPG Key ID: 5F47D61B676D07F6
2 changed files with 31 additions and 2 deletions

View File

@ -17,7 +17,7 @@
"homeView": {
"refreshSuccess": "Refreshed successfully",
"widgetTitle": "Dashboard",
"updatesSubtitle": "Updates",
"patchedSubtitle": "Patched applications",
@ -211,6 +211,7 @@
"resetStoredPatchesLabel": "Reset patches",
"resetStoredPatchesHint": "Reset the stored patches selection",
"resetStoredPatchesDialogText": "Are you sure you want to reset the stored patches selection?",
"resetStoredPatches": "Patches selection has been reset",
"deleteLogsLabel": "Delete logs",

View File

@ -3,6 +3,7 @@ import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart';
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.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();
@ -91,9 +92,36 @@ class SExportSection extends StatelessWidget {
),
),
subtitle: I18nText('settingsView.resetStoredPatchesHint'),
onTap: () => _settingsViewModel.resetSelectedPatches(),
onTap: () => _showResetStoredPatchesDialog(context),
),
],
);
}
Future<void> _showResetStoredPatchesDialog(context) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('warning'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'settingsView.resetStoredPatchesDialogText',
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () => {
Navigator.of(context).pop(),
_settingsViewModel.resetSelectedPatches()
},
)
],
),
);
}
}