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