diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 0c951a7a..d4138f0b 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -75,7 +75,9 @@ "viewTitle": "Select patches", "searchBarHint": "Search patches", "doneButton": "Done", - "noPatchesFound": "No patches found for the selected app" + "noPatchesFound": "No patches found for the selected app", + "selectAllPatchesWarningTitle": "Warning", + "selectAllPatchesWarningContent": "You are about to select all patches, that includes unrecommended patches and can cause unwanted behavior." }, "patchItem": { "unsupportedWarningButton": "Unsupported version", diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index afe13eca..eac0c94f 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -73,7 +73,12 @@ class _PatchesSelectorViewState extends State { _query = searchQuery; }); }, - onSelectAll: (value) => model.selectAllPatches(value), + onSelectAll: (value) { + if (value) { + model.selectAllPatcherWarning(context); + } + model.selectAllPatches(value); + }, ), ), ), diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index b57b0750..3be23413 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -1,10 +1,13 @@ import 'package:collection/collection.dart'; +import 'package:flutter_i18n/widgets/I18nText.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; +import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:stacked/stacked.dart'; +import 'package:flutter/material.dart'; class PatchesSelectorViewModel extends BaseViewModel { final PatcherAPI _patcherAPI = locator(); @@ -35,6 +38,23 @@ class PatchesSelectorViewModel extends BaseViewModel { notifyListeners(); } + Future selectAllPatcherWarning(BuildContext context) { + return showDialog( + context: context, + builder: (context) => AlertDialog( + title: I18nText('patchesSelectorView.selectAllPatchesWarningTitle'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + content: I18nText('patchesSelectorView.selectAllPatchesWarningContent'), + actions: [ + CustomMaterialButton( + label: I18nText('okButton'), + onPressed: () => Navigator.of(context).pop(), + ) + ], + ), + ); + } + void selectAllPatches(bool isSelected) { selectedPatches.clear(); if (isSelected) {