From 6c823a76d5b4d3eeaf49d4796cf76f8ec3d17afa Mon Sep 17 00:00:00 2001 From: Aabed Khan Date: Thu, 15 Jun 2023 18:20:32 +0545 Subject: [PATCH] fix: unsupported patches keep being selected --- lib/ui/widgets/patchesSelectorView/patch_item.dart | 6 ++++++ .../settingsView/settings_experimental_patches.dart | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index c3cfba8002..62def8e766 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -3,6 +3,7 @@ import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/toast.dart'; +import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_patches.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; @@ -132,6 +133,11 @@ class _PatchItemState extends State { } else { widget.isSelected = newValue!; } + if (widget.isUnsupported && + widget.isSelected && + !selectedUnsupportedPatches.contains(widget.name)) { + selectedUnsupportedPatches.add(widget.name); + } }); widget.onChanged(widget.isSelected); }, diff --git a/lib/ui/widgets/settingsView/settings_experimental_patches.dart b/lib/ui/widgets/settingsView/settings_experimental_patches.dart index b5bf97db40..79f5e7fe82 100644 --- a/lib/ui/widgets/settingsView/settings_experimental_patches.dart +++ b/lib/ui/widgets/settingsView/settings_experimental_patches.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/widgets/I18nText.dart'; +import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; class SExperimentalPatches extends StatefulWidget { @@ -10,6 +11,7 @@ class SExperimentalPatches extends StatefulWidget { } final _settingsViewModel = SettingsViewModel(); +final List selectedUnsupportedPatches = []; class _SExperimentalPatchesState extends State { @override @@ -32,6 +34,12 @@ class _SExperimentalPatchesState extends State { setState(() { _settingsViewModel.useExperimentalPatches(value); }); + if(!value) { + for (final patch in selectedUnsupportedPatches) { + PatchesSelectorViewModel().selectedPatches.removeWhere((element) => patch == element.name); + } + selectedUnsupportedPatches.clear(); + } }, ); }