feat: filter apps by patch count

This commit is contained in:
Ushie 2022-12-14 01:52:06 +03:00
parent 01a681ad00
commit d78868b462
No known key found for this signature in database
GPG Key ID: 0EF73F1CA38B2D5F
2 changed files with 6 additions and 5 deletions

View File

@ -94,15 +94,14 @@ class PatcherAPI {
return filteredApps;
}
Future<List<Patch>> getFilteredPatches(String packageName) async {
List<Patch> getFilteredPatches(String packageName) {
List<Patch> filteredPatches = [];
_patches.forEach((patch) {
if (patch.compatiblePackages.isEmpty) {
filteredPatches.add(patch);
} else {
if (!patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName)
) {
patch.compatiblePackages.any((pack) => pack.name == packageName)) {
filteredPatches.add(patch);
}
}

View File

@ -2,7 +2,6 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart';
@ -19,7 +18,10 @@ class AppSelectorViewModel extends BaseViewModel {
Future<void> initialize() async {
apps.addAll(await _patcherAPI.getFilteredInstalledApps());
apps.sort((a, b) => a.appName.compareTo(b.appName));
apps.sort(((a, b) => _patcherAPI
.getFilteredPatches(b.packageName)
.length
.compareTo(_patcherAPI.getFilteredPatches(a.packageName).length)));
noApps = apps.isEmpty;
notifyListeners();
}