mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 20:57:36 +02:00
fix: improve app selector.
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:installed_apps/app_info.dart';
|
||||
import 'package:installed_apps/installed_apps.dart';
|
||||
import 'package:revanced_manager/ui/widgets/installed_app_item.dart';
|
||||
import 'package:revanced_manager/ui/widgets/search_bar.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import 'app_selector_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
|
||||
|
||||
class AppSelectorView extends StatefulWidget {
|
||||
const AppSelectorView({Key? key}) : super(key: key);
|
||||
@ -14,11 +14,11 @@ class AppSelectorView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
List<Application> apps = [];
|
||||
List<AppInfo> apps = [];
|
||||
String query = '';
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
apps = await InstalledApps.getInstalledApps(false, true);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@ -55,12 +55,11 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
//sort alphabetically
|
||||
apps.sort(
|
||||
(a, b) => a.appName.compareTo(b.appName));
|
||||
apps.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
name: apps[index].name!,
|
||||
pkgName: apps[index].packageName!,
|
||||
icon: apps[index].icon!,
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -74,18 +73,17 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
apps.sort(
|
||||
(a, b) => a.appName.compareTo(b.appName));
|
||||
if (apps[index].appName.toLowerCase().contains(
|
||||
apps.sort((a, b) => a.name!.compareTo(b.name!));
|
||||
if (apps[index].name!.toLowerCase().contains(
|
||||
query.toLowerCase(),
|
||||
)) {
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
name: apps[index].name!,
|
||||
pkgName: apps[index].packageName!,
|
||||
icon: apps[index].icon!,
|
||||
);
|
||||
} else {
|
||||
return SizedBox();
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
|
@ -1,8 +1,9 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:installed_apps/app_info.dart';
|
||||
import 'package:installed_apps/installed_apps.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class AppSelectorViewModel extends BaseViewModel {
|
||||
List<Application> apps = [];
|
||||
List<AppInfo> apps = [];
|
||||
String query = '';
|
||||
|
||||
void initialization() {
|
||||
@ -10,6 +11,6 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
apps = await InstalledApps.getInstalledApps(false, true);
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ class HomeView extends StatelessWidget {
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 0.0,
|
||||
horizontal: 20.0,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
|
||||
import 'package:revanced_manager/ui/widgets/app_selector_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/patch_selector_card.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
@ -24,8 +23,7 @@ class PatcherView extends StatelessWidget {
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
Reference in New Issue
Block a user