Skip to content

Commit

Permalink
feat: warning dialog when selecting all patches.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunali321 committed Sep 23, 2022
1 parent efe1306 commit d8df377
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/views/patches_selector/patches_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
_query = searchQuery;
});
},
onSelectAll: (value) => model.selectAllPatches(value),
onSelectAll: (value) {
if (value) {
model.selectAllPatcherWarning(context);
}
model.selectAllPatches(value);
},
),
),
),
Expand Down
20 changes: 20 additions & 0 deletions lib/ui/views/patches_selector/patches_selector_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -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<PatcherAPI>();
Expand Down Expand Up @@ -35,6 +38,23 @@ class PatchesSelectorViewModel extends BaseViewModel {
notifyListeners();
}

Future<void> 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: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
}

void selectAllPatches(bool isSelected) {
selectedPatches.clear();
if (isSelected) {
Expand Down

0 comments on commit d8df377

Please sign in to comment.