mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 04:37:37 +02:00
fix: patch selection while scrolling
This commit is contained in:
@ -62,10 +62,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
onPressed: () {
|
||||
model.selectPatches(patches);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: I18nText('patchesSelectorView.fabButton'),
|
||||
),
|
||||
],
|
||||
|
@ -22,17 +22,17 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
patches = await patcherAPI.getFilteredPatches(app);
|
||||
}
|
||||
|
||||
void selectPatches(List<PatchItem> patchItems) {
|
||||
selectedPatches.clear();
|
||||
for (PatchItem item in patchItems) {
|
||||
if (item.isSelected) {
|
||||
Patch patch =
|
||||
patches.firstWhere((element) => element.name == item.name);
|
||||
if (!selectedPatches.contains(patch)) {
|
||||
selectedPatches.add(patch);
|
||||
}
|
||||
}
|
||||
void selectPatch(PatchItem item) {
|
||||
Patch patch = locator<PatchesSelectorViewModel>()
|
||||
.patches
|
||||
.firstWhere((p) => p.name == item.name);
|
||||
if (item.isSelected &&
|
||||
!locator<PatchesSelectorViewModel>().selectedPatches.contains(patch)) {
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.add(patch);
|
||||
} else {
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.remove(patch);
|
||||
}
|
||||
locator<PatchesSelectorViewModel>().notifyListeners();
|
||||
locator<PatcherViewModel>().notifyListeners();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user