mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: improve app selector.
This commit is contained in:
parent
89b642772c
commit
3df427dccb
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
// ignore_for_file: public_member_api_docs
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
|
// ignore: depend_on_referenced_packages
|
||||||
import 'package:stacked_core/stacked_core.dart';
|
import 'package:stacked_core/stacked_core.dart';
|
||||||
|
// ignore: implementation_imports
|
||||||
import 'package:stacked_services/src/navigation/navigation_service.dart';
|
import 'package:stacked_services/src/navigation/navigation_service.dart';
|
||||||
|
|
||||||
final locator = StackedLocator.instance;
|
final locator = StackedLocator.instance;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
|
// ignore: depend_on_referenced_packages
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/app/app.router.dart';
|
import 'package:revanced_manager/app/app.router.dart';
|
||||||
|
@ -13,7 +13,7 @@ class ManagerAPI {
|
|||||||
|
|
||||||
Future<String?> getPath() async {
|
Future<String?> getPath() async {
|
||||||
final path = await p.getApplicationSupportDirectory();
|
final path = await p.getApplicationSupportDirectory();
|
||||||
final workDir = Directory('${path.path}/revanced').createSync();
|
Directory('${path.path}/revanced').createSync();
|
||||||
final workDirPath = '${path.path}/revanced';
|
final workDirPath = '${path.path}/revanced';
|
||||||
return workDirPath;
|
return workDirPath;
|
||||||
}
|
}
|
||||||
@ -25,7 +25,6 @@ class ManagerAPI {
|
|||||||
final name = dlUrl
|
final name = dlUrl
|
||||||
?.split('/')
|
?.split('/')
|
||||||
.lastWhere((element) => element.contains('revanced'));
|
.lastWhere((element) => element.contains('revanced'));
|
||||||
print(name);
|
|
||||||
final assetFile = File('$workDir/$name');
|
final assetFile = File('$workDir/$name');
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
dlUrl!,
|
dlUrl!,
|
||||||
@ -34,16 +33,12 @@ class ManagerAPI {
|
|||||||
followRedirects: true,
|
followRedirects: true,
|
||||||
receiveTimeout: 0,
|
receiveTimeout: 0,
|
||||||
),
|
),
|
||||||
onReceiveProgress: (count, total) {
|
|
||||||
print('$count/$total');
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
final raf = assetFile.openSync(mode: FileMode.write);
|
final raf = assetFile.openSync(mode: FileMode.write);
|
||||||
raf.writeFromSync(response.data);
|
raf.writeFromSync(response.data);
|
||||||
raf.closeSync();
|
raf.closeSync();
|
||||||
return assetFile;
|
return assetFile;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:device_apps/device_apps.dart';
|
|
||||||
import 'package:flutter/material.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/installed_app_item.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/search_bar.dart';
|
import 'package:revanced_manager/ui/widgets/search_bar.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
|
||||||
import 'app_selector_viewmodel.dart';
|
|
||||||
|
|
||||||
class AppSelectorView extends StatefulWidget {
|
class AppSelectorView extends StatefulWidget {
|
||||||
const AppSelectorView({Key? key}) : super(key: key);
|
const AppSelectorView({Key? key}) : super(key: key);
|
||||||
@ -14,11 +14,11 @@ class AppSelectorView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AppSelectorViewState extends State<AppSelectorView> {
|
class _AppSelectorViewState extends State<AppSelectorView> {
|
||||||
List<Application> apps = [];
|
List<AppInfo> apps = [];
|
||||||
String query = '';
|
String query = '';
|
||||||
|
|
||||||
void getApps() async {
|
void getApps() async {
|
||||||
apps = await DeviceApps.getInstalledApplications();
|
apps = await InstalledApps.getInstalledApps(false, true);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +55,11 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
|||||||
itemCount: apps.length,
|
itemCount: apps.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
//sort alphabetically
|
//sort alphabetically
|
||||||
apps.sort(
|
apps.sort((a, b) => a.name!.compareTo(b.name!));
|
||||||
(a, b) => a.appName.compareTo(b.appName));
|
|
||||||
return InstalledAppItem(
|
return InstalledAppItem(
|
||||||
name: apps[index].appName,
|
name: apps[index].name!,
|
||||||
pkgName: apps[index].packageName,
|
pkgName: apps[index].packageName!,
|
||||||
isSelected: false,
|
icon: apps[index].icon!,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -74,18 +73,17 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
|||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: apps.length,
|
itemCount: apps.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
apps.sort(
|
apps.sort((a, b) => a.name!.compareTo(b.name!));
|
||||||
(a, b) => a.appName.compareTo(b.appName));
|
if (apps[index].name!.toLowerCase().contains(
|
||||||
if (apps[index].appName.toLowerCase().contains(
|
|
||||||
query.toLowerCase(),
|
query.toLowerCase(),
|
||||||
)) {
|
)) {
|
||||||
return InstalledAppItem(
|
return InstalledAppItem(
|
||||||
name: apps[index].appName,
|
name: apps[index].name!,
|
||||||
pkgName: apps[index].packageName,
|
pkgName: apps[index].packageName!,
|
||||||
isSelected: false,
|
icon: apps[index].icon!,
|
||||||
);
|
);
|
||||||
} else {
|
} 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';
|
import 'package:stacked/stacked.dart';
|
||||||
|
|
||||||
class AppSelectorViewModel extends BaseViewModel {
|
class AppSelectorViewModel extends BaseViewModel {
|
||||||
List<Application> apps = [];
|
List<AppInfo> apps = [];
|
||||||
String query = '';
|
String query = '';
|
||||||
|
|
||||||
void initialization() {
|
void initialization() {
|
||||||
@ -10,6 +11,6 @@ class AppSelectorViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getApps() async {
|
void getApps() async {
|
||||||
apps = await DeviceApps.getInstalledApplications();
|
apps = await InstalledApps.getInstalledApps(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,7 @@ class HomeView extends StatelessWidget {
|
|||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
vertical: 0.0,
|
|
||||||
horizontal: 20.0,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:google_fonts/google_fonts.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/app_selector_card.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/patch_selector_card.dart';
|
import 'package:revanced_manager/ui/widgets/patch_selector_card.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
@ -24,8 +23,7 @@ class PatcherView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.all(12.0),
|
||||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
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/constants.dart';
|
import 'package:revanced_manager/constants.dart';
|
||||||
@ -5,13 +7,13 @@ import 'package:revanced_manager/constants.dart';
|
|||||||
class InstalledAppItem extends StatefulWidget {
|
class InstalledAppItem extends StatefulWidget {
|
||||||
final String name;
|
final String name;
|
||||||
final String pkgName;
|
final String pkgName;
|
||||||
bool isSelected = false;
|
final Uint8List icon;
|
||||||
|
|
||||||
InstalledAppItem({
|
const InstalledAppItem({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.pkgName,
|
required this.pkgName,
|
||||||
required this.isSelected,
|
required this.icon,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -21,48 +23,52 @@ class InstalledAppItem extends StatefulWidget {
|
|||||||
class _InstalledAppItemState extends State<InstalledAppItem> {
|
class _InstalledAppItemState extends State<InstalledAppItem> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return InkWell(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
onTap: () => Navigator.pop(context),
|
||||||
child: Container(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
borderRadius: BorderRadius.circular(12),
|
padding: const EdgeInsets.all(12.0),
|
||||||
color: const Color(0xff1B222B),
|
decoration: BoxDecoration(
|
||||||
),
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: Row(
|
color: const Color(0xff1B222B),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
),
|
||||||
children: [
|
child: Row(
|
||||||
Expanded(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Container(
|
||||||
children: [
|
width: 48,
|
||||||
Text(
|
height: 48,
|
||||||
widget.name,
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
maxLines: 2,
|
alignment: Alignment.center,
|
||||||
overflow: TextOverflow.visible,
|
child: CircleAvatar(
|
||||||
style: GoogleFonts.inter(
|
child: Image.memory(widget.icon),
|
||||||
fontSize: 16,
|
),
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
widget.pkgName,
|
|
||||||
style: robotoTextStyle,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 12),
|
||||||
Checkbox(
|
Expanded(
|
||||||
value: widget.isSelected,
|
child: Column(
|
||||||
onChanged: (val) {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
setState(() {
|
children: [
|
||||||
widget.isSelected = val!;
|
Text(
|
||||||
Navigator.pop(context);
|
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';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
class SearchBar extends StatefulWidget {
|
class SearchBar extends StatefulWidget {
|
||||||
SearchBar({
|
const SearchBar({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.onQueryChanged,
|
required this.onQueryChanged,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -162,13 +162,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.3"
|
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:
|
dio:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -11,7 +11,6 @@ environment:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
device_apps: ^2.2.0
|
|
||||||
dio: ^4.0.6
|
dio: ^4.0.6
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user