mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-01 22:34:25 +02:00
feat: fully working search bar.
This commit is contained in:
parent
15a7f9f962
commit
0b58ce3dca
@ -12,7 +12,7 @@ class AppSelectorScreen extends StatefulWidget {
|
||||
|
||||
class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
List<Application> apps = [];
|
||||
String query = 'yout';
|
||||
String query = '';
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
@ -30,10 +30,16 @@ class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SearchBar(),
|
||||
SearchBar(
|
||||
onQueryChanged: (searchQuery) {
|
||||
setState(() {
|
||||
query = searchQuery;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (query.isEmpty || query.length < 2)
|
||||
apps.isEmpty
|
||||
? const Center(
|
||||
@ -43,6 +49,8 @@ class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
//sort alphabetically
|
||||
apps.sort((a, b) => a.appName.compareTo(b.appName));
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
@ -60,6 +68,7 @@ class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
apps.sort((a, b) => a.appName.compareTo(b.appName));
|
||||
if (apps[index].appName.toLowerCase().contains(
|
||||
query.toLowerCase(),
|
||||
)) {
|
||||
|
@ -37,7 +37,7 @@ class PatcherScreen extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AppSelectorScreen()));
|
||||
builder: (context) => const AppSelectorScreen()));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
@ -2,10 +2,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class SearchBar extends StatefulWidget {
|
||||
const SearchBar({
|
||||
SearchBar({
|
||||
Key? key,
|
||||
required this.onQueryChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
final Function(String) onQueryChanged;
|
||||
|
||||
@override
|
||||
State<SearchBar> createState() => _SearchBarState();
|
||||
}
|
||||
@ -14,10 +17,6 @@ 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),
|
||||
@ -30,7 +29,7 @@ class _SearchBarState extends State<SearchBar> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
onSubmitted: (value) {},
|
||||
onChanged: widget.onQueryChanged,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.blueGrey[700],
|
||||
filled: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user