mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: add select/deselect icon on Patches Selector View
This commit is contained in:
@ -31,6 +31,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
? Column(
|
||||
children: [
|
||||
SearchBar(
|
||||
showSelectIcon: true,
|
||||
fillColor:
|
||||
isDark ? const Color(0xff1B222B) : Colors.grey[200],
|
||||
hintText: FlutterI18n.translate(
|
||||
@ -43,6 +44,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
query = searchQuery;
|
||||
});
|
||||
},
|
||||
onSelectAll: (value) => model.selectAllPatches(value),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
query.isEmpty || query.length < 2
|
||||
@ -90,11 +92,8 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
simpleName: model.patches[index].simpleName,
|
||||
version: model.patches[index].version,
|
||||
description: model.patches[index].description,
|
||||
isSelected: model.selectedPatches.any(
|
||||
(element) => element.name == model.patches[index].name,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
model.selectPatch(model.patches[index].name, value),
|
||||
isSelected: model.isSelected(index),
|
||||
onChanged: (value) => model.selectPatch(index, value),
|
||||
);
|
||||
_items.add(item);
|
||||
return item;
|
||||
@ -118,11 +117,8 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
simpleName: model.patches[index].simpleName,
|
||||
version: model.patches[index].version,
|
||||
description: model.patches[index].description,
|
||||
isSelected: model.selectedPatches.any(
|
||||
(element) => element.name == model.patches[index].name,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
model.selectPatch(model.patches[index].name, value),
|
||||
isSelected: model.isSelected(index),
|
||||
onChanged: (value) => model.selectPatch(index, value),
|
||||
);
|
||||
_items.add(item);
|
||||
return item;
|
||||
|
@ -17,8 +17,14 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void selectPatch(String name, bool isSelected) {
|
||||
Patch patch = patches.firstWhere((p) => p.name == name);
|
||||
bool isSelected(int index) {
|
||||
return selectedPatches.any(
|
||||
(element) => element.name == patches[index].name,
|
||||
);
|
||||
}
|
||||
|
||||
void selectPatch(int index, bool isSelected) {
|
||||
Patch patch = patches.firstWhere((p) => p.name == patches[index].name);
|
||||
if (isSelected && !selectedPatches.contains(patch)) {
|
||||
selectedPatches.add(patch);
|
||||
} else {
|
||||
@ -27,6 +33,14 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void selectAllPatches(bool isSelected) {
|
||||
selectedPatches.clear();
|
||||
if (isSelected) {
|
||||
selectedPatches.addAll(patches);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void selectPatches() {
|
||||
locator<PatcherViewModel>().selectedPatches = selectedPatches;
|
||||
locator<PatcherViewModel>().notifyListeners();
|
||||
|
Reference in New Issue
Block a user