mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
fix: patch selection while scrolling
This commit is contained in:
@ -118,6 +118,7 @@ class InstallerViewModel extends BaseViewModel {
|
||||
isInstalled = await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
||||
if (isInstalled) {
|
||||
updateLog('Done');
|
||||
selectedApp.patchDate = DateTime.now();
|
||||
selectedApp.appliedPatches
|
||||
.addAll(selectedPatches.map((p) => p.name).toList());
|
||||
await saveApp(selectedApp);
|
||||
@ -157,7 +158,8 @@ class InstallerViewModel extends BaseViewModel {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
||||
String app = json.encode(selectedApp.toJson());
|
||||
patchedApps.remove(app);
|
||||
patchedApps.removeWhere(
|
||||
(a) => json.decode(a)['packageName'] == selectedApp.packageName);
|
||||
patchedApps.add(app);
|
||||
prefs.setStringList('patchedApps', patchedApps);
|
||||
}
|
||||
|
@ -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