mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: wip searchbar in appselector.
This commit is contained in:
parent
0350dacb3b
commit
15a7f9f962
@ -1,6 +1,7 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:flutter/material.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 {
|
||||
const AppSelectorScreen({Key? key}) : super(key: key);
|
||||
@ -11,6 +12,7 @@ class AppSelectorScreen extends StatefulWidget {
|
||||
|
||||
class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
List<Application> apps = [];
|
||||
String query = 'yout';
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
@ -27,17 +29,54 @@ class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SearchBar(),
|
||||
if (query.isEmpty || query.length < 2)
|
||||
apps.isEmpty
|
||||
? 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: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 pkgName;
|
||||
bool isSelected = false;
|
||||
|
||||
const InstalledAppItem({
|
||||
InstalledAppItem({
|
||||
Key? key,
|
||||
required this.name,
|
||||
required this.pkgName,
|
||||
required this.isSelected,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<InstalledAppItem> createState() => _InstalledAppItemState();
|
||||
}
|
||||
|
||||
class _InstalledAppItemState extends State<InstalledAppItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
@ -23,16 +32,35 @@ class InstalledAppItem extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(name),
|
||||
Text(pkgName),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
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(
|
||||
value: false,
|
||||
onChanged: (val) {},
|
||||
value: widget.isSelected,
|
||||
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 New Issue
Block a user