From d8df377427f2be90b52a8833f8e61709a4b65e8c Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Fri, 23 Sep 2022 14:53:21 +0530 Subject: [PATCH] feat: warning dialog when selecting all patches. --- assets/i18n/en.json | 4 +++- .../patches_selector_view.dart | 7 ++++++- .../patches_selector_viewmodel.dart | 20 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 0c951a7ab3..d4138f0b55 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 afe13eca6b..eac0c94f59 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 b57b075027..3be23413bd 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) {