mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: improve app selector.
This commit is contained in:
parent
89b642772c
commit
3df427dccb
11 changed files with 76 additions and 86 deletions
|
@ -6,7 +6,9 @@
|
|||
|
||||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:stacked_core/stacked_core.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:stacked_services/src/navigation/navigation_service.dart';
|
||||
|
||||
final locator = StackedLocator.instance;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
|
|
|
@ -13,7 +13,7 @@ class ManagerAPI {
|
|||
|
||||
Future<String?> getPath() async {
|
||||
final path = await p.getApplicationSupportDirectory();
|
||||
final workDir = Directory('${path.path}/revanced').createSync();
|
||||
Directory('${path.path}/revanced').createSync();
|
||||
final workDirPath = '${path.path}/revanced';
|
||||
return workDirPath;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ class ManagerAPI {
|
|||
final name = dlUrl
|
||||
?.split('/')
|
||||
.lastWhere((element) => element.contains('revanced'));
|
||||
print(name);
|
||||
final assetFile = File('$workDir/$name');
|
||||
final response = await dio.get(
|
||||
dlUrl!,
|
||||
|
@ -34,16 +33,12 @@ class ManagerAPI {
|
|||
followRedirects: true,
|
||||
receiveTimeout: 0,
|
||||
),
|
||||
onReceiveProgress: (count, total) {
|
||||
print('$count/$total');
|
||||
},
|
||||
);
|
||||
final raf = assetFile.openSync(mode: FileMode.write);
|
||||
raf.writeFromSync(response.data);
|
||||
raf.closeSync();
|
||||
return assetFile;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
|
@ -5,13 +7,13 @@ import 'package:revanced_manager/constants.dart';
|
|||
class InstalledAppItem extends StatefulWidget {
|
||||
final String name;
|
||||
final String pkgName;
|
||||
bool isSelected = false;
|
||||
final Uint8List icon;
|
||||
|
||||
InstalledAppItem({
|
||||
const InstalledAppItem({
|
||||
Key? key,
|
||||
required this.name,
|
||||
required this.pkgName,
|
||||
required this.isSelected,
|
||||
required this.icon,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -21,48 +23,52 @@ class InstalledAppItem extends StatefulWidget {
|
|||
class _InstalledAppItemState extends State<InstalledAppItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: const Color(0xff1B222B),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.name,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.visible,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.pkgName,
|
||||
style: robotoTextStyle,
|
||||
),
|
||||
],
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: const Color(0xff1B222B),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
alignment: Alignment.center,
|
||||
child: CircleAvatar(
|
||||
child: Image.memory(widget.icon),
|
||||
),
|
||||
),
|
||||
),
|
||||
Checkbox(
|
||||
value: widget.isSelected,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
widget.isSelected = val!;
|
||||
Navigator.pop(context);
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.name,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.visible,
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.pkgName,
|
||||
style: robotoTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class SearchBar extends StatefulWidget {
|
||||
SearchBar({
|
||||
const SearchBar({
|
||||
Key? key,
|
||||
required this.onQueryChanged,
|
||||
}) : super(key: key);
|
||||
|
|
|
@ -162,13 +162,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
device_apps:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: device_apps
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
dio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -11,7 +11,6 @@ environment:
|
|||
|
||||
dependencies:
|
||||
cupertino_icons: ^1.0.2
|
||||
device_apps: ^2.2.0
|
||||
dio: ^4.0.6
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
|
Loading…
Reference in a new issue