mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-12 18:04:28 +01:00
feat: wip searchbar in appselector.
This commit is contained in:
parent
0350dacb3b
commit
15a7f9f962
3 changed files with 153 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:revanced_manager_flutter/ui/widgets/installed_app_item.dart';
|
import 'package:revanced_manager_flutter/ui/widgets/installed_app_item.dart';
|
||||||
|
import 'package:revanced_manager_flutter/ui/widgets/search_bar.dart';
|
||||||
|
|
||||||
class AppSelectorScreen extends StatefulWidget {
|
class AppSelectorScreen extends StatefulWidget {
|
||||||
const AppSelectorScreen({Key? key}) : super(key: key);
|
const AppSelectorScreen({Key? key}) : super(key: key);
|
||||||
|
@ -11,6 +12,7 @@ class AppSelectorScreen extends StatefulWidget {
|
||||||
|
|
||||||
class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||||
List<Application> apps = [];
|
List<Application> apps = [];
|
||||||
|
String query = 'yout';
|
||||||
|
|
||||||
void getApps() async {
|
void getApps() async {
|
||||||
apps = await DeviceApps.getInstalledApplications();
|
apps = await DeviceApps.getInstalledApplications();
|
||||||
|
@ -27,17 +29,54 @@ class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: apps.isEmpty
|
child: Padding(
|
||||||
? const Center(child: CircularProgressIndicator())
|
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
|
||||||
: ListView.builder(
|
child: Column(
|
||||||
itemCount: apps.length,
|
children: [
|
||||||
itemBuilder: (context, index) {
|
SearchBar(),
|
||||||
return InstalledAppItem(
|
if (query.isEmpty || query.length < 2)
|
||||||
name: apps[index].appName,
|
apps.isEmpty
|
||||||
pkgName: apps[index].packageName,
|
? const Center(
|
||||||
);
|
child: CircularProgressIndicator(),
|
||||||
},
|
)
|
||||||
),
|
: Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: apps.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return InstalledAppItem(
|
||||||
|
name: apps[index].appName,
|
||||||
|
pkgName: apps[index].packageName,
|
||||||
|
isSelected: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (query.isNotEmpty)
|
||||||
|
apps.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: Text('No apps found'),
|
||||||
|
)
|
||||||
|
: Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: apps.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (apps[index].appName.toLowerCase().contains(
|
||||||
|
query.toLowerCase(),
|
||||||
|
)) {
|
||||||
|
return InstalledAppItem(
|
||||||
|
name: apps[index].appName,
|
||||||
|
pkgName: apps[index].packageName,
|
||||||
|
isSelected: false,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return SizedBox();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:revanced_manager_flutter/constants.dart';
|
||||||
|
|
||||||
class InstalledAppItem extends StatelessWidget {
|
class InstalledAppItem extends StatefulWidget {
|
||||||
final String name;
|
final String name;
|
||||||
final String pkgName;
|
final String pkgName;
|
||||||
|
bool isSelected = false;
|
||||||
|
|
||||||
const InstalledAppItem({
|
InstalledAppItem({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.pkgName,
|
required this.pkgName,
|
||||||
|
required this.isSelected,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<InstalledAppItem> createState() => _InstalledAppItemState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InstalledAppItemState extends State<InstalledAppItem> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -23,16 +32,35 @@ class InstalledAppItem extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Expanded(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(name),
|
children: [
|
||||||
Text(pkgName),
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: false,
|
value: widget.isSelected,
|
||||||
onChanged: (val) {},
|
onChanged: (val) {
|
||||||
|
setState(() {
|
||||||
|
widget.isSelected = val!;
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
64
lib/ui/widgets/search_bar.dart
Normal file
64
lib/ui/widgets/search_bar.dart
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
class SearchBar extends StatefulWidget {
|
||||||
|
const SearchBar({
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SearchBar> createState() => _SearchBarState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchBarState extends State<SearchBar> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 0.0,
|
||||||
|
horizontal: 0.0,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
color: const Color(0xff1B222B),
|
||||||
|
border: Border.all(
|
||||||
|
color: const Color(0xff1B222B),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
onSubmitted: (value) {},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
fillColor: Colors.blueGrey[700],
|
||||||
|
filled: true,
|
||||||
|
contentPadding: const EdgeInsets.all(12.0),
|
||||||
|
hintText: 'Search applications',
|
||||||
|
hintStyle: GoogleFonts.poppins(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
prefixIcon: const Icon(
|
||||||
|
Icons.search,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue