From 0350dacb3b7d9b94c1826b36e56c5e0fb468460a Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Tue, 2 Aug 2022 14:49:14 +0530 Subject: [PATCH] feat: primitive app selector screen. --- android/app/src/main/AndroidManifest.xml | 1 + lib/ui/screens/app_selector_screen.dart | 44 ++++++++++++++++++++++++ lib/ui/screens/patcher_screen.dart | 17 +++------ lib/ui/widgets/installed_app_item.dart | 42 ++++++++++++++++++++++ pubspec.lock | 7 ++++ pubspec.yaml | 1 + 6 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 lib/ui/screens/app_selector_screen.dart create mode 100644 lib/ui/widgets/installed_app_item.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 19eaf983..61043029 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ + createState() => _AppSelectorScreenState(); +} + +class _AppSelectorScreenState extends State { + List apps = []; + + void getApps() async { + apps = await DeviceApps.getInstalledApplications(); + setState(() {}); + } + + @override + void initState() { + getApps(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: apps.isEmpty + ? const Center(child: CircularProgressIndicator()) + : ListView.builder( + itemCount: apps.length, + itemBuilder: (context, index) { + return InstalledAppItem( + name: apps[index].appName, + pkgName: apps[index].packageName, + ); + }, + ), + ), + ); + } +} diff --git a/lib/ui/screens/patcher_screen.dart b/lib/ui/screens/patcher_screen.dart index 87afc739..bb758402 100644 --- a/lib/ui/screens/patcher_screen.dart +++ b/lib/ui/screens/patcher_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:revanced_manager_flutter/ui/screens/app_selector_screen.dart'; import 'package:revanced_manager_flutter/ui/widgets/app_selector_card.dart'; import 'package:revanced_manager_flutter/ui/widgets/patch_selector_card.dart'; @@ -33,18 +34,10 @@ class PatcherScreen extends StatelessWidget { const SizedBox(height: 23), AppSelectorCard( onPressed: () { - //show snackbar - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "Select application", - style: GoogleFonts.inter( - fontSize: 18, - fontWeight: FontWeight.w500, - ), - ), - ), - ); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AppSelectorScreen())); }, ), const SizedBox(height: 16), diff --git a/lib/ui/widgets/installed_app_item.dart b/lib/ui/widgets/installed_app_item.dart new file mode 100644 index 00000000..d1fa7001 --- /dev/null +++ b/lib/ui/widgets/installed_app_item.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class InstalledAppItem extends StatelessWidget { + final String name; + final String pkgName; + + const InstalledAppItem({ + Key? key, + required this.name, + required this.pkgName, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.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: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(name), + Text(pkgName), + ], + ), + Checkbox( + value: false, + onChanged: (val) {}, + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index f7b67e32..b422cec1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + 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: diff --git a/pubspec.yaml b/pubspec.yaml index 7099c08d..1b292c93 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: github: ^9.4.0 path_provider: ^2.0.11 dio: ^4.0.6 + device_apps: ^2.2.0 dev_dependencies: flutter_test: