mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: patch selection while scrolling
This commit is contained in:
parent
cff27872eb
commit
492aa848ff
@ -15,7 +15,7 @@ class PatchedApplication {
|
|||||||
toJson: encodeBase64,
|
toJson: encodeBase64,
|
||||||
)
|
)
|
||||||
final Uint8List icon;
|
final Uint8List icon;
|
||||||
final DateTime patchDate;
|
DateTime patchDate;
|
||||||
final bool isRooted;
|
final bool isRooted;
|
||||||
final bool isFromStorage;
|
final bool isFromStorage;
|
||||||
List<String> appliedPatches;
|
List<String> appliedPatches;
|
||||||
|
@ -118,6 +118,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
isInstalled = await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
isInstalled = await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
updateLog('Done');
|
updateLog('Done');
|
||||||
|
selectedApp.patchDate = DateTime.now();
|
||||||
selectedApp.appliedPatches
|
selectedApp.appliedPatches
|
||||||
.addAll(selectedPatches.map((p) => p.name).toList());
|
.addAll(selectedPatches.map((p) => p.name).toList());
|
||||||
await saveApp(selectedApp);
|
await saveApp(selectedApp);
|
||||||
@ -157,7 +158,8 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
||||||
String app = json.encode(selectedApp.toJson());
|
String app = json.encode(selectedApp.toJson());
|
||||||
patchedApps.remove(app);
|
patchedApps.removeWhere(
|
||||||
|
(a) => json.decode(a)['packageName'] == selectedApp.packageName);
|
||||||
patchedApps.add(app);
|
patchedApps.add(app);
|
||||||
prefs.setStringList('patchedApps', patchedApps);
|
prefs.setStringList('patchedApps', patchedApps);
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
|||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
model.selectPatches(patches);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: I18nText('patchesSelectorView.fabButton'),
|
child: I18nText('patchesSelectorView.fabButton'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -22,17 +22,17 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
|||||||
patches = await patcherAPI.getFilteredPatches(app);
|
patches = await patcherAPI.getFilteredPatches(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectPatches(List<PatchItem> patchItems) {
|
void selectPatch(PatchItem item) {
|
||||||
selectedPatches.clear();
|
Patch patch = locator<PatchesSelectorViewModel>()
|
||||||
for (PatchItem item in patchItems) {
|
.patches
|
||||||
if (item.isSelected) {
|
.firstWhere((p) => p.name == item.name);
|
||||||
Patch patch =
|
if (item.isSelected &&
|
||||||
patches.firstWhere((element) => element.name == item.name);
|
!locator<PatchesSelectorViewModel>().selectedPatches.contains(patch)) {
|
||||||
if (!selectedPatches.contains(patch)) {
|
locator<PatchesSelectorViewModel>().selectedPatches.add(patch);
|
||||||
selectedPatches.add(patch);
|
} else {
|
||||||
}
|
locator<PatchesSelectorViewModel>().selectedPatches.remove(patch);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
locator<PatchesSelectorViewModel>().notifyListeners();
|
||||||
locator<PatcherViewModel>().notifyListeners();
|
locator<PatcherViewModel>().notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
|
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class PatchItem extends StatefulWidget {
|
class PatchItem extends StatefulWidget {
|
||||||
@ -26,9 +28,10 @@ class _PatchItemState extends State<PatchItem> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => setState(() {
|
onTap: () {
|
||||||
widget.isSelected = !widget.isSelected;
|
setState(() => widget.isSelected = !widget.isSelected);
|
||||||
}),
|
locator<PatchesSelectorViewModel>().selectPatch(widget);
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
@ -78,9 +81,8 @@ class _PatchItemState extends State<PatchItem> {
|
|||||||
value: widget.isSelected,
|
value: widget.isSelected,
|
||||||
activeColor: Colors.blueGrey[500],
|
activeColor: Colors.blueGrey[500],
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
setState(() {
|
setState(() => widget.isSelected = newValue!);
|
||||||
widget.isSelected = newValue!;
|
locator<PatchesSelectorViewModel>().selectPatch(widget);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user