Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: experimental patches stay selected when toggled off #946

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/ui/widgets/patchesSelectorView/patch_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -116,7 +117,7 @@ class _PatchItemState extends State<PatchItem> {
value: widget.isSelected,
activeColor: Theme.of(context).colorScheme.primary,
checkColor:
Theme.of(context).colorScheme.secondaryContainer,
Theme.of(context).colorScheme.secondaryContainer,
side: BorderSide(
width: 2.0,
color: Theme.of(context).colorScheme.primary,
Expand All @@ -127,11 +128,16 @@ class _PatchItemState extends State<PatchItem> {
!widget._managerAPI
.areExperimentalPatchesEnabled()) {
widget.isSelected = false;
widget.toast.showBottom(
'patchItem.unsupportedPatchVersion');
widget.toast
.showBottom('patchItem.unsupportedPatchVersion');
} else {
widget.isSelected = newValue!;
}
if (widget.isUnsupported &&
widget.isSelected &&
!selectedUnsupportedPatches.contains(widget.name)) {
selectedUnsupportedPatches.add(widget.name);
}
});
widget.onChanged(widget.isSelected);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -10,6 +11,7 @@ class SExperimentalPatches extends StatefulWidget {
}

final _settingsViewModel = SettingsViewModel();
final List<String> selectedUnsupportedPatches = [];

class _SExperimentalPatchesState extends State<SExperimentalPatches> {
@override
Expand All @@ -32,6 +34,12 @@ class _SExperimentalPatchesState extends State<SExperimentalPatches> {
setState(() {
_settingsViewModel.useExperimentalPatches(value);
});
if(!value) {
for (final patch in selectedUnsupportedPatches) {
PatchesSelectorViewModel().selectedPatches.removeWhere((element) => patch == element.name);
}
selectedUnsupportedPatches.clear();
}
},
);
}
Expand Down