Skip to content

Commit

Permalink
feat: show warning dialog when resetting stored patches
Browse files Browse the repository at this point in the history
This prevent user from accidentally resetting stored patches by showing
them warning dialog.
  • Loading branch information
validcube committed Jul 8, 2023
1 parent 16318ef commit 9e93177
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"homeView": {
"refreshSuccess": "Refreshed successfully",
"widgetTitle": "Dashboard",

"updatesSubtitle": "Updates",
"patchedSubtitle": "Patched applications",

Expand Down Expand Up @@ -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",
Expand Down
30 changes: 29 additions & 1 deletion lib/ui/widgets/settingsView/settings_export_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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()
},
)
],
),
);
}
}

0 comments on commit 9e93177

Please sign in to comment.